diff options
author | piernov <piernov@piernov.org> | 2016-05-07 13:48:28 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-05-07 13:48:28 +0200 |
commit | b91588134f3067c2771011c10af77cda5f9031e8 (patch) | |
tree | a8e5f1bde0bfe9539bb5dd29e249ee8c6b1f36d6 /inc/Inventory.inc | |
parent | 8621eae6aa5fcdba0a60f0a5f1136412c61999ec (diff) | |
parent | 80f5826d1ac8f6d42866d5133c6f463943b96bab (diff) | |
download | candybox-b91588134f3067c2771011c10af77cda5f9031e8.tar.gz candybox-b91588134f3067c2771011c10af77cda5f9031e8.tar.bz2 candybox-b91588134f3067c2771011c10af77cda5f9031e8.tar.xz candybox-b91588134f3067c2771011c10af77cda5f9031e8.zip |
Merge branch 'alexichi' into feat/gui
Diffstat (limited to 'inc/Inventory.inc')
-rw-r--r-- | inc/Inventory.inc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/inc/Inventory.inc b/inc/Inventory.inc index 024a4fe..747c4db 100644 --- a/inc/Inventory.inc +++ b/inc/Inventory.inc @@ -46,6 +46,23 @@ class Inventory { $inv->_removeItem($item); } + private function _useItem($item) { + foreach($this->items as $k => $object){ + if($object[0] == $item){ + if($this->items[$k][1]>0)$this->items[$k][1]--; + //if($this->items[$k][1] == 0) _removeItem($item); + return $this->items[$k]; + } + } + return false; + } + + public static function useItem($item) { + $inv = self::get(); + $it = $inv->_useItem($item); + return $it; + } + public function addToXML($root) { foreach($this->items as $item) $item->addToXML($root); |