diff options
author | piernov <piernov@piernov.org> | 2016-05-10 22:31:09 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-05-10 22:31:09 +0200 |
commit | 931eb5f31a12f6415ff4cf447528f4df504aa3a3 (patch) | |
tree | c21a2a41e2bb72812e2ba14d6ba4530a9ce6976c /inc/guild.inc | |
parent | 9ad61ab6a23bd6fd51e67b85d743b4a7664ec637 (diff) | |
parent | 58b1893e6c820ce8810c33f09bfcc16c3e59f4eb (diff) | |
download | candybox-931eb5f31a12f6415ff4cf447528f4df504aa3a3.tar.gz candybox-931eb5f31a12f6415ff4cf447528f4df504aa3a3.tar.bz2 candybox-931eb5f31a12f6415ff4cf447528f4df504aa3a3.tar.xz candybox-931eb5f31a12f6415ff4cf447528f4df504aa3a3.zip |
Merge branch 'alexichi' into piernov
Diffstat (limited to 'inc/guild.inc')
-rw-r--r-- | inc/guild.inc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/inc/guild.inc b/inc/guild.inc index f4c10af..537b87a 100644 --- a/inc/guild.inc +++ b/inc/guild.inc @@ -16,6 +16,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; +} + /** * Create the miners guild in the session. * Debits GUILD_COST from the player's gold. @@ -43,6 +50,7 @@ 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"])); } @@ -54,6 +62,7 @@ function hireMiner(){ * @return int number of miners in the guild */ function sendMiners(){ + initMinersIfNeeded(); return $_SESSION["mine"]["miners"]; } |