aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-08 15:09:55 +0200
committerpiernov <piernov@piernov.org>2016-05-08 15:09:55 +0200
commit818a88625577b4422f82af6fda3718b43b84fb6d (patch)
tree5b9e6ee19cc5c709e85c2667b8b0b089ad092dc5 /inc
parent9c43e81e57cebceee5abc2e8897e7cf5631eff5b (diff)
downloadcandybox-feat/savegame.tar.gz
candybox-feat/savegame.tar.bz2
candybox-feat/savegame.tar.xz
candybox-feat/savegame.zip
Items feature support on save/load gamefeat/savegame
Diffstat (limited to 'inc')
-rw-r--r--inc/Item.inc9
1 files changed, 8 insertions, 1 deletions
diff --git a/inc/Item.inc b/inc/Item.inc
index f01b709..8eebbf8 100644
--- a/inc/Item.inc
+++ b/inc/Item.inc
@@ -32,11 +32,18 @@ class Item {
$item->addChild("cost", $this->cost);
$item->addChild("icon", $this->icon);
$item->addChild("desc", $this->desc);
+ $xmlfeat = $item->addChild("feat");
+ foreach($this->feat as $k => $v)
+ $xmlfeat->addChild($k, $v);
$item->addChild("count", $count);
}
public static function fromXML($xml) {
- return new static((string)$xml->name, +(string)$xml->cost /* convert to number */, (string)$xml->icon, (string)$xml->desc);
+ $feats = array();
+ foreach($xml->feat[0] as $k => $v)
+ $feats[(string)$k] = (string)$v;
+
+ return new static((string)$xml->name, +(string)$xml->cost /* convert to number */, (string)$xml->icon, (string)$xml->desc, $feats);
}
}