aboutsummaryrefslogtreecommitdiffstats
path: root/inc/Inventory.inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc/Inventory.inc')
-rw-r--r--inc/Inventory.inc15
1 files changed, 10 insertions, 5 deletions
diff --git a/inc/Inventory.inc b/inc/Inventory.inc
index 58cf709..4a1add8 100644
--- a/inc/Inventory.inc
+++ b/inc/Inventory.inc
@@ -1,4 +1,7 @@
<?php
+
+require_once("perso.inc");
+
/**
* Represent the player's Inventory.
* Implemented as a singleton in the session.
@@ -110,12 +113,14 @@ class Inventory {
foreach($this->items as $k => $object){
if($object[0] == $item) {
$nb = $this->items[$k][1];
- if($nb > 0) {
- $this->items[$k][0]->consume();
- $this->items[$k][1]--;
+ if(limitUse($this->items[$k][0])){
+ if($nb > 0) {
+ $this->items[$k][0]->consume();
+ $this->items[$k][1]--;
+ }
+ if($nb-1 <= 0) $this->_removeItem($item);
+ return array($object[0], $nb-1);
}
- if($nb-1 <= 0) $this->_removeItem($item);
- return array($object[0], $nb-1);
}
}
return false;