aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/Item.inc15
-rw-r--r--inc/perso.inc13
2 files changed, 24 insertions, 4 deletions
diff --git a/inc/Item.inc b/inc/Item.inc
index 907872e..f01b709 100644
--- a/inc/Item.inc
+++ b/inc/Item.inc
@@ -1,16 +1,29 @@
<?php
+require_once("perso.inc");
+
class Item {
public $name = "";
public $cost = 0;
public $icon = "";
public $desc = "";
+ public $feat = array();
- function __construct($name, $cost, $icon, $desc) {
+ function __construct($name, $cost, $icon, $desc, $feat) {
$this->name = $name;
$this->cost = $cost;
$this->icon = $icon;
$this->desc = $desc;
+ $this->feat = $feat;
+ }
+
+ function consume() {
+ foreach($this->feat as $k => $v) {
+ switch($k) {
+ case "hp": increasePerso("hp", +$v); break;
+ case "power": break;
+ }
+ }
}
function addToXML($root, $count) {
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(){