aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/items.xml3
-rw-r--r--inc/perso.inc26
2 files changed, 19 insertions, 10 deletions
diff --git a/data/items.xml b/data/items.xml
index 4448b1c..e122826 100644
--- a/data/items.xml
+++ b/data/items.xml
@@ -7,6 +7,7 @@
<features>
<power>+1</power>
<limit>1</limit>
+ <longevity>2</longevity>
</features>
<icon>⚔</icon>
<description>A sword that beginners need to use to improve their skills</description>
@@ -17,6 +18,7 @@
<features>
<power>+3</power>
<limit>1</limit>
+ <longevity>2</longevity>
</features>
<icon>⚔</icon>
<description>A sword which are often use buy skilled knight. The material is very good and the sword is very powerful</description>
@@ -38,6 +40,7 @@
<features>
<power>+2</power>
<limit>3</limit>
+ <longevity>1</longevity>
</features>
<icon>🍶</icon>
<description>If used, you have 20% more chance to hit your enemy during the battle</description>
diff --git a/inc/perso.inc b/inc/perso.inc
index e38fb4c..aaf7b1b 100644
--- a/inc/perso.inc
+++ b/inc/perso.inc
@@ -43,8 +43,9 @@ function increasePerso($prop, $num) {
function limitUse($item){
$n = $item->name;
if(empty($item->feat["limit"])) return true;
- if(empty($_SESSION["usedItem"])){
+ else if(empty($_SESSION["usedItem"])){
initUsedItem();
+ $_SESSION["usedItem"][$n] = array();
$_SESSION["usedItem"][$n]["nbUse"]=1;
return true;
}
@@ -57,13 +58,17 @@ function limitUse($item){
}
}
-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 initUsedItem(){
+ $_SESSION["usedItem"]=array();
+}
+
+function resetUsedItem($item){
+ $it = $_SESSION["usedItem"][$item];
+ foreach($it as $k => $v){
+ foreach($v as $val){
+ $val = 0;
+ }
+ }
}
function reusable(){
@@ -74,17 +79,18 @@ function reusable(){
if($_SESSION["usedItem"]["Wooden Sword"]["nbUse"]>=1){
$_SESSION["usedItem"]["Wooden Sword"]["longevity"]++;
if($_SESSION["usedItem"]["Wooden Sword"]["longevity"]>=2){
- $_SESSION["perso"]["powerBonus"] -= 1;
+ $_SESSION["perso"]["bonusPower"] -= 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["perso"]["bonusPower"] -= 3;
$_SESSION["usedItem"]["Metal Sword"]["nbUse"]=0;
}
}
+ //echo json_encode($_SESSION["usedItem"]);
}
/**