aboutsummaryrefslogtreecommitdiffstats
path: root/inc/perso.inc
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-10 18:34:22 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-10 18:34:22 +0200
commit162b1de442bae3f02f14771eeb5f4f32868a97b3 (patch)
tree3426fdb07b631690d28619c570139244803e5763 /inc/perso.inc
parent2f32bc3153b7f2c2561e4603f912573921e6449f (diff)
downloadcandybox-162b1de442bae3f02f14771eeb5f4f32868a97b3.tar.gz
candybox-162b1de442bae3f02f14771eeb5f4f32868a97b3.tar.bz2
candybox-162b1de442bae3f02f14771eeb5f4f32868a97b3.tar.xz
candybox-162b1de442bae3f02f14771eeb5f4f32868a97b3.zip
continue the use of objects problem
Diffstat (limited to 'inc/perso.inc')
-rw-r--r--inc/perso.inc45
1 files changed, 39 insertions, 6 deletions
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;
+ }
}
}