From 005aa354df664abaebd15dc6c468b177e8618145 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Feb 2023 15:48:42 +0700 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20rarity,=20fuel=20=D0=B8=20category=20?= =?UTF-8?q?=D0=B8=D0=B1=D0=BE=20=D0=BE=D0=BD=D0=B8=20=D0=BD=D1=83=D0=B6?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B4=D0=B2=D0=B8=D0=B6=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kstarbound/defs/item/IItemDefinition.kt | 10 ++++++++++ .../kstarbound/defs/item/ItemPrototype.kt | 6 +++--- .../kstarbound/defs/item/ItemRarity.kt | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/item/ItemRarity.kt 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) + } +}