mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 13:04:05 +09:00
inventory now shows equipped position
Former-commit-id: 10950ffc409accfa914b9f531193b2fac0783f7d
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gameitem
|
||||
|
||||
import net.torvald.terrarum.ItemValue
|
||||
import net.torvald.terrarum.gameactors.Pocketed
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import org.newdawn.slick.Color
|
||||
@@ -91,7 +92,8 @@ abstract class InventoryItem : Comparable<InventoryItem> {
|
||||
* Set to zero if durability not applicable
|
||||
*/
|
||||
open var maxDurability: Double = 0.0
|
||||
open var durability: Double = maxDurability
|
||||
|
||||
open var durability: Double = 0.0
|
||||
|
||||
/**
|
||||
* Effects applied continuously while in pocket
|
||||
@@ -152,6 +154,17 @@ abstract class InventoryItem : Comparable<InventoryItem> {
|
||||
|
||||
fun Int.sign(): Int = if (this > 0) 1 else if (this < 0) -1 else 0
|
||||
|
||||
infix fun equipTo(actor: Pocketed) {
|
||||
if (equipPosition == EquipPosition.NULL)
|
||||
throw IllegalArgumentException("Item is not supposed to be equipped (equipPosition is NULL")
|
||||
|
||||
if (!actor.inventory.hasItem(this.id)) {
|
||||
actor.inventory.add(this)
|
||||
}
|
||||
|
||||
actor.itemEquipped[this.equipPosition] = this
|
||||
}
|
||||
|
||||
object EquipPosition {
|
||||
const val NULL = -1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user