diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index b397f3fb2d..a288e5d774 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -98,7 +98,9 @@ See also = Requires at least one of the following: = Requires all of the following: = Leads to [techName] = -Leads to: = +Leads to: = +Enables: = +Disables: = Current construction = Construction queue = diff --git a/core/src/com/unciv/models/ruleset/Policy.kt b/core/src/com/unciv/models/ruleset/Policy.kt index 9c5d74c814..d6746624ce 100644 --- a/core/src/com/unciv/models/ruleset/Policy.kt +++ b/core/src/com/unciv/models/ruleset/Policy.kt @@ -1,5 +1,6 @@ package com.unciv.models.ruleset +import com.unciv.models.ruleset.unique.StateForConditionals import com.unciv.models.ruleset.unique.UniqueFlag import com.unciv.models.ruleset.unique.UniqueTarget import com.unciv.models.ruleset.unique.UniqueType @@ -91,6 +92,41 @@ open class Policy : RulesetObject() { } } + fun isEnabledByPolicy(rulesetObject: IRulesetObject) = + rulesetObject.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any { it.conditionals.any { + it.type == UniqueType.ConditionalAfterPolicy && it.params[0] == name + } } + + val enabledBuildings = ruleset.buildings.values.filter { isEnabledByPolicy(it) } + val enabledUnits = ruleset.units.values.filter { isEnabledByPolicy(it) } + + if (enabledBuildings.isNotEmpty() || enabledUnits.isNotEmpty()){ + lineList += FormattedLine("Enables:") + for (building in enabledBuildings) + lineList += FormattedLine(building.name, link = building.makeLink(), indent = 1) + for (unit in enabledUnits) + lineList += FormattedLine(unit.name, link = unit.makeLink(), indent = 1) + } + + + fun isDisabledByPolicy(rulesetObject: IRulesetObject) = + rulesetObject.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any { it.conditionals.any { + it.type == UniqueType.ConditionalBeforePolicy && it.params[0] == name + } } + + + val disabledBuildings = ruleset.buildings.values.filter { isDisabledByPolicy(it) } + val disabledUnits = ruleset.units.values.filter { isDisabledByPolicy(it) } + + if (disabledBuildings.isNotEmpty() || disabledUnits.isNotEmpty()){ + lineList += FormattedLine("Disables:") + for (building in disabledBuildings) + lineList += FormattedLine(building.name, link = building.makeLink(), indent = 1) + for (unit in disabledUnits) + lineList += FormattedLine(unit.name, link = unit.makeLink(), indent = 1) + } + + if (uniques.isNotEmpty()) { lineList += FormattedLine() uniqueObjects.forEach { diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index 0eae1a4e08..eb2a5e888c 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -185,9 +185,9 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s state.civInfo != null && state.civInfo.tech.isResearched(condition.params[0]) UniqueType.ConditionalNoTech -> state.civInfo != null && !state.civInfo.tech.isResearched(condition.params[0]) - UniqueType.ConditionalPolicy -> + UniqueType.ConditionalAfterPolicy -> state.civInfo != null && state.civInfo.policies.isAdopted(condition.params[0]) - UniqueType.ConditionalNoPolicy -> + UniqueType.ConditionalBeforePolicy -> state.civInfo != null && !state.civInfo.policies.isAdopted(condition.params[0]) UniqueType.ConditionalBeforePantheon -> state.civInfo != null && state.civInfo.religionManager.religionState == ReligionState.None diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt index 014991446f..3888551380 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt @@ -452,7 +452,7 @@ enum class UniqueParameterType( } }, - /** [UniqueType.ConditionalPolicy] and others, no central implementation */ + /** [UniqueType.ConditionalAfterPolicy] and others, no central implementation */ Policy("policy", "Oligarchy", "The name of any policy") { override fun getErrorSeverity( parameterText: String, diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index bf90bd6422..c12ca2b252 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -606,8 +606,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: ConditionalTech("after discovering [tech]", UniqueTarget.Conditional), ConditionalNoTech("before discovering [tech]", UniqueTarget.Conditional), - ConditionalPolicy("after adopting [policy]", UniqueTarget.Conditional), - ConditionalNoPolicy("before adopting [policy]", UniqueTarget.Conditional), + ConditionalAfterPolicy("after adopting [policy]", UniqueTarget.Conditional), + ConditionalBeforePolicy("before adopting [policy]", UniqueTarget.Conditional), ConditionalBeforePantheon("before founding a Pantheon", UniqueTarget.Conditional), ConditionalAfterPantheon("after founding a Pantheon", UniqueTarget.Conditional),