diff options
author | piernov <piernov@piernov.org> | 2016-05-08 14:40:02 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-05-08 14:40:02 +0200 |
commit | 2ecc9a72e9e932f1bf0431f391814837d8694884 (patch) | |
tree | ae5b94939d04a37a7952d9e65578eccdb8988971 /js | |
parent | e46e058e34c030c4a5342e82dd24ac49104d56e9 (diff) | |
download | candybox-2ecc9a72e9e932f1bf0431f391814837d8694884.tar.gz candybox-2ecc9a72e9e932f1bf0431f391814837d8694884.tar.bz2 candybox-2ecc9a72e9e932f1bf0431f391814837d8694884.tar.xz candybox-2ecc9a72e9e932f1bf0431f391814837d8694884.zip |
Create updatePerso() JS function
Diffstat (limited to 'js')
-rw-r--r-- | js/craftmine.js | 7 | ||||
-rw-r--r-- | js/perso.js | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/js/craftmine.js b/js/craftmine.js index 347ce65..77cafee 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -56,12 +56,7 @@ function initCraftMine() { console.log(ret.perso); data.gold = parseInt(ret.gold); // Server's response is a string data.mine = 0; // Reset mine - if(ret.perso){ - data.hp = ret.perso.hp; - data.xp = ret.perso.xp; - data.level = ret.perso.lv; - displayPerso(ret.perso.hp,ret.perso.xp,ret.perso.lv); - } + if(ret.perso) updatePerso(ret.perso); if(ret.shop) displayShop(ret.shop); if(ret.inventory) displayInventory(ret.inventory); if(ret.dungeon == false){}//if we have left the donjon diff --git a/js/perso.js b/js/perso.js index 365cf54..02a8892 100644 --- a/js/perso.js +++ b/js/perso.js @@ -3,3 +3,10 @@ function displayPerso(hp,xp,lv){ document.getElementById("lv").innerHTML = lv; document.getElementById("xp").innerHTML = xp; } + +function updatePerso(perso) { + data.hp = perso.hp; + data.xp = perso.xp; + data.level = perso.lv; + displayPerso(perso.hp, perso.xp, perso.lv); +} |