<?php

class Item {
	public $name = "";
	public $cost = 0;
	public $icon = "";
	public $desc = "";

	function __construct($name, $cost, $icon, $desc) {
		$this->name = $name;
		$this->cost = $cost;
		$this->icon = $icon;
		$this->desc = $desc;
	}

	function addToXML($root, $count) {
		$item = $root->addChild("item");
		$item->addChild("name", $this->name);
		$item->addChild("cost", $this->cost);
		$item->addChild("icon", $this->icon);
		$item->addChild("desc", $this->desc);
		$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);
	}
}

?>