EconomyHelper impl update

This commit is contained in:
Astrologies 2021-12-31 03:04:28 -05:00
parent b98250e808
commit 8ad30a129a
2 changed files with 9 additions and 13 deletions

View File

@ -1,5 +1,6 @@
<?php
use Alphaland\Economy\EconomyHelper;
use Alphaland\Users\User;
use Alphaland\Web\WebContextManager;
@ -13,18 +14,12 @@ if(isset($_GET['id']))
//handle purchasing items
if(isset($_POST['buyitem']))
{
$result = buyItem($id);
if ($result == 0)
{
$alert = "<div class='alert alert-danger' role='alert'>You don't have enough Alphabux</div>";
}
elseif ($result == 1)
{
$alert = "<div class='alert alert-danger' role='alert'>You already own this item</div>";
}
elseif ($result == 2)
{
WebContextManager::Redirect("/catalog/view?id=". $id . "");
try {
if (EconomyHelper::PurchaseItem($user->id, $id)) {
WebContextManager::Redirect("/catalog/view?id=". $id . "");
}
} catch (Exception $e) {
$alert = "<div class='alert alert-danger' role='alert'>".$e->getMessage()."</div>";
}
}
// ...

View File

@ -5,6 +5,7 @@ Alphaland 2021
*/
use Alphaland\Assets\Asset;
use Alphaland\Economy\EconomyHelper;
use Alphaland\Web\WebContextManager;
$body = '';
@ -172,7 +173,7 @@ function uploadCosmetic()
}
//remove currency
if (!removeCurrency($minimumprice, "Creation of cosmetic name ".$name))
if (!EconomyHelper::RemoveAlphabux($minimumprice, $GLOBALS['user']->id, "Creation of cosmetic name ".$name))
{
return "You don't have enough currency";
}