From 31866085151518f468794dc71b541543e6b2f691 Mon Sep 17 00:00:00 2001 From: alexichi Date: Sun, 1 May 2016 11:32:08 +0200 Subject: add the beginning part of the dungeon When you have enough money you can buy a ticket and access the dungeon I made a file monsters.xml . It's a bit like the code with the shop but modified When you press the button launch in the onglet dungeon , it display "Battle!" in the console --- inc/dungeon.inc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 inc/dungeon.inc (limited to 'inc/dungeon.inc') diff --git a/inc/dungeon.inc b/inc/dungeon.inc new file mode 100644 index 0000000..b2277f0 --- /dev/null +++ b/inc/dungeon.inc @@ -0,0 +1,39 @@ +(string)$monsters["cost"],"monsters"=>array()); + foreach($monsters as $f){ + $floor = (string)$f["name"]; + $dungeon["monsters"][$floor] = array(); + foreach($f as $monster){ + $dungeon["monsters"][$floor][] = new Monster((string)$monster->name, + intval($monster->level), + intval($monster->hp), + (string)$monster->icon); + } + } + return $dungeon; +} + +function initDungeon() { + $_SESSION["dungeon"] = true; +} + +function buildDungeon() { + $dungeon=generateMonster(); + if(!empty($_SESSION["dungeon"])) { + sendError("dungeon_already_available"); + } + elseif(debitAccount($dungeon["cost"])) { + initDungeon(); + $_SESSION["mine"]["gold"] -= $dungeon["cost"]; + echo json_encode($dungeon); + } +} + +?> -- cgit v1.2.3-70-g09d2