mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-19 15:04:05 +09:00
inventory ui update
This commit is contained in:
@@ -2,6 +2,7 @@ package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameitem.InventoryItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -18,7 +19,7 @@ interface Pocketed {
|
||||
if (item.equipPosition == InventoryItem.EquipPosition.NULL)
|
||||
throw Error("Unequipping the item that cannot be equipped")
|
||||
|
||||
if (!inventory.hasItem(item))
|
||||
if (!inventory.contains(item))
|
||||
throw Error("Unequipping the item that does not exist in inventory")
|
||||
|
||||
inventory.itemEquipped[item.equipPosition] = null
|
||||
@@ -29,7 +30,7 @@ interface Pocketed {
|
||||
* Equips an item. If the item is not in the inventory, adds the item first.
|
||||
*/
|
||||
fun equipItem(item: InventoryItem) {
|
||||
if (!inventory.hasItem(item))
|
||||
if (!inventory.contains(item))
|
||||
inventory.add(item)
|
||||
|
||||
if (item.equipPosition >= 0) {
|
||||
@@ -38,10 +39,17 @@ interface Pocketed {
|
||||
}
|
||||
}
|
||||
|
||||
fun isEquipped(item: InventoryItem): Boolean {
|
||||
fun equipped(item: InventoryItem): Boolean {
|
||||
return inventory.itemEquipped[item.equipPosition] == item
|
||||
}
|
||||
|
||||
fun addItem(itemID: Int, count: Int = 1) = inventory.add(ItemCodex[itemID], count)
|
||||
fun addItem(item: InventoryItem, count: Int = 1) = inventory.add(item, count)
|
||||
fun removeItem(itemID: Int, count: Int = 1) = inventory.remove(ItemCodex[itemID], count)
|
||||
fun removeItem(item: InventoryItem, count: Int = 1) = inventory.remove(item, count)
|
||||
|
||||
fun hasItem(item: InventoryItem) = inventory.contains(item.id)
|
||||
fun hasItem(id: Int) = inventory.contains(id)
|
||||
|
||||
|
||||
fun consumePrimary(item: InventoryItem) {
|
||||
|
||||
Reference in New Issue
Block a user