From 879a5b230f1b53f9728c9724647b8bda94ddcbb5 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 16 Jan 2023 13:05:11 +0200 Subject: [PATCH] Resolved #8387 - Fixed Reliquary belief Got rid of multiple uniques with the same text --- .../automation/civilization/ReligionAutomation.kt | 2 +- core/src/com/unciv/logic/map/MapUnit.kt | 2 +- core/src/com/unciv/models/Religion.kt | 8 +++++--- .../com/unciv/models/ruleset/unique/UniqueType.kt | 6 +----- docs/Modders/uniques.md | 13 ------------- tests/src/com/unciv/uniques/UniqueErrorTests.kt | 15 +++++++++++++++ 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/core/src/com/unciv/logic/automation/civilization/ReligionAutomation.kt b/core/src/com/unciv/logic/automation/civilization/ReligionAutomation.kt index c08135b502..eec34ecf59 100644 --- a/core/src/com/unciv/logic/automation/civilization/ReligionAutomation.kt +++ b/core/src/com/unciv/logic/automation/civilization/ReligionAutomation.kt @@ -370,7 +370,7 @@ object ReligionAutomation { unique.stats.values.sum() UniqueType.StatsFromGlobalFollowers -> 4f * (unique.stats.values.sum() / unique.params[1].toFloat()) - UniqueType.StatsSpendingGreatPeople -> + UniqueType.ProvidesStatsWheneverGreatPersonExpended -> unique.stats.values.sum() / 2f UniqueType.Strength -> unique.params[0].toFloat() / 4f diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index fe360c9e3c..2ab86e4a5b 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -341,7 +341,7 @@ class MapUnit : IsPartOfGameInfoSerialization { hasStrengthBonusInRadiusUnique = hasUnique(UniqueType.StrengthBonusInRadius) hasCitadelPlacementUnique = getMatchingUniques(UniqueType.ConstructImprovementConsumingUnit) .mapNotNull { civInfo.gameInfo.ruleSet.tileImprovements[it.params[0]] } - .any { it.hasUnique(UniqueType.TakeOverTilesAroundWhenBuilt) } + .any { it.hasUnique(UniqueType.TakesOverAdjacentTiles) } } fun copyStatisticsTo(newUnit: MapUnit) { diff --git a/core/src/com/unciv/models/Religion.kt b/core/src/com/unciv/models/Religion.kt index a48b9b87ae..91233f3b00 100644 --- a/core/src/com/unciv/models/Religion.kt +++ b/core/src/com/unciv/models/Religion.kt @@ -4,9 +4,9 @@ import com.unciv.logic.GameInfo import com.unciv.logic.IsPartOfGameInfoSerialization import com.unciv.models.ruleset.Belief import com.unciv.models.ruleset.BeliefType +import com.unciv.models.ruleset.unique.Unique import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.stats.INamed -import com.unciv.models.stats.Stat /** Data object for Religions */ class Religion() : INamed, IsPartOfGameInfoSerialization { @@ -85,8 +85,10 @@ class Religion() : INamed, IsPartOfGameInfoSerialization { mapToExistingBeliefs(founderBeliefs).asSequence().filter { it.type == BeliefType.Enhancer } } - private fun getUniquesOfBeliefs(beliefs: HashSet) = - mapToExistingBeliefs(beliefs).asSequence().flatMap { it.uniqueObjects } + private fun getUniquesOfBeliefs(beliefs: HashSet): Sequence { + val result = mapToExistingBeliefs(beliefs).asSequence().flatMap { it.uniqueObjects } + return result + } fun getFollowerUniques() = getUniquesOfBeliefs(followerBeliefs) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 424a0cc983..14e99d1dc0 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -156,8 +156,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global), StatsWhenAdoptingReligionSpeed("[stats] when a city adopts this religion for the first time (modified by game speed)", UniqueTarget.Global), StatsWhenAdoptingReligion("[stats] when a city adopts this religion for the first time", UniqueTarget.Global), - StatsSpendingGreatPeople("[stats] whenever a Great Person is expended", UniqueTarget.Global), - UnhappinessFromPopulationTypePercentageChange("[relativeAmount]% Unhappiness from [populationFilter] [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), FoodConsumptionBySpecialists("[relativeAmount]% Food consumption by specialists [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), @@ -233,7 +231,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: GainInfluenceWithUnitGiftToCityState("Gain [amount] Influence with a [baseUnitFilter] gift to a City-State", UniqueTarget.Global), FaithCostOfGreatProphetChange("[relativeAmount]% Faith cost of generating Great Prophet equivalents", UniqueTarget.Global), RestingPointOfCityStatesFollowingReligionChange("Resting point for Influence with City-States following this religion [amount]", UniqueTarget.Global), - StatBonusPercentFromCityStates("[relativeAmount]% [stat] from City-States", UniqueTarget.Global), ProvidesGoldWheneverGreatPersonExpended("Provides a sum of gold each time you spend a Great Person", UniqueTarget.Global), ProvidesStatsWheneverGreatPersonExpended("[stats] whenever a Great Person is expended", UniqueTarget.Global), @@ -570,7 +567,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: //@Deprecated("as of 4.3.9", ReplaceWith("Costs [amount] [stats] per turn when in your territory"), DeprecationLevel.ERROR) OldImprovementMaintenance("Costs [amount] gold per turn when in your territory", UniqueTarget.Improvement), // unused DamagesAdjacentEnemyUnits("Adjacent enemy units ending their turn take [amount] damage", UniqueTarget.Improvement), - TakeOverTilesAroundWhenBuilt("Constructing it will take over the tiles around it and assign them to your closest city", UniqueTarget.Improvement), GreatImprovement("Great Improvement", UniqueTarget.Improvement), IsAncientRuinsEquivalent("Provides a random bonus when entered", UniqueTarget.Improvement), @@ -828,7 +824,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: @Deprecated("as of 3.19.2", ReplaceWith("[amount]% Food is carried over after population increases [cityFilter]"), DeprecationLevel.ERROR) CarryOverFoodAlsoDeprecated("[amount]% of food is carried over [cityFilter] after population increases", UniqueTarget.Global, UniqueTarget.FollowerBelief), @Deprecated("as of 3.19.2", ReplaceWith("[amount]% Culture cost of natural border growth [cityFilter]"), DeprecationLevel.ERROR) - BorderGrowthPercentageWithoutPercentageSign("[amount]% Culture cost of natural border growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), + BorderGrowthPercentageWithoutPercentageSign("[amount] Culture cost of natural border growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), @Deprecated("as of 3.19.1", ReplaceWith("[-amount]% Culture cost of natural border growth [cityFilter]"), DeprecationLevel.ERROR) DecreasedAcquiringTilesCost("-[amount]% Culture cost of acquiring tiles [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), @Deprecated("as of 3.19.1", ReplaceWith("[amount]% Culture cost of natural border growth [in all cities]"), DeprecationLevel.ERROR) diff --git a/docs/Modders/uniques.md b/docs/Modders/uniques.md index 26712087c8..0797f3fd2e 100644 --- a/docs/Modders/uniques.md +++ b/docs/Modders/uniques.md @@ -297,11 +297,6 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl Applicable to: Global -??? example "[stats] whenever a Great Person is expended" - Example: "[+1 Gold, +2 Production] whenever a Great Person is expended" - - Applicable to: Global - ??? example "[relativeAmount]% Unhappiness from [populationFilter] [cityFilter]" Example: "[+20]% Unhappiness from [Followers of this Religion] [in all cities]" @@ -533,11 +528,6 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl Applicable to: Global -??? example "[relativeAmount]% [stat] from City-States" - Example: "[+20]% [Culture] from City-States" - - Applicable to: Global - ??? example "Provides a sum of gold each time you spend a Great Person" Applicable to: Global @@ -1520,9 +1510,6 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl Applicable to: Improvement -??? example "Constructing it will take over the tiles around it and assign them to your closest city" - Applicable to: Improvement - ??? example "Great Improvement" Applicable to: Improvement diff --git a/tests/src/com/unciv/uniques/UniqueErrorTests.kt b/tests/src/com/unciv/uniques/UniqueErrorTests.kt index 94b8425674..32286922f9 100644 --- a/tests/src/com/unciv/uniques/UniqueErrorTests.kt +++ b/tests/src/com/unciv/uniques/UniqueErrorTests.kt @@ -1,6 +1,7 @@ package com.unciv.uniques import com.unciv.models.ruleset.RulesetCache +import com.unciv.models.ruleset.unique.UniqueType import com.unciv.testing.GdxTestRunner import org.junit.Test import org.junit.runner.RunWith @@ -8,6 +9,20 @@ import org.junit.runner.RunWith @RunWith(GdxTestRunner::class) class UniqueErrorTests { + @Test + fun testMultipleUniqueTypesSameText(){ + val textToUniqueType = HashMap() + var errors = false + for (uniqueType in UniqueType.values()){ + if (textToUniqueType.containsKey(uniqueType.placeholderText)){ + println("UniqueTypes ${uniqueType.name} and ${textToUniqueType[uniqueType.placeholderText]!!.name} have the same text!") + errors = true + } + else textToUniqueType[uniqueType.placeholderText] = uniqueType + } + assert(!errors) + } + @Test fun testCodependantTechs() { RulesetCache.loadRulesets()