diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/IItemDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/IItemDefinition.kt index 38a54ecd..b8a46eb3 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/IItemDefinition.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/IItemDefinition.kt @@ -18,6 +18,11 @@ interface IItemDefinition : IThingWithDescription { */ val price: Long + /** + * Редкость предмета + */ + val rarity: ItemRarity + /** * Категория предмета, определяет, в какую вкладку инвентаря оно попадает */ @@ -48,6 +53,11 @@ interface IItemDefinition : IThingWithDescription { */ val eventCategory: String? + /** + * Топливо корабля + */ + val fuelAmount: Long + /** * Заставляет предмет "использовать" сразу же при подборе */ diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemPrototype.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemPrototype.kt index 07091114..a55f3b0b 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemPrototype.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemPrototype.kt @@ -28,12 +28,12 @@ open class ItemPrototype : FreezableDefintionBuilder(), IItemDefinition { get() = descriptionData.racialShortDescription @JsonPropertyConfig(isFlat = true) - var descriptionData: ThingDescription by NotNullVar() + var descriptionData: ThingDescription by NotNull() final override var itemName: String by NotNull() final override var price: Long by NotNull(0L) final override var rarity: ItemRarity by NotNull(ItemRarity.COMMON) - final override var category: String? by Nullable() + final override var category: String by NotNull() final override var inventoryIcon: ImmutableList? by Nullable() final override var itemTags: ImmutableList by NotNull(ImmutableList.of()) final override var learnBlueprintsOnPickup: ImmutableList> by NotNull(ImmutableList.of()) @@ -44,7 +44,7 @@ open class ItemPrototype : FreezableDefintionBuilder(), IItemDefinition { final override var tooltipKind: String by NotNull("normal") final override var twoHanded: Boolean by NotNull(false) final override var radioMessagesOnPickup: ImmutableList by NotNull(ImmutableList.of()) - final override var fuelAmount: Long? by Nullable() + final override var fuelAmount: Long by NotNull(0L) final override var pickupSoundsSmall: ImmutableList by NotNull(ImmutableList.of()) final override var pickupSoundsMedium: ImmutableList by NotNull(ImmutableList.of()) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemRarity.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemRarity.kt new file mode 100644 index 00000000..1e889c3a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemRarity.kt @@ -0,0 +1,20 @@ +package ru.dbotthepony.kstarbound.defs.item + +import com.google.gson.stream.JsonWriter +import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable + +enum class ItemRarity(val canonical: String) : IStringSerializable { + COMMON("Common"), + UNCOMMON("Uncommon"), + RARE("Rare"), + LEGENDARY("Legendary"), + ESSENTIAL("Essential"); + + override fun match(name: String): Boolean { + return name == this.canonical || name.lowercase() == this.name.lowercase() + } + + override fun write(out: JsonWriter) { + out.value(canonical) + } +}