"before adopting / after adopting" uniques accept belief as well as policy - #3242

This commit is contained in:
Yair Morgenstern 2023-06-07 10:21:12 +03:00
parent e44af219eb
commit edccbf6273
4 changed files with 10 additions and 8 deletions

View File

@ -94,7 +94,7 @@ open class Policy : RulesetObject() {
fun isEnabledByPolicy(rulesetObject: IRulesetObject) = fun isEnabledByPolicy(rulesetObject: IRulesetObject) =
rulesetObject.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any { it.conditionals.any { rulesetObject.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any { it.conditionals.any {
it.type == UniqueType.ConditionalAfterPolicy && it.params[0] == name it.type == UniqueType.ConditionalAfterPolicyOrBelief && it.params[0] == name
} } } }
val enabledBuildings = ruleset.buildings.values.filter { isEnabledByPolicy(it) } val enabledBuildings = ruleset.buildings.values.filter { isEnabledByPolicy(it) }
@ -111,7 +111,7 @@ open class Policy : RulesetObject() {
fun isDisabledByPolicy(rulesetObject: IRulesetObject) = fun isDisabledByPolicy(rulesetObject: IRulesetObject) =
rulesetObject.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any { it.conditionals.any { rulesetObject.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any { it.conditionals.any {
it.type == UniqueType.ConditionalBeforePolicy && it.params[0] == name it.type == UniqueType.ConditionalBeforePolicyOrBelief && it.params[0] == name
} } } }

View File

@ -190,10 +190,12 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
state.civInfo != null && state.civInfo.tech.isResearched(condition.params[0]) state.civInfo != null && state.civInfo.tech.isResearched(condition.params[0])
UniqueType.ConditionalNoTech -> UniqueType.ConditionalNoTech ->
state.civInfo != null && !state.civInfo.tech.isResearched(condition.params[0]) state.civInfo != null && !state.civInfo.tech.isResearched(condition.params[0])
UniqueType.ConditionalAfterPolicy -> UniqueType.ConditionalAfterPolicyOrBelief ->
state.civInfo != null && state.civInfo.policies.isAdopted(condition.params[0]) state.civInfo != null && (state.civInfo.policies.isAdopted(condition.params[0])
UniqueType.ConditionalBeforePolicy -> || state.civInfo.religionManager.religion?.hasBelief(condition.params[0]) == true)
UniqueType.ConditionalBeforePolicyOrBelief ->
state.civInfo != null && !state.civInfo.policies.isAdopted(condition.params[0]) state.civInfo != null && !state.civInfo.policies.isAdopted(condition.params[0])
&& state.civInfo.religionManager.religion?.hasBelief(condition.params[0]) != true
UniqueType.ConditionalBeforePantheon -> UniqueType.ConditionalBeforePantheon ->
state.civInfo != null && state.civInfo.religionManager.religionState == ReligionState.None state.civInfo != null && state.civInfo.religionManager.religionState == ReligionState.None
UniqueType.ConditionalAfterPantheon -> UniqueType.ConditionalAfterPantheon ->

View File

@ -461,7 +461,7 @@ enum class UniqueParameterType(
} }
}, },
/** [UniqueType.ConditionalAfterPolicy] and others, no central implementation */ /** [UniqueType.ConditionalAfterPolicyOrBelief] and others, no central implementation */
Policy("policy", "Oligarchy", "The name of any policy") { Policy("policy", "Oligarchy", "The name of any policy") {
override fun getErrorSeverity( override fun getErrorSeverity(
parameterText: String, parameterText: String,

View File

@ -654,8 +654,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
ConditionalTech("after discovering [tech]", UniqueTarget.Conditional), ConditionalTech("after discovering [tech]", UniqueTarget.Conditional),
ConditionalNoTech("before discovering [tech]", UniqueTarget.Conditional), ConditionalNoTech("before discovering [tech]", UniqueTarget.Conditional),
ConditionalAfterPolicy("after adopting [policy]", UniqueTarget.Conditional), ConditionalAfterPolicyOrBelief("after adopting [policy/belief]", UniqueTarget.Conditional),
ConditionalBeforePolicy("before adopting [policy]", UniqueTarget.Conditional), ConditionalBeforePolicyOrBelief("before adopting [policy/belief]", UniqueTarget.Conditional),
ConditionalBeforePantheon("before founding a Pantheon", UniqueTarget.Conditional), ConditionalBeforePantheon("before founding a Pantheon", UniqueTarget.Conditional),
ConditionalAfterPantheon("after founding a Pantheon", UniqueTarget.Conditional), ConditionalAfterPantheon("after founding a Pantheon", UniqueTarget.Conditional),