diff options
author | alexichi <alexbankai96@gmail.com> | 2016-05-05 23:06:29 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-05-05 23:09:21 +0200 |
commit | f171811a44364f605712aff1ca0808bfe570ef6e (patch) | |
tree | a970a69853e19ef43d97c2f48d61a6fb34637ff6 /js/dungeon.js | |
parent | 1efc4a15c8ab913bf8bdb1aef9f3b5720b3b7762 (diff) | |
download | candybox-f171811a44364f605712aff1ca0808bfe570ef6e.tar.gz candybox-f171811a44364f605712aff1ca0808bfe570ef6e.tar.bz2 candybox-f171811a44364f605712aff1ca0808bfe570ef6e.tar.xz candybox-f171811a44364f605712aff1ca0808bfe570ef6e.zip |
add xp system and perso server side
Diffstat (limited to 'js/dungeon.js')
-rw-r--r-- | js/dungeon.js | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/js/dungeon.js b/js/dungeon.js index c6ce014..65d1081 100644 --- a/js/dungeon.js +++ b/js/dungeon.js @@ -50,11 +50,12 @@ function strike(ret,nb, f){ var mobLife = document.getElementById("lifeMob").innerHTML; var persoLife = document.getElementById("lifePerso").innerHTML; if(mobLife == 0){ - endBattle("perso",nb,f); + data.hp = persoLife; + endBattle("perso",nb,f,ret); return; } else if(persoLife == 0){ - endBattle("mob",nb); + endBattle("mob",nb,f,ret); return; } if(hitRate<50+10*lvDiff){ @@ -68,19 +69,32 @@ function strike(ret,nb, f){ battle(ret,nb,f); } -function endBattle(v,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 - nb++;//go to the next mob in the same floor - if(nb>=3){//floor changing - nb=0;//reset the number of the mob - f++;//increment the number of the floor + //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; + if(data.xp>=data.level){ + data.xp-=data.level; + data.level++; + //need to send the xp to the server + sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&xp="+data.xp+"&lv="+data.level, function(){ + displayPerso(data.hp,data.xp,data.level); + }); + } + nb++;//go to the next mob in the same floor + if(nb>=3){//floor changing + nb=0;//reset the number of the mob + f++;//increment the number of the floor + } + var tmphtml = "Le " + v + " a gagné."; + tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"launchDungeon("+nb+","+ f +",false)\">Next Battle</button>" + document.getElementById("tab4").innerHTML = tmphtml; + displayExit(); + sendRequest("craftmine.php", "op=sendDungeonProgress&floor="+f+"&mob="+nb); } - var tmphtml = "Le " + v + " a gagné."; - tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"launchDungeon("+nb+","+ f +",false)\">Next Battle</button>" - document.getElementById("tab4").innerHTML = tmphtml; - displayExit(); - sendRequest("craftmine.php", "op=sendDungeonProgress&floor="+f+"&mob="+nb); } function displayExit(){ |