aboutsummaryrefslogtreecommitdiffstats
path: root/inc/account.inc
blob: bfbd47b47e5eb88cc383bc1fbe8b8b153332897f (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
<?php
/**
 * Manages player's account: debit and credit.
 *
 * @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;
}


?>