diff options
author | alexichi <alexbankai96@gmail.com> | 2016-04-25 13:37:08 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-04-25 13:37:08 +0200 |
commit | 29d23898c7ec5d3280e9a7f01a6209f8c8f2d5f8 (patch) | |
tree | cbfaaea85e3739abd0b4c59c1bef4e28ff69a84a /inc/guild.inc | |
parent | 1ffba62faae83e18597270b68580a90ac3032a31 (diff) | |
download | candybox-29d23898c7ec5d3280e9a7f01a6209f8c8f2d5f8.tar.gz candybox-29d23898c7ec5d3280e9a7f01a6209f8c8f2d5f8.tar.bz2 candybox-29d23898c7ec5d3280e9a7f01a6209f8c8f2d5f8.tar.xz candybox-29d23898c7ec5d3280e9a7f01a6209f8c8f2d5f8.zip |
Mise en commun du shop et de la guilde
Diffstat (limited to 'inc/guild.inc')
-rw-r--r-- | inc/guild.inc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/inc/guild.inc b/inc/guild.inc index 4ca0262..c0e8264 100644 --- a/inc/guild.inc +++ b/inc/guild.inc @@ -1,30 +1,31 @@ <?php +define("GUILD_COST",10); +define("MINER_COST",5); + function createGuild(){ - if($_SESSION["mine"]["gold"] >= 50 && !isset($_SESSION["guild"])){ - $_SESSION["guild"]= array("miners" => 1); - $_SESSION["mine"]["gold"] -= 50; - echo "Guild has been successfully created"; + if(!empty($_SESSION["guild"])) { + sendError("guild_already_built"); } - else{ - echo "g"; + elseif(debitAccount(GUILD_COST)) { + $_SESSION["guild"] = true; + echo json_encode(array("cost" => GUILD_COST)); } } function hireMiner(){ if(!isset($_SESSION["guild"])){ - echo "you need to create a guild first"; + sendError("guild_not_yet_created"); } - if($_SESSION["mine"]["gold"] >= 20 && isset($_SESSION["guild"])){ - $_SESSION["guild"]["miners"]++; - $_SESSION["mine"]["gold"] -= 20; - $_SESSION["mine"]["miners"] = $_SESSION["guild"]["miners"]; - $mine = $_SESSION["mine"]; - echo $mine["gold"] +","+ $mine["miners"]; + elseif(debitAccount(MINER_COST)){ + $_SESSION["mine"]["miners"]++; + echo json_encode(array("cost" => MINER_COST , "miners" => $_SESSION["mine"]["miners"])); } } -//function buy($obj,$prix){} +function sendMiners(){ + return $_SESSION["mine"]["miners"]; +} ?> |