diff options
Diffstat (limited to 'js/perso.js')
-rw-r--r-- | js/perso.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/js/perso.js b/js/perso.js index 02a8892..44b82eb 100644 --- a/js/perso.js +++ b/js/perso.js @@ -1,12 +1,32 @@ -function displayPerso(hp,xp,lv){ +function displayPerso(hp,maxHP,xp,lv,power,bonusPower){ document.getElementById("hp").innerHTML = hp; + document.getElementById("maxHP").innerHTML = maxHP; document.getElementById("lv").innerHTML = lv; document.getElementById("xp").innerHTML = xp; + document.getElementById("power").innerHTML = power; + document.getElementById("bonusPower").innerHTML = bonusPower; } function updatePerso(perso) { data.hp = perso.hp; + data.maxHP = perso.maxHP; data.xp = perso.xp; data.level = perso.lv; - displayPerso(perso.hp, perso.xp, perso.lv); + data.power = perso.power; + data.bonusPower = perso.bonusPower; + displayPerso(perso.hp, perso.maxHP, perso.xp, perso.lv, perso.power, perso.bonusPower); +} + +function levelUp(xp){ + data.xp += parseInt(xp); + while(data.xp>=data.level){ + data.xp-=data.level; + data.level++; + data.power++; + data.maxHP+=2; + } + //need to send the xp to the server + sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&maxHP="+data.maxHP+"&xp="+data.xp+"&lv="+data.level+"&power="+data.power+"&bonusPower="+bonusPower, function(){ + displayPerso(data.hp,data.maxHP,data.maxHP,data.xp,data.level,data.power,data.bonusPower); + }); } |