From bce65a96f6e0a65b1ac197786f4b9c0173c27542 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 14 Feb 2022 19:05:54 +0200 Subject: [PATCH] More unique typing --- core/src/com/unciv/logic/BarbarianManager.kt | 2 +- .../com/unciv/logic/battle/BattleDamage.kt | 2 +- .../unciv/logic/civilization/TechManager.kt | 2 +- .../unciv/models/ruleset/unique/UniqueType.kt | 6 ++++ docs/uniques.md | 33 ++++++++++++++++--- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/core/src/com/unciv/logic/BarbarianManager.kt b/core/src/com/unciv/logic/BarbarianManager.kt index dfeddf4c48..55b7524b29 100644 --- a/core/src/com/unciv/logic/BarbarianManager.kt +++ b/core/src/com/unciv/logic/BarbarianManager.kt @@ -156,7 +156,7 @@ class BarbarianManager { */ private fun notifyCivsOfBarbarianEncampment(tile: TileInfo) { gameInfo.civilizations.filter { - it.hasUnique("Notified of new Barbarian encampments") + it.hasUnique(UniqueType.NotifiedOfBarbarianEncampments) && it.exploredTiles.contains(tile.position) } .forEach { diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 1776b9e7be..33373a01e7 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -103,7 +103,7 @@ object BattleDamage { } if (enemy.getCivInfo().isCityState() - && civInfo.hasUnique("+30% Strength when fighting City-State units and cities") + && civInfo.hasUnique(UniqueType.StrengthBonusVsCityStates) ) modifiers["vs [City-States]"] = 30 } else if (combatant is CityCombatant) { diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index 70e214294e..6c3dedd282 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -378,7 +378,7 @@ class TechManager { } private fun updateTransientBooleans() { - wayfinding = civInfo.hasUnique("Can embark and move over Coasts and Oceans immediately") + wayfinding = civInfo.hasUnique(UniqueType.EmbarkAndEnterOcean) unitsCanEmbark = wayfinding || civInfo.hasUnique(UniqueType.LandUnitEmbarkation) embarkedUnitsCanEnterOcean = wayfinding || civInfo.hasUnique(UniqueType.EmbarkedUnitsMayEnterOcean) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 23cc3fd324..f5e23a9de5 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -241,6 +241,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: EnablesConstructionOfSpaceshipParts("Enables construction of Spaceship parts", UniqueTarget.Global), + NotifiedOfBarbarianEncampments("Notified of new Barbarian encampments", UniqueTarget.Global), + EnablesOpenBorders("Enables Open Borders agreements", UniqueTarget.Global), // Should the 'R' in 'Research agreements' be capitalized? EnablesResearchAgreements("Enables Research agreements", UniqueTarget.Global), @@ -282,6 +284,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: // ToDo: make per unit and use unit filters? LandUnitEmbarkation("Enables embarkation for land units", UniqueTarget.Global), EmbarkedUnitsMayEnterOcean("Enables embarked units to enter ocean tiles", UniqueTarget.Global), + // todo: Should this be deprecated and replaces with the two above uniques? + EmbarkAndEnterOcean("Can embark and move over Coasts and Oceans immediately", UniqueTarget.Global), PopulationLossFromNukes("Population loss from nuclear attacks [amount]% [cityFilter]", UniqueTarget.Global), @Deprecated("as of 3.19.2", ReplaceWith("Population loss from nuclear attacks [-amount]% [in this city]")) @@ -365,6 +369,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: Strength("[amount]% Strength", UniqueTarget.Unit, UniqueTarget.Global), StrengthNearCapital("[amount]% Strength decreasing with distance from the capital", UniqueTarget.Unit, UniqueTarget.Global), FlankAttackBonus("[amount]% to Flank Attack bonuses", UniqueTarget.Unit, UniqueTarget.Global), + // There's currently no conditional that would allow you strength vs city-state *cities* and that's why this isn't deprecated yet + StrengthBonusVsCityStates("+30% Strength when fighting City-State units and cities", UniqueTarget.Global), Movement("[amount] Movement", UniqueTarget.Unit, UniqueTarget.Global), Sight("[amount] Sight", UniqueTarget.Unit, UniqueTarget.Global, UniqueTarget.Terrain), diff --git a/docs/uniques.md b/docs/uniques.md index b1eeb76b35..06490b8082 100644 --- a/docs/uniques.md +++ b/docs/uniques.md @@ -131,6 +131,9 @@ Example: "[20]% Production towards any buildings that already exist in the Capit Applicable to: Global, FollowerBelief +#### Tile yields from Natural Wonders doubled +Applicable to: Global + #### Military Units gifted from City-States start with [amount] XP Example: "Military Units gifted from City-States start with [20] XP" @@ -362,6 +365,22 @@ Example: "[20]% Culture cost of adopting new Policies" Applicable to: Global +#### Quantity of strategic resources produced by the empire +[amount]% +Example: "Quantity of strategic resources produced by the empire +[20]%" + +Applicable to: Global + +#### Double quantity of [resource] produced +Example: "Double quantity of [Iron] produced" + +Applicable to: Global + +#### Double Happiness from Natural Wonders +Applicable to: Global + +#### Enables construction of Spaceship parts +Applicable to: Global + #### Enables Open Borders agreements Applicable to: Global @@ -463,6 +482,9 @@ Example: "[20] Unit Supply per city" Applicable to: Global +#### Units in cities cost no Maintenance +Applicable to: Global + #### Rebel units may spawn Applicable to: Global @@ -634,11 +656,6 @@ Example: "[Wounded] units gain the [Shock I] promotion" Applicable to: Global -#### Quantity of strategic resources produced by the empire +[amount]% -Example: "Quantity of strategic resources produced by the empire +[20]%" - -Applicable to: Global - #### Provides the cheapest [stat] building in your first [amount] cities for free Example: "Provides the cheapest [Culture] building in your first [20] cities for free" @@ -838,6 +855,9 @@ Example: "Blast radius [20]" Applicable to: Unit +#### Ranged attacks may be performed over obstacles +Applicable to: Unit + #### Uncapturable Applicable to: Unit @@ -846,6 +866,9 @@ Example: "May withdraw before melee ([20]%)" Applicable to: Unit +#### Unable to capture cities +Applicable to: Unit + #### Can move after attacking Applicable to: Unit