DEADSOFTWARE

Update version
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / mobs / player / Inventory.kt
index 44ee6dd17e6bb94393475dc22c2778f4a2569338..36827c36bd997bdfea07808f98412d403a4e9f14 100644 (file)
@@ -82,9 +82,9 @@ class Inventory(
         val inventoryItem = items[slot]
 
         if (inventoryItem.item == drop.item) {
-            inventoryItem.add()
+            inventoryItem.add(drop.amount)
         } else {
-            _items[slot] = drop.item.toInventoryItem()
+            _items[slot] = drop.item.toInventoryItem(drop.amount)
             if (slot == activeSlot) {
                 showCurrentItemTooltip()
             }
@@ -106,10 +106,16 @@ class Inventory(
     }
 
     @JvmOverloads
-    fun decreaseCurrentItemAmount(count: Int = 1) {
-        activeItem.subtract(count)
-        if (activeItem.amount <= 0) {
-            _items[activeSlot] = fallbackItem
+    fun decreaseItemAmount(slot: Int, count: Int = 1) {
+        val item = _items[slot]
+        item.subtract(count)
+        if (item.amount <= 0) {
+            _items[slot] = fallbackItem
         }
     }
+
+    @JvmOverloads
+    fun decreaseCurrentItemAmount(count: Int = 1) {
+        decreaseItemAmount(activeSlot, count)
+    }
 }
\ No newline at end of file