From add9d3248a5adc02b071a301005c6f11195f7f7b Mon Sep 17 00:00:00 2001 From: alexichi Date: Tue, 3 May 2016 10:33:27 +0200 Subject: add dungeon client side to display it when reload --- inc/craftmine.inc | 4 +++- inc/dungeon.inc | 6 ++++++ js/craftmine.js | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) 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"); }) -- cgit v1.2.3-70-g09d2