aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-01 13:55:08 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-01 13:55:08 +0200
commit64b1663e55544e1ed0e072c4f624688625691c9f (patch)
tree2af1f1941361e89f17c1f32d60dfe6f2873f9bca /js
parent31866085151518f468794dc71b541543e6b2f691 (diff)
downloadcandybox-64b1663e55544e1ed0e072c4f624688625691c9f.tar.gz
candybox-64b1663e55544e1ed0e072c4f624688625691c9f.tar.bz2
candybox-64b1663e55544e1ed0e072c4f624688625691c9f.tar.xz
candybox-64b1663e55544e1ed0e072c4f624688625691c9f.zip
Add dungeon without fight system
You can buy a "ticket" to access the dungeon If you exit you have to buy another ticket Problem when we update the page, the default sentence is displayed while it said that you can access the dungeon
Diffstat (limited to 'js')
-rw-r--r--js/craftmine.js5
-rw-r--r--js/dungeon.js30
2 files changed, 31 insertions, 4 deletions
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");
+ });
}