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 { else {
meter.vitalGetterVal = { meter.vitalGetterVal = {
if (ItemCodex[currentItem.originalID].stackable) if (ItemCodex[currentItem.originalID].stackable) {
//println("[AmmoMeterProxy] currentItem: $currentItem")
actor.inventory.getByDynamicID(currentItem.dynamicID)!!.amount.toFloat() actor.inventory.getByDynamicID(currentItem.dynamicID)!!.amount.toFloat()
}
else else
currentItem.durability currentItem.durability
} }

View File

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

View File

@@ -61,22 +61,12 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
// if the item already exists // if the item already exists
if (existingItem != null) { if (existingItem != null) {
val newCount = getByDynamicID(item.dynamicID)!!.amount + count // increment count
itemList.remove(existingItem) existingItem.amount += count
itemList.add(InventoryPair(existingItem.item, newCount))
} }
// new item // new item
else { else {
/*if (item.isDynamic) { itemList.add(InventoryPair(item, count))
// assign new ID for each
repeat(count) {
val newItem = item.clone().generateUniqueDynamicID(this)
itemList.add(InventoryPair(newItem, 1))
}
}
else {*/
itemList.add(InventoryPair(item, count))
//}
} }
insertionSortLastElem(itemList) insertionSortLastElem(itemList)
} }
@@ -98,15 +88,14 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
val existingItem = getByDynamicID(item.dynamicID) val existingItem = getByDynamicID(item.dynamicID)
if (existingItem != null) { // if the item already exists if (existingItem != null) { // if the item already exists
val newCount = getByDynamicID(item.dynamicID)!!.amount - count val newCount = existingItem.amount - count
if (newCount < 0) { 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) { else if (newCount > 0) {
// decrement count // decrement count
val newCount = getByDynamicID(item.dynamicID)!!.amount - count existingItem.amount = newCount
itemList.remove(existingItem)
itemList.add(InventoryPair(existingItem.item, newCount))
} }
else { else {
// unequip, if applicable // 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)