fun Inventory.applyToCurrentItems(quantity: Int = maxAllowedQuantity) {
val reusableItem = object : Inventory.Item {
override var index = 0
override var id = 0
override val quantity = quantity
}
val mutateItem = fun (index: Int, id: Int, quantity: Int) -> Inventory.Item {
reusableItem.index = index
reusableItem.id = id
return reusableItem
}
for (index in 0 until itemCounts) {
setItem(selectItem(index, mapTo = mutateItem))
}
}
Give max quantity of all items
fun Inventory.giveAllItems() {
val itemsCount = supportedItemIds.size.coerceAtMost(capacity)
val reusableItem = object : Inventory.Item {
override var index = 0
override var id = 0
override val quantity = maxAllowedQuantity
}
for (i in 0 until maxSupportedCount) {
reusableItem.index = i
reusableItem.id = supportedItemIds[i]
setItem(reusableItem)
}
}
Maximize current items quantity
Give max quantity of all items
Sort items by id