aboutsummaryrefslogtreecommitdiffstats
path: root/inc/guild.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-04-25 22:36:33 +0200
committerpiernov <piernov@piernov.org>2016-04-25 22:36:33 +0200
commit54635d17eef27eb2546d69599e4107b242509ced (patch)
tree86d18cbb6e021b78ba1ce87307447d71d1802ad3 /inc/guild.inc
parentf98b06a25d71cc02bf29d7c525da0095688ea872 (diff)
parent8140617aeb2f32f7095a443ca743c6d6915739c6 (diff)
downloadcandybox-54635d17eef27eb2546d69599e4107b242509ced.tar.gz
candybox-54635d17eef27eb2546d69599e4107b242509ced.tar.bz2
candybox-54635d17eef27eb2546d69599e4107b242509ced.tar.xz
candybox-54635d17eef27eb2546d69599e4107b242509ced.zip
Merge branch 'alexichi' of ssh://piernov.org/srv/git/candybox into alexichi
Diffstat (limited to 'inc/guild.inc')
-rw-r--r--inc/guild.inc32
1 files changed, 17 insertions, 15 deletions
diff --git a/inc/guild.inc b/inc/guild.inc
index 5ede1f6..c0e8264 100644
--- a/inc/guild.inc
+++ b/inc/guild.inc
@@ -1,29 +1,31 @@
<?php
+define("GUILD_COST",10);
+define("MINER_COST",5);
+
function createGuild(){
- if($_SESSION["mine"]["gold"] >= 150){
- $_SESSION["guild"]= array("miners" => 1);
- $_SESSION["mine"]["gold"] -= 150;
- echo "Guild has been successfully created";
+ if(!empty($_SESSION["guild"])) {
+ sendError("guild_already_built");
}
- else{
- echo "Not enough money";
+ elseif(debitAccount(GUILD_COST)) {
+ $_SESSION["guild"] = true;
+ echo json_encode(array("cost" => GUILD_COST));
}
}
function hireMiner(){
if(!isset($_SESSION["guild"])){
- echo "<p>you need to create a guild first";
+ sendError("guild_not_yet_created");
}
- if($_SESSION["mine"]["gold"] >= 40){
- $_SESSION["guild"]["miners"]++;
- $_SESSION["mine"]["gold"] -= 40;
- $_SESSION["mine"]["miners"] = $_SESSION["guild"]["miners"];
- $mine = $_SESSION["mine"];
- $guild = $_SESSION["guild"];
- echo $mine["gold"];
- echo $mine["miners"];
+ elseif(debitAccount(MINER_COST)){
+ $_SESSION["mine"]["miners"]++;
+ echo json_encode(array("cost" => MINER_COST , "miners" => $_SESSION["mine"]["miners"]));
}
}
+function sendMiners(){
+ return $_SESSION["mine"]["miners"];
+}
+
+
?>