aboutsummaryrefslogtreecommitdiffstats
path: root/inc/Item.inc
blob: 8e90998fe8987076b30eae2aca9d15669bba602f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?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) {
		$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);
	}
}

?>