aboutsummaryrefslogtreecommitdiffstats
path: root/inc/account.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-04-24 22:08:10 +0200
committerpiernov <piernov@piernov.org>2016-04-24 22:08:10 +0200
commitc8688e50d613b540913de570f3b64fd5ffcec161 (patch)
treeb5b73915d0b7c2bad7edf444fd9932ffa7233561 /inc/account.inc
parent38a80dc6468c7e7cfaa4e22d4e4b8e3b374cf388 (diff)
downloadcandybox-c8688e50d613b540913de570f3b64fd5ffcec161.tar.gz
candybox-c8688e50d613b540913de570f3b64fd5ffcec161.tar.bz2
candybox-c8688e50d613b540913de570f3b64fd5ffcec161.tar.xz
candybox-c8688e50d613b540913de570f3b64fd5ffcec161.zip
Add debit/creditAccount() PHP account management helpers
Diffstat (limited to 'inc/account.inc')
-rw-r--r--inc/account.inc18
1 files changed, 18 insertions, 0 deletions
diff --git a/inc/account.inc b/inc/account.inc
new file mode 100644
index 0000000..19f311d
--- /dev/null
+++ b/inc/account.inc
@@ -0,0 +1,18 @@
+<?php
+require_once("messages.inc");
+
+function debitAccount($amount) {
+ if($_SESSION["mine"]["gold"] <= $amount) {
+ sendError("gold_insufficient");
+ return false;
+ }
+ $_SESSION["mine"]["gold"] -= $amount;
+ return true;
+}
+
+function creditAccount($amount) {
+ $_SESSION["mine"]["gold"] += $amount;
+}
+
+
+?>