blob: 8c26c9268a4eb75873355bfba721c3a46b241a90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
require_once("messages.inc");
require_once("account.inc");
require_once("Monster.inc");
function generateMonster(){
$monsters = simplexml_load_file('data/monsters.xml');
$dungeon = array("cost"=>(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);
}
}
function launchDungeon(){
$dungeon=generateMonster();
$opponent = $dungeon["monsters"]["floor1"];
echo json_encode($opponent);
}
function exitDungeon(){
$_SESSION["dungeon"] = false;
echo json_encode(array("a" => 7));//Cette ligne ne sert qu'à contourner l'erreur créé à cause de sendRequest. A revoir.
}
?>
|