From 79cfbb29042fd60dfbc76a6810f75cce21d3ffe0 Mon Sep 17 00:00:00 2001 From: alexichi Date: Sat, 7 May 2016 12:08:36 +0200 Subject: add the use of the life bottle --- inc/Inventory.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'inc/Inventory.inc') 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); -- cgit v1.2.3-54-g00ecf