diff options
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); +} |