aboutsummaryrefslogtreecommitdiffstats
path: root/inc/account.inc
blob: f7e3c0527c24b09f49ff2609292fb4221d7cb9c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
 * Manages player's account: debit and credit.
 *
 * @package inc\account.inc
 * @author     Alexandre Renoux
 * @author     Pierre-Emmanuel Novac
 */

require_once("messages.inc");

/**
 * Debits the account of a certain amount of gold.
 *
 * @param int  $amount amount to debit
 * @return boolean  true if player had enough gold, false otherwise
 */
function debitAccount($amount) {
	if($_SESSION["mine"]["gold"] < $amount) {
		sendError("gold_insufficient");
		return false;
	}
	$_SESSION["mine"]["gold"] -= $amount;
	return true;
}

/**
 * Credits the account of a certain amount of gold.
 *
 * @param int  $amount amount to credit
 * @return void
 */
function creditAccount($amount) {
	$_SESSION["mine"]["gold"] += $amount;
}


?>