Example #1
0
$PlayerUpkeep = $user->getUpkeep();
$updatedCash = 0;
$request_timer = '';
$increment_value = '';
$fn = new common_functions();
if (isset($_GET)) {
    if (!isset($_GET['operation'])) {
        if (isset($_GET['request_timer']) && $_GET['request_timer'] == "income_timer") {
            $increment_value = $_GET['increment_value'];
            $request_timer = $_GET['request_timer'];
            //if(UserTimers::incrementIncomeTimer($_SESSION['userID'], $increment_value)){
            if (UserTimers::updateIncomeTimer($_SESSION['userID'])) {
                if ($PlayerNetIncome > 0) {
                    $updatedCash = $playerCash + $PlayerNetIncome;
                } else {
                    $userUpkeepItemsDetails = Item::getUserUpkeepItems($_SESSION['userID']);
                    $allUpkeepItems = array();
                    foreach ($userUpkeepItemsDetails as $item) {
                        array_push($allUpkeepItems, array('type' => 'item', 'id' => $item->getID(), 'upkeep' => $item->getUpkeep(), 'quantity' => $item->getQuantity(), 'price' => $item->getPrice()));
                    }
                    $fn->aasort($allUpkeepItems, "upkeep");
                    $allUpkeepItems = array_reverse($allUpkeepItems);
                    $count = 0;
                    if (count($allUpkeepItems) > 0) {
                        while ($playerCash + $PlayerNetIncome < 0) {
                            if ($allUpkeepItems[$count]['quantity'] > 0) {
                                $amount = 0;
                                echo $PlayerNetIncome . " < " . $playerCash . "<br>";
                                $id = $allUpkeepItems[$count]['id'];
                                echo $id . "<-id<br>";
                                $upkeep = $allUpkeepItems[$count]['upkeep'];