From 2f32bc3153b7f2c2561e4603f912573921e6449f Mon Sep 17 00:00:00 2001 From: alexichi Date: Mon, 9 May 2016 20:26:51 +0200 Subject: add the use of the objects and the feature power and maxHP --- js/craftmine.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'js/craftmine.js') 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); -- cgit v1.2.3-54-g00ecf