fixes, bits and pieces, changes in ID referencing, terrain and wall takes damage, working test pickaxe, and a new issue

This commit is contained in:
Song Minjae
2017-04-17 02:18:52 +09:00
parent 6087072d3d
commit f2ae2d9449
40 changed files with 502 additions and 249 deletions

View File

@@ -16,13 +16,6 @@ import org.newdawn.slick.GameContainer
open abstract class DynamicItem(val baseItemID: Int?, newMass: Double? = null, newScale: Double? = null)
: InventoryItem() {
/*
/**
* Internal ID of an Item, Long
* 0-4096: Tiles
* 4097-32767: Static items
* 32768-16777215: Dynamic items
* >= 16777216: Actor RefID
*/
override val id: Int = generateUniqueDynamicItemID()
private fun generateUniqueDynamicItemID(): Int {

View File

@@ -7,6 +7,9 @@ object IVKey {
const val ITEMTYPE = "itemtype" // "sword1h", "sword2h", "pick", "hammer", "tile", "wall", etc
const val UUID = "uuid" // some items need UUID to be stored
const val BASE_WEAPON_POWER = "baseweaponpower"
const val BASE_PICK_POWER = "basepickpower"
object ItemType {
const val BLOCK = "tile"

View File

@@ -10,17 +10,12 @@ import org.newdawn.slick.GameContainer
/**
* Created by minjaesong on 16-01-16.
*/
abstract class InventoryItem : Comparable<InventoryItem> {
/**
* Internal ID of an Item,
* 0-4095: Tiles
* 4096-32767: Unique items (isUnique = true), brand-new tools
* 32768-16777215: Dynamic items (e.g. tools with damage)
* >= 16777216: Actor RefID
*/
abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
abstract val id: Int
/**
*
* e.g. Key Items (in a Pokémon sense), floppies
*/
abstract val isUnique: Boolean
@@ -47,11 +42,11 @@ abstract class InventoryItem : Comparable<InventoryItem> {
abstract var baseToolSize: Double?
abstract var category: String // "weapon", "tool", "armor", etc. (all smallcaps)
abstract var inventoryCategory: String // "weapon", "tool", "armor", etc. (all smallcaps)
var itemProperties = ItemValue()
/** Single-use then destroyed (e.g. Tiles) */
/** Single-use then destroyed (e.g. Tiles), aka negation of "stackable" */
abstract var consumable: Boolean
/**
@@ -94,9 +89,12 @@ abstract class InventoryItem : Comparable<InventoryItem> {
/**
* Set to zero if durability not applicable
*/
open var maxDurability: Double = 0.0
open var maxDurability: Int = 0
open var durability: Double = 0.0
/**
* Float. NOT A MISTAKE
*/
open var durability: Float = 0f
/**
* Effects applied continuously while in pocket
@@ -115,6 +113,9 @@ abstract class InventoryItem : Comparable<InventoryItem> {
* @return true when used successfully, false otherwise
*
* note: DO NOT super(gc, g) this!
*
* Consumption function is executed in net.torvald.terrarum.gamecontroller.GameController,
* in which the function itself is defined in net.torvald.terrarum.gameactors.ActorInventory
*/
open fun primaryUse(gc: GameContainer, delta: Int): Boolean = false
@@ -212,4 +213,12 @@ abstract class InventoryItem : Comparable<InventoryItem> {
const val WALL = "wall"
const val MISC = "misc"
}
override public fun clone(): InventoryItem {
val clonedItem = super.clone()
// properly clone ItemValue
(clonedItem as InventoryItem).itemProperties = this.itemProperties.clone()
return clonedItem
}
}