Skip to content

ItemContainer

class ItemContainer(
val capacity: Int,
val stack: ItemContainerStackBehaviour = ItemContainerStackBehaviour.Normal
) : Iterable<Item?>
Example
fun describe(player: Actor, inventory: Inventory) {
val items: ItemContainer = inventory.raw
val sharks = items.count(Assets.Item.shark.id)
player.message("$sharks sharks; ${items.freeSlotCount} of ${items.capacity} slots free.")
}
val capacity: Int
val stack: ItemContainerStackBehaviour
override fun iterator(): Iterator<Item?>
fun contains(item: Int): Boolean
val freeSlotCount: Int
val isFull: Boolean
val isEmpty: Boolean
fun add(
item: Item,
partial: Boolean = false
): Int
fun add(
id: Int,
amount: Int = 1,
partial: Boolean = false
): Int
fun remove(
item: Item,
partial: Boolean = false
): Int
fun remove(
id: Int,
amount: Int = 1,
partial: Boolean = false
): Int
fun count(id: Int): Int
fun fits(item: Item): Int
fun removeAll()
fun move(
from: Int,
to: Int
)
operator fun get(index: Int): Item?
operator fun set(
index: Int,
item: Item?
)