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; 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); }); }