aboutsummaryrefslogtreecommitdiffstats
path: root/inc/perso.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-09 22:06:30 +0200
committerpiernov <piernov@piernov.org>2016-05-09 22:06:30 +0200
commitf10c51f07a755d75a583f85316efbcd3bd1e4b6d (patch)
tree87419a11e12f5b7433459fcb5cb9da5211dcbd9e /inc/perso.inc
parent54635d17eef27eb2546d69599e4107b242509ced (diff)
parent2f32bc3153b7f2c2561e4603f912573921e6449f (diff)
downloadcandybox-f10c51f07a755d75a583f85316efbcd3bd1e4b6d.tar.gz
candybox-f10c51f07a755d75a583f85316efbcd3bd1e4b6d.tar.bz2
candybox-f10c51f07a755d75a583f85316efbcd3bd1e4b6d.tar.xz
candybox-f10c51f07a755d75a583f85316efbcd3bd1e4b6d.zip
Merge branch 'alexichi' of ssh://piernov.org/srv/git/candybox into alexichi
Diffstat (limited to 'inc/perso.inc')
-rw-r--r--inc/perso.inc63
1 files changed, 63 insertions, 0 deletions
diff --git a/inc/perso.inc b/inc/perso.inc
new file mode 100644
index 0000000..0a32b64
--- /dev/null
+++ b/inc/perso.inc
@@ -0,0 +1,63 @@
+<?php
+
+function sendPerso() {
+ if(empty($_SESSION["perso"]))
+ initPerso();
+ return $_SESSION["perso"];
+}
+
+function increasePerso($prop, $num) {
+ if(empty($_SESSION["perso"]))
+ initPerso();
+ $_SESSION["perso"][$prop] += $num;
+ if($_SESSION["perso"]["hp"] > $_SESSION["perso"]["maxHP"]){//if you want to heal even if you have less than 3 hp to heal, heal until the max is attained
+ $diff = $_SESSION["perso"]["hp"] - $_SESSION["perso"]["maxHP"];
+ $_SESSION["perso"]["hp"] -= $diff;
+ }
+}
+
+/**
+ *traite le fait que wooden sword n'est pas cumulable
+ *metal sword non plus
+ *life bottle cumulable 3 fois
+ *si on clique sur wooden sword alors que on avait une metal sword, le bonusPower passe de +3 à +1
+ */
+function limitUse($item){
+ $n = $item->name;
+ if($n =="Life Bottle")return true;
+ if(empty($_SESSION[$n])){
+ $_SESSION[$n]=1;
+ return true;
+ }
+ else{
+ $_SESSION[$n]++;
+ if($_SESSION[$n] >= $item->feat["limit"])return false;
+ else return true;
+ }
+}
+
+function updatePerso(){
+ $hp = $_POST["hp"];
+ $maxHP = $_POST["maxHP"];
+ $xp = $_POST["xp"];
+ $lv = $_POST["lv"];
+ $power = $_POST["power"];
+ $bonusPower = $_POST["bonusPower"];
+ $_SESSION["perso"]["hp"] = +$hp;
+ $_SESSION["perso"]["maxHP"] = +$maxHP;
+ $_SESSION["perso"]["xp"] = +$xp;
+ $_SESSION["perso"]["lv"] = +$lv;
+ $_SESSION["perso"]["power"] = +$power;
+ $_SESSION["perso"]["bonusPower"] = +$bonusPower;
+}
+
+function initPerso(){
+ $_SESSION["perso"]["hp"] = 5;
+ $_SESSION["perso"]["maxHP"] = 5;
+ $_SESSION["perso"]["xp"] = 0;
+ $_SESSION["perso"]["lv"] = 3;
+ $_SESSION["perso"]["power"] = 3;
+ $_SESSION["perso"]["bonusPower"] = 0;
+}
+
+?>