From f734770dd4fe464a8c263218efa90fd487c6a608 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 8 May 2016 14:41:25 +0200 Subject: Add feature attribute to Item class + add consume() method to use those features + use coercion on updatePerso() values --- inc/Item.inc | 15 ++++++++++++++- inc/perso.inc | 13 ++++++++++--- 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 @@ 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 @@