Example #1
0
	private static function
	upgrade(User $user, $name, $cost = null, $what = false, $delta = 0) {
		$msg = '';
		
		if ($cost != null and $cost != Inf and $cost != 0 and $what and $delta) {
			if ($user->canBuy($cost)) {
				$user->buy($cost, $what, $delta);
				$msg = "You have increased your $name by $delta";
				$user->save();
				Upgrades::$isErr = false;
			}
			else {
				$msg = 'You do not have enough resources';
				Upgrades::$isErr = true;
			}
		}
		
		return $msg;
	}
Example #2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require './database.php';
require './class/user.php';
session_start();
$user = new User($db);
$data = $user->userinfo($_SESSION['uid']);
if ($_POST['one'] * 1 + $_POST['double'] * 3 + $_POST['cash'] * 2 < $data['money']) {
    $user->buy($_POST['one'], $_POST['double'], $_POST['cash'], $_SESSION['uid']);
    echo 'Success!';
} else {
    echo 'Failure!';
}