diff options
author | alexichi <alexbankai96@gmail.com> | 2016-04-29 21:06:59 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-04-29 21:06:59 +0200 |
commit | 48ca3e8ee63787d567fd0fe1bcfea7158a6f9596 (patch) | |
tree | 2c2b5bdf4c2461444112c5a63b94f4dffcae84ff /js | |
parent | 3c297defe63a2af75cc7aafcfa5cf74dd1f2c20a (diff) | |
download | candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.tar.gz candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.tar.bz2 candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.tar.xz candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.zip |
add the option to not create 2 objects of the same type, doesn't work well
Diffstat (limited to 'js')
-rw-r--r-- | js/shop.js | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -28,14 +28,21 @@ function buildShop() { sendRequest("craftmine.php", "op=buildShop", function(ret) { displayShop(ret); debitAccount(ret.cost); + showInfo("Your shop has been successfully created"); }); } function addItem(ret) { - var itemhtml = "<li>"; - itemhtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"useItem('" + ret.name + "')\"><span class=\"item-icon\">" + ret.icon + "</span><br />" + ret.name + "</button>"; - itemhtml += "</li>"; - + var itemhtml = ""; + if(ret[1]==1){ //si c'est la première itération de l'objet + itemhtml += "<li>"; + itemhtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"useItem('" + ret[0].name + "')\"><span class=\"item-icon\">" + ret[0].icon + "</span><br />" + ret[0].name + "(<span id=\"nbObjet\">"+ret[1]+"</span>)</button>"; + itemhtml += "</li>"; + } + else if(ret[1]>1){ // si c'est une n-ième itération + document.getElementById("nbObjet").innerHTML=ret[1]; + } + var invcontent = document.getElementById("tab3"); if(invcontent.children.length <= 1) @@ -48,13 +55,13 @@ function addItem(ret) { } else invcontent.getElementsByTagName('ul')[0].innerHTML += itemhtml; - showInfo("The "+ ret.name + " has been successfully purchased"); + showInfo("The "+ ret[0].name + " has been successfully purchased"); } function buyItem(name) { sendRequest("craftmine.php", "op=buyItem&item="+name, function(ret) { addItem(ret); - debitAccount(ret.cost); + debitAccount(ret[0].cost); }); } |