diff options
author | alexichi <alexbankai96@gmail.com> | 2016-05-07 12:08:36 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-05-07 12:08:36 +0200 |
commit | 79cfbb29042fd60dfbc76a6810f75cce21d3ffe0 (patch) | |
tree | ed1425c2bf94fd7e2b068bfe64134e0689f83285 /js | |
parent | ee02581b7fabd087fc4056bda739c88656fbca14 (diff) | |
download | candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.tar.gz candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.tar.bz2 candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.tar.xz candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.zip |
add the use of the life bottle
Diffstat (limited to 'js')
-rw-r--r-- | js/craftmine.js | 2 | ||||
-rw-r--r-- | js/dungeon.js | 3 | ||||
-rw-r--r-- | js/shop.js | 18 |
3 files changed, 20 insertions, 3 deletions
diff --git a/js/craftmine.js b/js/craftmine.js index a8619df..70becec 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -63,7 +63,7 @@ function initCraftMine() { displayPerso(ret.perso.hp,ret.perso.xp,ret.perso.lv); } if(ret.shop) displayShop(ret.shop); - displayInventory(ret.inventory); + if(ret.inventory) displayInventory(ret.inventory); if(ret.dungeon == false){}//if we have left the donjon else if(typeof ret.dungeon.mob == "undefined") displayDungeon(0,1,true); //if we have reload just after buying the ticket else displayDungeon(ret.dungeon.mob,ret.dungeon.flat,true);//if we have reload in the middle of the dungeon diff --git a/js/dungeon.js b/js/dungeon.js index 30808ff..982dcf6 100644 --- a/js/dungeon.js +++ b/js/dungeon.js @@ -55,6 +55,7 @@ function strike(ret,nb, f){ return; } else if(persoLife == 0){ + data.hp = 1; endBattle("mob",nb,f,ret); return; } @@ -100,7 +101,7 @@ function endBattle(v,nb, f, ret){ sendRequest("craftmine.php", "op=sendDungeonProgress&floor="+f+"&mob="+nb); } sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&xp="+data.xp+"&lv="+data.level, function(){ - displayPerso(data.hp,data.xp,data.level); + displayPerso(data.hp,parseInt(data.xp),data.level); }); } @@ -37,7 +37,7 @@ function addItem(ret) { var itemtag = document.querySelector("[data-name=\""+ret[0].name+"\"]"); if(!itemtag){ //si c'est la première itération de l'objet itemhtml += "<li>"; - itemhtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"useItem('" + ret[0].name + "')\"><span class=\"item-icon\">" + ret[0].icon + "</span><br />" + ret[0].name + "(<span data-name=\""+ ret[0].name + "\">"+ret[1]+"</span>)</button>"; + itemhtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"useItem('" + ret[0].name + "')\"><span class=\"item-icon\">" + ret[0].icon + "</span><br />" + ret[0].name + "(<span id=\"nbItem\" data-name=\""+ ret[0].name + "\">"+ret[1]+"</span>)</button>"; itemhtml += "</li>"; } else{ // si c'est une n-ième itération @@ -68,6 +68,22 @@ function buyItem(name) { function useItem(name) { sendRequest("craftmine.php", "op=useItem&item="+name, function(ret) { + if(parseInt(ret[1])>=0){ + var nb = parseInt(document.getElementById("nbItem").innerHTML); + if(nb>0){ + nb--; + switch(ret[0].name){ + case "Life Bottle": data.hp = parseInt(data.hp) + 3; break; + case "Strength Bottle" : break; // to do + case "Wooden Sword" : break; //to do + case "Metal Sword" : break; //to do + } + } + document.getElementById("nbItem").innerHTML = nb; + sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&xp="+data.xp+"&lv="+data.level, function(){ + displayPerso(data.hp,data.xp,data.level); + }); + } }); } |