diff options
Diffstat (limited to 'inc/Inventory.inc')
-rw-r--r-- | inc/Inventory.inc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/inc/Inventory.inc b/inc/Inventory.inc index 0a93d7f..024a4fe 100644 --- a/inc/Inventory.inc +++ b/inc/Inventory.inc @@ -20,12 +20,21 @@ class Inventory { } private function _addItem($item) { - $this->items[] = $item; + foreach($this->items as $k => $object){ + if($object[0] == $item){ + $this->items[$k][1]++; + return $this->items[$k]; + } + } + $tab = array($item,1); + $this->items[] = $tab; + return $tab; } public static function addItem($item) { $inv = self::get(); - $inv->_addItem($item); + $tab = $inv->_addItem($item); + return $tab; } private function _removeItem($item) { |