aboutsummaryrefslogtreecommitdiffstats
path: root/inc/guild.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-10 22:21:31 +0200
committerpiernov <piernov@piernov.org>2016-05-10 22:21:31 +0200
commit58b1893e6c820ce8810c33f09bfcc16c3e59f4eb (patch)
tree8e893d4981f3d869cbe79b985570d66cf3c42175 /inc/guild.inc
parent204e838a7794bbce0d44fc35efb367abb052d02f (diff)
downloadcandybox-58b1893e6c820ce8810c33f09bfcc16c3e59f4eb.tar.gz
candybox-58b1893e6c820ce8810c33f09bfcc16c3e59f4eb.tar.bz2
candybox-58b1893e6c820ce8810c33f09bfcc16c3e59f4eb.tar.xz
candybox-58b1893e6c820ce8810c33f09bfcc16c3e59f4eb.zip
Various fixes
Diffstat (limited to 'inc/guild.inc')
-rw-r--r--inc/guild.inc9
1 files changed, 9 insertions, 0 deletions
diff --git a/inc/guild.inc b/inc/guild.inc
index c0e8264..1666b15 100644
--- a/inc/guild.inc
+++ b/inc/guild.inc
@@ -3,6 +3,13 @@
define("GUILD_COST",10);
define("MINER_COST",5);
+function initMinersIfNeeded() {
+ if(empty($_SESSION["mine"]))
+ $_SESSION["mine"] = array("miners" => 0);
+ else if(!array_key_exists("miners", $_SESSION["mine"]))
+ $_SESSION["mine"]["miners"] = 0;
+}
+
function createGuild(){
if(!empty($_SESSION["guild"])) {
sendError("guild_already_built");
@@ -18,12 +25,14 @@ function hireMiner(){
sendError("guild_not_yet_created");
}
elseif(debitAccount(MINER_COST)){
+ initMinersIfNeeded();
$_SESSION["mine"]["miners"]++;
echo json_encode(array("cost" => MINER_COST , "miners" => $_SESSION["mine"]["miners"]));
}
}
function sendMiners(){
+ initMinersIfNeeded();
return $_SESSION["mine"]["miners"];
}