diff options
author | piernov <piernov@piernov.org> | 2016-05-08 15:09:55 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-05-08 15:09:55 +0200 |
commit | 818a88625577b4422f82af6fda3718b43b84fb6d (patch) | |
tree | 5b9e6ee19cc5c709e85c2667b8b0b089ad092dc5 | |
parent | 9c43e81e57cebceee5abc2e8897e7cf5631eff5b (diff) | |
download | candybox-818a88625577b4422f82af6fda3718b43b84fb6d.tar.gz candybox-818a88625577b4422f82af6fda3718b43b84fb6d.tar.bz2 candybox-818a88625577b4422f82af6fda3718b43b84fb6d.tar.xz candybox-818a88625577b4422f82af6fda3718b43b84fb6d.zip |
Items feature support on save/load gamefeat/savegame
-rw-r--r-- | inc/Item.inc | 9 |
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); } } |