aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-03 10:33:27 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-03 10:33:27 +0200
commitadd9d3248a5adc02b071a301005c6f11195f7f7b (patch)
treedb841c7347bcda24335718fa4f4d33397e0ade8c
parent556adda68fe99e3a88f59803aa9bd8892e4d34cf (diff)
downloadcandybox-add9d3248a5adc02b071a301005c6f11195f7f7b.tar.gz
candybox-add9d3248a5adc02b071a301005c6f11195f7f7b.tar.bz2
candybox-add9d3248a5adc02b071a301005c6f11195f7f7b.tar.xz
candybox-add9d3248a5adc02b071a301005c6f11195f7f7b.zip
add dungeon client side to display it when reload
-rw-r--r--inc/craftmine.inc4
-rw-r--r--inc/dungeon.inc6
-rw-r--r--js/craftmine.js1
3 files changed, 10 insertions, 1 deletions
diff --git a/inc/craftmine.inc b/inc/craftmine.inc
index 33a28d7..0d6a445 100644
--- a/inc/craftmine.inc
+++ b/inc/craftmine.inc
@@ -2,12 +2,14 @@
require_once("mine.inc");
require_once("shop.inc");
+require_once("dungeon.inc");
function sendCraftMine() {
$data = array("gold" => sendMine(),
"shop" => sendShop(),
"inventory" => Inventory::sendContent(),
- "miners" => sendMiners()
+ "miners" => sendMiners(),
+ "dungeon" => sendDungeon(),
);
echo json_encode($data);
}
diff --git a/inc/dungeon.inc b/inc/dungeon.inc
index 8c26c92..81e2ba7 100644
--- a/inc/dungeon.inc
+++ b/inc/dungeon.inc
@@ -24,6 +24,12 @@ function initDungeon() {
$_SESSION["dungeon"] = true;
}
+function sendDungeon() {
+ if(!empty($_SESSION["dungeon"]))
+ return generateMonster();
+ else return false;
+}
+
function buildDungeon() {
$dungeon=generateMonster();
if(!empty($_SESSION["dungeon"])) {
diff --git a/js/craftmine.js b/js/craftmine.js
index c40106c..7c37e59 100644
--- a/js/craftmine.js
+++ b/js/craftmine.js
@@ -52,6 +52,7 @@ function initCraftMine() {
data.gold = parseInt(ret.gold); // Server's response is a string
if(ret.shop) displayShop(ret.shop);
displayInventory(ret.inventory);
+ if(ret.dungeon) displayDungeon();
data.miners = parseInt(ret.miners);
updateData("gold","miners");
})