From ee02581b7fabd087fc4056bda739c88656fbca14 Mon Sep 17 00:00:00 2001 From: alexichi Date: Sat, 7 May 2016 10:13:20 +0200 Subject: add the display of the perso characteristics below the title --- inc/perso.inc | 12 +++++++++--- js/craftmine.js | 2 +- js/dungeon.js | 18 +++++++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/inc/perso.inc b/inc/perso.inc index 075f8ae..4fb05ef 100644 --- a/inc/perso.inc +++ b/inc/perso.inc @@ -1,8 +1,8 @@ diff --git a/js/craftmine.js b/js/craftmine.js index c7a396f..a8619df 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -3,7 +3,7 @@ data = { gold: 0, mine: 0, miners: 0, - level: 4, + level: 3, hp: 5, xp: 0, icon : "H" 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 += "" @@ -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 = "

"; - tmphtml += ""; + tmphtml += ""; document.getElementById("tab4").innerHTML += tmphtml; } -function exitDungeon(){ +function exitDungeon(boss){ sendRequest("craftmine.php", "op=exitDungeon", function() { window.clearTimeout(timeout); - document.getElementById("tab4").innerHTML = "

Look at how poor you are! You can't access the dungeon, it is only for the elite.

"; + document.getElementById("tab4").innerHTML = "

Not available, you have to buy a ticket in the build section.

"; + if(boss) showInfo("You have beaten the final boss! CONGRATULATIONS!"); showInfo("You have left the dungeon"); }); } -- cgit v1.2.3-70-g09d2