aboutsummaryrefslogtreecommitdiffstats
path: root/inc/Inventory.inc
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-07 12:08:36 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-07 12:08:36 +0200
commit79cfbb29042fd60dfbc76a6810f75cce21d3ffe0 (patch)
treeed1425c2bf94fd7e2b068bfe64134e0689f83285 /inc/Inventory.inc
parentee02581b7fabd087fc4056bda739c88656fbca14 (diff)
downloadcandybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.tar.gz
candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.tar.bz2
candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.tar.xz
candybox-79cfbb29042fd60dfbc76a6810f75cce21d3ffe0.zip
add the use of the life bottle
Diffstat (limited to 'inc/Inventory.inc')
-rw-r--r--inc/Inventory.inc17
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);