From dcbb0df4f9d62fd18a1676c315499f2f27202800 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Thu, 30 Dec 2021 17:33:01 +0100 Subject: [PATCH] Typefied spaceship part unique (#5878) * Typefied spaceship part unique * Removed unused imports * Ah right, spaceship parts are still buildings --- core/src/com/unciv/logic/GameInfo.kt | 2 +- core/src/com/unciv/logic/automation/Automation.kt | 2 +- core/src/com/unciv/logic/automation/ConstructionAutomation.kt | 3 +-- core/src/com/unciv/models/ruleset/Building.kt | 4 ++-- core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 1 + 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 7c71c9ba47..cefda18a6e 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -448,7 +448,7 @@ class GameInfo { } } - spaceResources.addAll(ruleSet.buildings.values.filter { it.hasUnique("Spaceship part") } + spaceResources.addAll(ruleSet.buildings.values.filter { it.hasUnique(UniqueType.SpaceshipPart) } .flatMap { it.getResourceRequirements().keys } ) barbarians.setTransients(this) diff --git a/core/src/com/unciv/logic/automation/Automation.kt b/core/src/com/unciv/logic/automation/Automation.kt index 9d30a07078..9d779686d4 100644 --- a/core/src/com/unciv/logic/automation/Automation.kt +++ b/core/src/com/unciv/logic/automation/Automation.kt @@ -173,7 +173,7 @@ object Automation { return true // Spaceships are always allowed - if (construction.hasUnique("Spaceship part")) + if (construction.hasUnique(UniqueType.SpaceshipPart)) return true val requiredResources = construction.getResourceRequirements() diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index 580c26eeee..6a622904b7 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -2,7 +2,6 @@ package com.unciv.logic.automation import com.unciv.UncivGame import com.unciv.logic.city.CityConstructions -import com.unciv.logic.city.INonPerpetualConstruction import com.unciv.logic.city.PerpetualConstruction import com.unciv.logic.civilization.CityAction import com.unciv.logic.civilization.NotificationIcon @@ -194,7 +193,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ } private fun addSpaceshipPartChoice() { - val spaceshipPart = buildableNotWonders.firstOrNull { it.uniques.contains("Spaceship part") } + val spaceshipPart = buildableNotWonders.firstOrNull { it.hasUnique(UniqueType.SpaceshipPart) } if (spaceshipPart != null) { var modifier = 1.5f if (preferredVictoryType == VictoryType.Scientific) modifier = 2f diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 7f3771225f..68e3231cd3 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -629,7 +629,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { } } - if ("Spaceship part" in uniques) { + if (hasUnique(UniqueType.SpaceshipPart)) { if (!civInfo.hasUnique("Enables construction of Spaceship parts")) rejectionReasons.add( RejectionReason.RequiresBuildingInSomeCity.apply { errorMessage = "Apollo project not built!" } @@ -722,7 +722,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { override fun postBuildEvent(cityConstructions: CityConstructions, boughtWith: Stat?): Boolean { val civInfo = cityConstructions.cityInfo.civInfo - if ("Spaceship part" in uniques) { + if (hasUnique(UniqueType.SpaceshipPart)) { civInfo.victoryManager.currentsSpaceshipParts.add(name, 1) return true } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 433de055a2..6eee16cf94 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -269,6 +269,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags: CanEnterForeignTilesButLosesReligiousStrength("May enter foreign tiles without open borders, but loses [amount] religious strength each turn it ends there", UniqueTarget.Unit), ReligiousUnit("Religious Unit", UniqueTarget.Unit), + SpaceshipPart("Spaceship part", UniqueTarget.Building, UniqueTarget.Unit), //endregion