mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 16:59:11 +07:00
Solved 'cannot start game' errors - 'always true' conditionals do not affect 'getMatchingUniques'
This commit is contained in:
@ -567,7 +567,7 @@ class City : IsPartOfGameInfoSerialization {
|
|||||||
getLocalMatchingUniques(uniqueType, stateForConditionals)
|
getLocalMatchingUniques(uniqueType, stateForConditionals)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLocalMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals? = null): Sequence<Unique> {
|
fun getLocalMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals = StateForConditionals(civ, this)): Sequence<Unique> {
|
||||||
return (
|
return (
|
||||||
cityConstructions.builtBuildingUniqueMap.getUniques(uniqueType).filter { !it.isAntiLocalEffect }
|
cityConstructions.builtBuildingUniqueMap.getUniques(uniqueType).filter { !it.isAntiLocalEffect }
|
||||||
+ religion.getUniques().filter { it.isOfType(uniqueType) }
|
+ religion.getUniques().filter { it.isOfType(uniqueType) }
|
||||||
|
@ -17,7 +17,7 @@ interface IHasUniques {
|
|||||||
|
|
||||||
fun getMatchingUniques(uniqueTemplate: String, stateForConditionals: StateForConditionals? = null): Sequence<Unique> {
|
fun getMatchingUniques(uniqueTemplate: String, stateForConditionals: StateForConditionals? = null): Sequence<Unique> {
|
||||||
val matchingUniques = uniqueMap[uniqueTemplate] ?: return sequenceOf()
|
val matchingUniques = uniqueMap[uniqueTemplate] ?: return sequenceOf()
|
||||||
return matchingUniques.asSequence().filter { it.conditionalsApply(stateForConditionals) }
|
return matchingUniques.asSequence().filter { it.conditionalsApply(stateForConditionals ?: StateForConditionals()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals? = null) =
|
fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals? = null) =
|
||||||
|
@ -48,8 +48,7 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
|
|||||||
return conditionalsApply(StateForConditionals(civInfo, city))
|
return conditionalsApply(StateForConditionals(civInfo, city))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun conditionalsApply(state: StateForConditionals?): Boolean {
|
fun conditionalsApply(state: StateForConditionals = StateForConditionals()): Boolean {
|
||||||
if (state == null) return conditionals.isEmpty()
|
|
||||||
if (state.ignoreConditionals) return true
|
if (state.ignoreConditionals) return true
|
||||||
for (condition in conditionals) {
|
for (condition in conditionals) {
|
||||||
if (!conditionalApplies(condition, state)) return false
|
if (!conditionalApplies(condition, state)) return false
|
||||||
|
@ -203,7 +203,9 @@ object UnitActions {
|
|||||||
|
|
||||||
return UnitAction(
|
return UnitAction(
|
||||||
type = UnitActionType.FoundCity,
|
type = UnitActionType.FoundCity,
|
||||||
title = actionTextWithSideEffects(UnitActionType.FoundCity.value, unique, unit),
|
title =
|
||||||
|
if (hasActionModifiers) actionTextWithSideEffects(UnitActionType.FoundCity.value, unique, unit)
|
||||||
|
else UnitActionType.FoundCity.value,
|
||||||
uncivSound = UncivSound.Chimes,
|
uncivSound = UncivSound.Chimes,
|
||||||
action = {
|
action = {
|
||||||
// check if we would be breaking a promise
|
// check if we would be breaking a promise
|
||||||
|
Reference in New Issue
Block a user