aboutsummaryrefslogtreecommitdiffstats
path: root/inc/perso.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-08 14:41:25 +0200
committerpiernov <piernov@piernov.org>2016-05-08 14:41:25 +0200
commitf734770dd4fe464a8c263218efa90fd487c6a608 (patch)
treee5f2b277d0272d622f1443590aca54a860cce76a /inc/perso.inc
parent2ecc9a72e9e932f1bf0431f391814837d8694884 (diff)
downloadcandybox-f734770dd4fe464a8c263218efa90fd487c6a608.tar.gz
candybox-f734770dd4fe464a8c263218efa90fd487c6a608.tar.bz2
candybox-f734770dd4fe464a8c263218efa90fd487c6a608.tar.xz
candybox-f734770dd4fe464a8c263218efa90fd487c6a608.zip
Add feature attribute to Item class + add consume() method to use those features + use coercion on updatePerso() values
Diffstat (limited to 'inc/perso.inc')
-rw-r--r--inc/perso.inc13
1 files changed, 10 insertions, 3 deletions
diff --git a/inc/perso.inc b/inc/perso.inc
index 0362d8c..f455173 100644
--- a/inc/perso.inc
+++ b/inc/perso.inc
@@ -1,17 +1,24 @@
<?php
+
function sendPerso() {
if(empty($_SESSION["perso"]))
initPerso();
return $_SESSION["perso"];
}
+function increasePerso($prop, $num) {
+ if(empty($_SESSION["perso"]))
+ initPerso();
+ $_SESSION["perso"][$prop] += $num;
+}
+
function updatePerso(){
$hp = $_POST["hp"];
$xp = $_POST["xp"];
$lv = $_POST["lv"];
- $_SESSION["perso"]["hp"] = $hp;
- $_SESSION["perso"]["xp"] = intval($xp);
- $_SESSION["perso"]["lv"] = $lv;
+ $_SESSION["perso"]["hp"] = +$hp;
+ $_SESSION["perso"]["xp"] = +$xp;
+ $_SESSION["perso"]["lv"] = +$lv;
}
function initPerso(){