walls now work

This commit is contained in:
minjaesong
2021-02-25 11:11:47 +09:00
parent 5f16f71b0a
commit 795f0ab853
3 changed files with 18 additions and 15 deletions

View File

@@ -45,18 +45,15 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
init {
}
fun add(itemID: ItemID, count: Int = 1) = if (ItemCodex[itemID] == null) throw NullPointerException("Item not found: "+itemID) else add(ItemCodex[itemID]!!, count)
fun add(itemID: ItemID, count: Int = 1) {
if (ItemCodex[itemID] == null)
throw NullPointerException("Item not found: $itemID")
else
add(ItemCodex[itemID]!!, count)
}
fun add(item: GameItem, count: Int = 1) {
println("[ActorInventory] add $item, $count")
// not wall-able walls
if (item.inventoryCategory == GameItem.Category.WALL &&
(!item.dynamicID.startsWith("wall@") || !BlockCodex[item.dynamicID.substring(5)].isWallable)) {
throw IllegalArgumentException("Wall ID ${item.dynamicID} is not wall-able.")
}
println("[ActorInventory] add-by-elem $item, $count")
// other invalid values
if (count == 0)

View File

@@ -78,7 +78,7 @@ object PlayerBuilderSigrid {
CreateTileAtlas.tags.forEach { t, _ ->
inventory.add(t, 9995)
try {
inventory.add("wall@"+t, 9995)
inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs
}
catch (e: Throwable) {
System.err.println("[PlayerBuilder] $e")