fresh-new dynamic items (e.g. pickaxe) can be stacked

This commit is contained in:
Song Minjae
2017-04-25 02:59:59 +09:00
parent c35ba8201a
commit ebc8174d2c
12 changed files with 102 additions and 47 deletions

View File

@@ -16,12 +16,15 @@ import org.newdawn.slick.GameContainer
abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
abstract var dynamicID: Int
/**
* if the ID is a Actor range, it's an actor contained in a pocket.
*/
abstract val originalID: Int // WUT?! using init does not work!!
/**
*
* e.g. Key Items (in a Pokémon sense), floppies
* e.g. Key Items (in a Pokémon sense); only the single instance of the item can exist in the pocket
*/
abstract val isUnique: Boolean
@@ -51,13 +54,15 @@ abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
var itemProperties = ItemValue()
/** Single-use then destroyed (e.g. Tiles), aka negation of "stackable" */
abstract var consumable: Boolean
/** Single-use then destroyed (e.g. Tiles), same as "consumable" */
abstract var stackable: Boolean
/**
* DYNAMIC means the item ID should be generated on the fly whenever the item is created.
* This is to be used with weapons/armours/etc where multiple instances can exist, and
* each of them should be treated as different item.
* each of them should be treated as different item. Because of this, new
* derivative instances (dynamically created items, e.g. used pickaxe) are not stackable.
*
* ID Range: 32768..1048575 (ItemCodex.ITEM_DYNAMIC)
*

View File

@@ -46,14 +46,14 @@ object ItemCodex {
// tile items (blocks and walls are the same thing basically)
for (i in ITEM_TILES + ITEM_WALLS) {
itemCodex[i] = object : InventoryItem() {
override var dynamicID: Int = i
override val originalID = dynamicID
override val originalID = i
override var dynamicID = i
override val isUnique: Boolean = false
override var baseMass: Double = TileCodex[i].density / 1000.0
override var baseToolSize: Double? = null
override var equipPosition = EquipPosition.HAND_GRIP
override val originalName = TileCodex[i % ITEM_WALLS.first].nameKey
override var consumable = true
override var stackable = true
override var inventoryCategory = Category.BLOCK
override var isDynamic = false
@@ -105,14 +105,14 @@ object ItemCodex {
// test copper pickaxe
itemCodex[ITEM_STATIC.first] = object : InventoryItem() {
override var dynamicID = ITEM_STATIC.first
override val originalID = dynamicID
override val originalID = ITEM_STATIC.first
override var dynamicID = originalID
override val isUnique = false
override val originalName = ""
override var baseMass = 10.0
override var baseToolSize: Double? = 10.0
override var consumable = false
override var maxDurability = 147//606 // this much tiles before breaking
override var stackable = true
override var maxDurability = 147//606
override var durability = maxDurability.toFloat()
override var equipPosition = EquipPosition.HAND_GRIP
override var inventoryCategory = Category.TOOL