mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Civilopedia entry for policy links to units and buildings that it enables/disables
This commit is contained in:
parent
93d171fd4b
commit
2530039c80
@ -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 =
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user