diff --git a/core/src/com/unciv/models/Religion.kt b/core/src/com/unciv/models/Religion.kt index e88938598a..64c23426fa 100644 --- a/core/src/com/unciv/models/Religion.kt +++ b/core/src/com/unciv/models/Religion.kt @@ -71,6 +71,7 @@ class Religion() : INamed, IsPartOfGameInfoSerialization { } fun addBelief(belief: Belief) = addBeliefs(listOf(belief)) + fun addBelief(beliefName: String) = gameInfo.ruleset.beliefs[beliefName]?.let { addBelief(it) } @Readonly fun getIconName() = diff --git a/core/src/com/unciv/models/ruleset/unique/Conditionals.kt b/core/src/com/unciv/models/ruleset/unique/Conditionals.kt index 83b855056c..2045f3c4c6 100644 --- a/core/src/com/unciv/models/ruleset/unique/Conditionals.kt +++ b/core/src/com/unciv/models/ruleset/unique/Conditionals.kt @@ -170,7 +170,13 @@ object Conditionals { else tech.researchedTechnologies.none { it.matchesFilter(filter) } } UniqueType.ConditionalWhileResearching -> checkOnCiv { tech.currentTechnology()?.matchesFilter(conditional.params[0]) == true } - + UniqueType.ConditionalNoCivAdopted -> checkOnGameInfo { + civilizations.none { + it.isMajorCiv() && + it.isAlive() && + (it.policies.isAdopted(conditional.params[0]) || it.religionManager.religion?.hasBelief(conditional.params[0]) == true) + } + } UniqueType.ConditionalAfterPolicyOrBelief -> checkOnCiv { policies.isAdopted(conditional.params[0]) || religionManager.religion?.hasBelief(conditional.params[0]) == true } UniqueType.ConditionalBeforePolicyOrBelief -> diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 9350b9cb39..9c31ce03d9 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -719,6 +719,7 @@ enum class UniqueType( docDescription = "This condition is fulfilled while the technology is actively being researched (it is the one research points are added to)"), ConditionalFirstCivToAdopt("if no other Civilization has adopted this", UniqueTarget.Conditional), + ConditionalNoCivAdopted("if no Civilization has adopted [policy/belief]", UniqueTarget.Conditional), ConditionalAfterPolicyOrBelief("after adopting [policy/belief]", UniqueTarget.Conditional), ConditionalBeforePolicyOrBelief("before adopting [policy/belief]", UniqueTarget.Conditional), diff --git a/docs/Modders/uniques.md b/docs/Modders/uniques.md index 89f7bf9874..99edbf1cbf 100644 --- a/docs/Modders/uniques.md +++ b/docs/Modders/uniques.md @@ -3303,6 +3303,11 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl ??? example "<if no other Civilization has adopted this>" Applicable to: Conditional +??? example "<if no Civilization has adopted [policy/belief]>" + Example: "<if no Civilization has adopted [Oligarchy]>" + + Applicable to: Conditional + ??? example "<after adopting [policy/belief]>" Example: "<after adopting [Oligarchy]>" diff --git a/tests/src/com/unciv/uniques/GlobalUniquesTests.kt b/tests/src/com/unciv/uniques/GlobalUniquesTests.kt index cae9a6f617..31f98153cb 100644 --- a/tests/src/com/unciv/uniques/GlobalUniquesTests.kt +++ b/tests/src/com/unciv/uniques/GlobalUniquesTests.kt @@ -661,6 +661,37 @@ class GlobalUniquesTests { } } + @Test + fun conditionalFirstCivToAdopt() { + val civInfo = game.addCiv() + val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true) + // Policy + civInfo.policies.run { + freePolicies++ + adopt(getPolicyByName("Tradition")) + } + // Belief + game.addReligion(civInfo) + civInfo.religionManager.religion?.run { + addBelief("Ancestor Worship") + addBelief("Not A Belief") + } + val tests = listOf( + "" to 1, + "" to 0, + "" to 1, + "" to 0, + "" to 1, + ) + Assert.assertEquals(civInfo.gold, 0) + for ((test, expected) in tests) { + val building = game.createBuilding("Gain [1] [Gold] $test") + city.cityConstructions.addBuilding(building) + Assert.assertEquals("Conditional `$test` should be: $expected", civInfo.gold, expected) + civInfo.addGold(-civInfo.gold) // Reset the gold + } + } + // endregion // region Great Persons