diff options
Diffstat (limited to 'js/craftmine.js')
-rw-r--r-- | js/craftmine.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/js/craftmine.js b/js/craftmine.js index 77cafee..fa70809 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -5,8 +5,11 @@ data = { miners: 0, level: 3, hp: 5, + maxHP: 5, xp: 0, - icon : "H" + power: 3, + bonusPower: 0, + icon : "💪" } function sendRequest(url, params, callback, isFile) { @@ -41,6 +44,16 @@ function debitAccount(amount) { updateData("gold"); } +function creditAccount(amount){ + data.gold += amount; + sendRequest("craftmine.php", "op=withdrawMine&amount="+amount, function(xhr) { + var gold = parseInt(xhr); + if(isNaN(gold)) return; + data.gold = gold; + updateData("gold"); + }); +} + function withdrawMine() { sendRequest("craftmine.php", "op=withdrawMine&amount="+data.mine, function(xhr) { var gold = parseInt(xhr); // Server's response is a string @@ -53,7 +66,7 @@ function withdrawMine() { function initCraftMine() { sendRequest("craftmine.php", "op=getCraftMine", function(ret) { - console.log(ret.perso); + //console.log(ret.perso); data.gold = parseInt(ret.gold); // Server's response is a string data.mine = 0; // Reset mine if(ret.perso) updatePerso(ret.perso); |