mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Add if no other Civilization has adopted [policy/belief]
Conditional
This commit is contained in:
parent
d51ef24c20
commit
0f62ec2fa5
@ -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() =
|
||||
|
@ -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 ->
|
||||
|
@ -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),
|
||||
|
||||
|
@ -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]>"
|
||||
|
||||
|
@ -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(
|
||||
"<if no Civilization has adopted [Oligarchy]>" to 1,
|
||||
"<if no Civilization has adopted [Tradition]>" to 0,
|
||||
"<if no Civilization has adopted [God of Craftsman]>" to 1,
|
||||
"<if no Civilization has adopted [Ancestor Worship]>" to 0,
|
||||
"<if no Civilization has adopted [Not A Belief]>" 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user