aboutsummaryrefslogtreecommitdiffstats
path: root/js/dungeon.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/dungeon.js')
-rw-r--r--js/dungeon.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/js/dungeon.js b/js/dungeon.js
index 65d1081..30808ff 100644
--- a/js/dungeon.js
+++ b/js/dungeon.js
@@ -71,11 +71,11 @@ function strike(ret,nb, f){
function endBattle(v,nb, f, ret){
window.clearTimeout(timeout);
- if(v=="mob")exitDungeon();//if you die in the dungeon, you are immediately sent out of the dungeon
+ if(v=="mob")exitDungeon(false);//if you die in the dungeon, you are immediately sent out of the dungeon
//To level up you have to obtain 2 xp to go to lv 3, 3 to go to lv 4, etc
//A mob level 2 , if defeated gives you 2 xp, ...etc
else{
- data.xp += ret[nb].xp;
+ data.xp += parseInt(ret[nb].xp);
if(data.xp>=data.level){
data.xp-=data.level;
data.level++;
@@ -88,6 +88,10 @@ function endBattle(v,nb, f, ret){
if(nb>=3){//floor changing
nb=0;//reset the number of the mob
f++;//increment the number of the floor
+ if(f>=4){
+ exitDungeon(true);//true means that you have completed the dungeon and not just die or exit by yourself
+ return;
+ }
}
var tmphtml = "Le " + v + " a gagné.";
tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"launchDungeon("+nb+","+ f +",false)\">Next Battle</button>"
@@ -95,18 +99,22 @@ function endBattle(v,nb, f, ret){
displayExit();
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);
+ });
}
function displayExit(){
var tmphtml = "<br/><br/>";
- tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"exitDungeon()\">Exit</button>";
+ tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"exitDungeon(false)\">Exit</button>";
document.getElementById("tab4").innerHTML += tmphtml;
}
-function exitDungeon(){
+function exitDungeon(boss){
sendRequest("craftmine.php", "op=exitDungeon", function() {
window.clearTimeout(timeout);
- document.getElementById("tab4").innerHTML = "<h4>Look at how poor you are! You can't access the dungeon, it is only for the elite.</h4>";
+ document.getElementById("tab4").innerHTML = "<h4>Not available, you have to buy a ticket in the build section.</h4>";
+ if(boss) showInfo("You have beaten the final boss! CONGRATULATIONS!");
showInfo("You have left the dungeon");
});
}