aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--craftmine.php2
-rw-r--r--data/items.xml4
-rw-r--r--inc/dungeon.inc11
-rw-r--r--js/craftmine.js5
-rw-r--r--js/dungeon.js30
5 files changed, 46 insertions, 6 deletions
diff --git a/craftmine.php b/craftmine.php
index 4cd6b00..72817cc 100644
--- a/craftmine.php
+++ b/craftmine.php
@@ -43,6 +43,8 @@ switch($op) {
case "buildShop": buildShop(); break;
case "buyItem": buyItem(); break;
case "buildDungeon" : buildDungeon(); break;
+ case "launchDungeon" : launchDungeon(); break;
+ case "exitDungeon" : exitDungeon(); break;
default: reportBadRequest();
}
diff --git a/data/items.xml b/data/items.xml
index 6c19b84..8888796 100644
--- a/data/items.xml
+++ b/data/items.xml
@@ -25,7 +25,7 @@
<name>Life Bottle</name>
<cost>5</cost>
<features></features>
- <icon>🍶</icon>
+ <icon>💧</icon>
<description>A bottle which can heal you by regaining hp</description>
</item>
<item>
@@ -34,7 +34,7 @@
<features>
<power>20</power>
</features>
- <icon>🍶</icon>
+ <icon>💧</icon>
<description>If used, you have 20% more chance to hit your enemy during the battle</description>
</item>
</category>
diff --git a/inc/dungeon.inc b/inc/dungeon.inc
index b2277f0..8c26c92 100644
--- a/inc/dungeon.inc
+++ b/inc/dungeon.inc
@@ -36,4 +36,15 @@ function buildDungeon() {
}
}
+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.
+}
+
?>
diff --git a/js/craftmine.js b/js/craftmine.js
index 92fa45a..c40106c 100644
--- a/js/craftmine.js
+++ b/js/craftmine.js
@@ -1,8 +1,11 @@
data = {
+ name: "You",
gold: 0,
mine: 0,
miners: 0,
- level: 1
+ level: 1,
+ hp: 1,
+ icon : "H"
}
function sendRequest(url, params, callback) {
diff --git a/js/dungeon.js b/js/dungeon.js
index 1760afa..d20a3cf 100644
--- a/js/dungeon.js
+++ b/js/dungeon.js
@@ -8,11 +8,35 @@ function buildDungeon(){
function displayDungeon(){
var tmphtml = "<br/>";
- tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"launchDungeon()\">Launch</button>";
- //tmphtml += "</li>";
+ tmphtml += "<button id=\"launch\" type=\"button\" class=\"btn btn-primary\" onclick=\"launchDungeon()\">Launch</button>";
document.getElementById("tab4").innerHTML = tmphtml;
}
function launchDungeon(){
- console.log("Battle!");
+ sendRequest("craftmine.php", "op=launchDungeon", function(ret) {
+ document.getElementById("launch").style.display = "none";
+ displayBattle(ret);
+ });
+}
+
+function displayBattle(ret){
+ var tmphtml = "<div class=\"row\">";
+ tmphtml += "<h4>Battle</h4>";
+ tmphtml += "<ul class=\"list-inline\">";
+ tmphtml += "<li>";
+ tmphtml += "<button type=\"button\" class=\"btn btn-primary\" style=\"margin-left:30px;\"><span class=\"item-icon\">" + data.icon + "</span><br />" + data.name + "<br/> lv: " + data.level + " <span id=\"lifeMob\">hp: " + data.hp + "</span></button>";
+ tmphtml += "<button type=\"button\" class=\"btn btn-primary\" style=\"margin-left:30px;\"><span class=\"item-icon\">" + ret[0].icon + "</span><br />" + ret[0].name + "<br/> lv: " + ret[0].level + " <span id=\"lifeMob\">hp: " + ret[0].hp + "</span></button>";
+ tmphtml += "</li>";
+ tmphtml += "</ul>";
+ tmphtml += "</div>";
+ tmphtml += "<br/><br/>";
+ tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"exitDungeon()\">Exit</button>";
+ document.getElementById("tab4").innerHTML = tmphtml;
+}
+
+function exitDungeon(){
+ sendRequest("craftmine.php", "op=exitDungeon", function() {
+ document.getElementById("tab4").innerHTML = "<h4>Look at how poor you are! You can't access the dungeon, it is only for the elite.</h4>";
+ showInfo("You have left the dungeon");
+ });
}