diff options
author | piernov <piernov@piernov.org> | 2016-05-10 21:37:27 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-05-10 21:37:27 +0200 |
commit | 204e838a7794bbce0d44fc35efb367abb052d02f (patch) | |
tree | 3426fdb07b631690d28619c570139244803e5763 | |
parent | f10c51f07a755d75a583f85316efbcd3bd1e4b6d (diff) | |
parent | 162b1de442bae3f02f14771eeb5f4f32868a97b3 (diff) | |
download | candybox-204e838a7794bbce0d44fc35efb367abb052d02f.tar.gz candybox-204e838a7794bbce0d44fc35efb367abb052d02f.tar.bz2 candybox-204e838a7794bbce0d44fc35efb367abb052d02f.tar.xz candybox-204e838a7794bbce0d44fc35efb367abb052d02f.zip |
Merge branch 'alexichi' of /srv/git/candybox into alexichi
-rw-r--r-- | inc/dungeon.inc | 3 | ||||
-rw-r--r-- | inc/perso.inc | 45 | ||||
-rw-r--r-- | js/dungeon.js | 8 | ||||
-rw-r--r-- | js/perso.js | 3 |
4 files changed, 50 insertions, 9 deletions
diff --git a/inc/dungeon.inc b/inc/dungeon.inc index 521303e..d6b80fc 100644 --- a/inc/dungeon.inc +++ b/inc/dungeon.inc @@ -2,7 +2,7 @@ require_once("messages.inc"); require_once("account.inc"); require_once("Monster.inc"); - +require_once("perso.inc"); function generateMonster(){ $monsters = simplexml_load_file('data/monsters.xml'); @@ -56,6 +56,7 @@ function sendDungeonProgress(){ $nb=$_POST["mob"]; $_SESSION["dungeon"]["flat"] = $f; $_SESSION["dungeon"]["mob"] = $nb; + reusable(); } diff --git a/inc/perso.inc b/inc/perso.inc index 0a32b64..2a514bb 100644 --- a/inc/perso.inc +++ b/inc/perso.inc @@ -24,15 +24,48 @@ function increasePerso($prop, $num) { */ function limitUse($item){ $n = $item->name; - if($n =="Life Bottle")return true; - if(empty($_SESSION[$n])){ - $_SESSION[$n]=1; + if(empty($item->feat["limit"])) return true; + if(empty($_SESSION["usedItem"])){ + initUsedItem(); + $_SESSION["usedItem"][$n]["nbUse"]=1; return true; } else{ - $_SESSION[$n]++; - if($_SESSION[$n] >= $item->feat["limit"])return false; - else return true; + if($_SESSION["usedItem"][$n]["nbUse"] >= $item->feat["limit"])return false; + else{ + $_SESSION["usedItem"][$n]["nbUse"]++; + return true; + } + } +} + +function initUsedItem(){ + $_SESSION["usedItem"]["Strength Bottle"]["longevity"] = 0;//if longevity equals 2, it means that the item was used during 2 battles + $_SESSION["usedItem"]["Wooden Sword"]["longevity"] = 0; + $_SESSION["usedItem"]["Metal Sword"]["longevity"] = 0; + $_SESSION["usedItem"]["Strength Bottle"]["nbUse"] = 0; + $_SESSION["usedItem"]["Wooden Sword"]["nbUse"] = 0; + $_SESSION["usedItem"]["Metal Sword"]["nbUse"] = 0; +} + +function reusable(){ + if(empty($_SESSION["usedItem"])){ + initUsedItem(); + } + $_SESSION["usedItem"]["Strength Bottle"]["nbUse"]=0; + if($_SESSION["usedItem"]["Wooden Sword"]["nbUse"]>=1){ + $_SESSION["usedItem"]["Wooden Sword"]["longevity"]++; + if($_SESSION["usedItem"]["Wooden Sword"]["longevity"]>=2){ + $_SESSION["perso"]["powerBonus"] -= 1; + $_SESSION["usedItem"]["Wooden Sword"]["nbUse"]=0; + } + } + else if($_SESSION["usedItem"]["Metal Sword"]["nbUse"]>=1){ + $_SESSION["usedItem"]["Metal Sword"]["longevity"]++; + if($_SESSION["usedItem"]["Metal Sword"]["longevity"]>=2){ + $_SESSION["perso"]["powerBonus"] -= 3; + $_SESSION["usedItem"]["Metal Sword"]["nbUse"]=0; + } } } diff --git a/js/dungeon.js b/js/dungeon.js index 2921c7d..7d97b49 100644 --- a/js/dungeon.js +++ b/js/dungeon.js @@ -69,6 +69,11 @@ function strike(ret,nb, f){ persoLife--; document.getElementById("lifePerso").innerHTML = parseInt(persoLife); } + data.hp=persoLife; + sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&maxHP="+data.maxHP+"&xp="+data.xp+"&lv="+data.level+"&power="+data.power + +"&bonusPower="+data.bonusPower, function(){ + displayPerso(data.hp,data.maxHP,data.xp,data.level,data.power,data.bonusPower); + }); battle(ret,nb,f); } @@ -94,7 +99,8 @@ function endBattle(v,nb, f, ret){ displayExit(); sendRequest("craftmine.php", "op=sendDungeonProgress&floor="+f+"&mob="+nb); } - sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&maxHP="+data.maxHP+"&xp="+data.xp+"&lv="+data.level+"&power="+data.power+"&bonusPower="+data.bonusPower, function(){ + sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&maxHP="+data.maxHP+"&xp="+data.xp+"&lv="+data.level+"&power="+data.power + +"&bonusPower="+data.bonusPower, function(){ displayPerso(data.hp,data.maxHP,data.xp,data.level,data.power,data.bonusPower); }); } diff --git a/js/perso.js b/js/perso.js index 44b82eb..7977a9d 100644 --- a/js/perso.js +++ b/js/perso.js @@ -26,7 +26,8 @@ function levelUp(xp){ data.maxHP+=2; } //need to send the xp to the server - sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&maxHP="+data.maxHP+"&xp="+data.xp+"&lv="+data.level+"&power="+data.power+"&bonusPower="+bonusPower, function(){ + sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&maxHP="+data.maxHP+"&xp="+data.xp+"&lv="+data.level + +"&power="+data.power+"&bonusPower="+bonusPower, function(){ displayPerso(data.hp,data.maxHP,data.maxHP,data.xp,data.level,data.power,data.bonusPower); }); } |