removing stupidity which harmed AmmoMeterProxy

This commit is contained in:
Song Minjae
2017-04-25 15:29:24 +09:00
parent ce08b47423
commit 7264fc6381
3 changed files with 13 additions and 22 deletions

View File

@@ -19,8 +19,10 @@ object AmmoMeterProxy {
}
else {
meter.vitalGetterVal = {
if (ItemCodex[currentItem.originalID].stackable)
if (ItemCodex[currentItem.originalID].stackable) {
//println("[AmmoMeterProxy] currentItem: $currentItem")
actor.inventory.getByDynamicID(currentItem.dynamicID)!!.amount.toFloat()
}
else
currentItem.durability
}

View File

@@ -93,8 +93,8 @@ class UIItemInventoryElem(
// this one-liner sets color
g.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol
g.drawString(
"$item" + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
//item!!.name + (if (amount > 0 && !item!!.isUnique) "$fwsp($amount)" else "") +
//"$item" + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
(if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""),
posX + textOffsetX,
posY + textOffsetY

View File

@@ -61,22 +61,12 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
// if the item already exists
if (existingItem != null) {
val newCount = getByDynamicID(item.dynamicID)!!.amount + count
itemList.remove(existingItem)
itemList.add(InventoryPair(existingItem.item, newCount))
// increment count
existingItem.amount += count
}
// new item
else {
/*if (item.isDynamic) {
// assign new ID for each
repeat(count) {
val newItem = item.clone().generateUniqueDynamicID(this)
itemList.add(InventoryPair(newItem, 1))
}
}
else {*/
itemList.add(InventoryPair(item, count))
//}
itemList.add(InventoryPair(item, count))
}
insertionSortLastElem(itemList)
}
@@ -98,15 +88,14 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
val existingItem = getByDynamicID(item.dynamicID)
if (existingItem != null) { // if the item already exists
val newCount = getByDynamicID(item.dynamicID)!!.amount - count
val newCount = existingItem.amount - count
if (newCount < 0) {
throw Error("Tried to remove $count of $item, but the inventory only contains ${getByDynamicID(item.dynamicID)!!.amount} of them.")
throw Error("Tried to remove $count of $item, but the inventory only contains ${existingItem.amount} of them.")
}
else if (newCount > 0) {
// decrement count
val newCount = getByDynamicID(item.dynamicID)!!.amount - count
itemList.remove(existingItem)
itemList.add(InventoryPair(existingItem.item, newCount))
existingItem.amount = newCount
}
else {
// unequip, if applicable
@@ -281,4 +270,4 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
}
}
data class InventoryPair(val item: InventoryItem, val amount: Int)
data class InventoryPair(val item: InventoryItem, var amount: Int)