diff options
author | alexichi <alexbankai96@gmail.com> | 2016-04-29 21:06:59 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-04-29 21:06:59 +0200 |
commit | 48ca3e8ee63787d567fd0fe1bcfea7158a6f9596 (patch) | |
tree | 2c2b5bdf4c2461444112c5a63b94f4dffcae84ff /inc/Inventory.inc | |
parent | 3c297defe63a2af75cc7aafcfa5cf74dd1f2c20a (diff) | |
download | candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.tar.gz candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.tar.bz2 candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.tar.xz candybox-48ca3e8ee63787d567fd0fe1bcfea7158a6f9596.zip |
add the option to not create 2 objects of the same type, doesn't work well
Diffstat (limited to 'inc/Inventory.inc')
-rw-r--r-- | inc/Inventory.inc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/inc/Inventory.inc b/inc/Inventory.inc index efe54f2..3396eb9 100644 --- a/inc/Inventory.inc +++ b/inc/Inventory.inc @@ -20,12 +20,21 @@ class Inventory { } private function _addItem($item) { - $this->items[] = $item; + $counter = 0; + foreach($this->items as $object){ + if($object[0] == $item){ + $counter++; + } + } + $tab = array($item,$counter+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) { @@ -36,6 +45,7 @@ class Inventory { $inv = self::get(); $inv->_removeItem($item); } + } ?> |