aboutsummaryrefslogtreecommitdiffstats
path: root/js/craftmine.js
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-09 20:26:51 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-09 20:26:51 +0200
commit2f32bc3153b7f2c2561e4603f912573921e6449f (patch)
tree87419a11e12f5b7433459fcb5cb9da5211dcbd9e /js/craftmine.js
parentf1677164c3f46785f6d9380b68cdeba58a680404 (diff)
downloadcandybox-2f32bc3153b7f2c2561e4603f912573921e6449f.tar.gz
candybox-2f32bc3153b7f2c2561e4603f912573921e6449f.tar.bz2
candybox-2f32bc3153b7f2c2561e4603f912573921e6449f.tar.xz
candybox-2f32bc3153b7f2c2561e4603f912573921e6449f.zip
add the use of the objects and the feature power and maxHP
Diffstat (limited to 'js/craftmine.js')
-rw-r--r--js/craftmine.js17
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);