aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-04-25 10:18:41 +0200
committeralexichi <alexbankai96@gmail.com>2016-04-25 10:18:41 +0200
commit8984aa2ecca7feacec93db35aee1570e40fa5123 (patch)
tree0b8595418d264cec9335c7e3f79143e9a91965fe /js
parentd013e0e873277dd1bf29f51a83bbd9e467cad23b (diff)
downloadcandybox-8984aa2ecca7feacec93db35aee1570e40fa5123.tar.gz
candybox-8984aa2ecca7feacec93db35aee1570e40fa5123.tar.bz2
candybox-8984aa2ecca7feacec93db35aee1570e40fa5123.tar.xz
candybox-8984aa2ecca7feacec93db35aee1570e40fa5123.zip
Add the guild
add buttons to hireMiner and purchase the guild on xhtml javascript send request to the server php -> update $_SESSION for miner
Diffstat (limited to 'js')
-rw-r--r--js/guild.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/js/guild.js b/js/guild.js
index 28f58b8..cb9e783 100644
--- a/js/guild.js
+++ b/js/guild.js
@@ -1,18 +1,26 @@
function hireMiner(){
- sendRequest("craftmine.php", "op=hireMiner", function() {
- //datas.gold -= parseInt(datas.mine);
+ sendRequest("craftmine.php", "op=hireMiner", function(xhr) {
+ //data.gold -= 40;
var ret = xhr.responseText;
- console.log(ret);
- //datas.gold = ret;
- //updateDatas("gold");
- //updateDatas("miners");
+ if(ret != "you need to create a guild first" && ret!=""){
+ console.log(ret);
+ var tmp = ret.split(",");
+ console.log(tmp);
+ data.gold = parseInt(tmp[0]);
+ data.miners = parseInt(tmp[1]);
+ updateData("gold","miners");
+ }
})
}
function createGuild(){
- sendRequest("craftmine.php", "op=createGuild", function() {
+ sendRequest("craftmine.php", "op=createGuild", function(xhr) {
var ret = xhr.responseText;
- console.log(ret);
+ if(ret != "g"){
+ document.getElementById("guild").innerHTML = ret;
+ data.gold -= 50;
+ updateData("gold");
+ }
})
}