aboutsummaryrefslogtreecommitdiffstats
path: root/inc/Item.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-03 10:37:18 +0200
committerpiernov <piernov@piernov.org>2016-05-03 10:37:18 +0200
commit64e184b901fd4e7c9a829d14c5c34416923171c3 (patch)
tree70b5281ca85a38ef2a077e226dcce56a40ed563a /inc/Item.inc
parentadd9d3248a5adc02b071a301005c6f11195f7f7b (diff)
parentb8112f72b322fe5bf7048ac76251c8c637b9fee2 (diff)
downloadcandybox-64e184b901fd4e7c9a829d14c5c34416923171c3.tar.gz
candybox-64e184b901fd4e7c9a829d14c5c34416923171c3.tar.bz2
candybox-64e184b901fd4e7c9a829d14c5c34416923171c3.tar.xz
candybox-64e184b901fd4e7c9a829d14c5c34416923171c3.zip
Merge branch 'master' into alexichi
Diffstat (limited to 'inc/Item.inc')
-rw-r--r--inc/Item.inc12
1 files changed, 12 insertions, 0 deletions
diff --git a/inc/Item.inc b/inc/Item.inc
index bf77818..8e90998 100644
--- a/inc/Item.inc
+++ b/inc/Item.inc
@@ -12,6 +12,18 @@ class Item {
$this->icon = $icon;
$this->desc = $desc;
}
+
+ function addToXML($root) {
+ $item = $root->addChild("item");
+ $item->addChild("name", $this->name);
+ $item->addChild("cost", $this->cost);
+ $item->addChild("icon", $this->icon);
+ $item->addChild("desc", $this->desc);
+ }
+
+ public static function fromXML($xml) {
+ return new static((string)$xml->name, +(string)$xml->cost /* convert to number */, (string)$xml->icon, (string)$xml->desc);
+ }
}
?>