mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-03 21:40:31 +07:00
Fix: "Only available" not working properly for religions or transforming/upgrading units (#10012)
This commit is contained in:
parent
bb3335aaa8
commit
dcb50bbbf5
@ -41,6 +41,7 @@ import com.unciv.models.ruleset.PolicyBranch
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.models.ruleset.tech.Technology
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
@ -708,7 +709,8 @@ object NextTurnAutomation {
|
||||
(it.type == beliefType || beliefType == BeliefType.Any)
|
||||
&& !additionalBeliefsToExclude.contains(it)
|
||||
&& civInfo.religionManager.getReligionWithBelief(it) == null
|
||||
&& it.getMatchingUniques(UniqueType.OnlyAvailableWhen).none { unique -> !unique.conditionalsApply(civInfo) }
|
||||
&& it.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals)
|
||||
.none { unique -> !unique.conditionalsApply(civInfo) }
|
||||
}
|
||||
.maxByOrNull { ReligionAutomation.rateBelief(civInfo, it) }
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class UnitUpgradeManager(val unit:MapUnit) {
|
||||
fun isInvalidUpgradeDestination(baseUnit: BaseUnit): Boolean{
|
||||
if (baseUnit.requiredTech != null && !unit.civ.tech.isResearched(baseUnit.requiredTech!!))
|
||||
return true
|
||||
if (baseUnit.getMatchingUniques(UniqueType.OnlyAvailableWhen).any {
|
||||
if (baseUnit.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any {
|
||||
!it.conditionalsApply(StateForConditionals(unit.civ, unit = unit ))
|
||||
}) return true
|
||||
return false
|
||||
|
@ -3,6 +3,8 @@ package com.unciv.ui.screens.pickerscreens
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.models.ruleset.Belief
|
||||
import com.unciv.models.ruleset.BeliefType
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.translations.tr
|
||||
|
||||
class PantheonPickerScreen(
|
||||
@ -17,7 +19,9 @@ class PantheonPickerScreen(
|
||||
for (belief in ruleset.beliefs.values) {
|
||||
if (belief.type != BeliefType.Pantheon) continue
|
||||
val beliefButton = getBeliefButton(belief, withTypeLabel = false)
|
||||
if (choosingCiv.religionManager.getReligionWithBelief(belief) == null) {
|
||||
if (choosingCiv.religionManager.getReligionWithBelief(belief) == null
|
||||
&& belief.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals)
|
||||
.none { !it.conditionalsApply(choosingCiv) }) {
|
||||
beliefButton.onClickSelect(selection, belief) {
|
||||
selectedPantheon = belief
|
||||
pick("Follow [${belief.name}]".tr())
|
||||
|
@ -11,6 +11,7 @@ import com.unciv.models.Counter
|
||||
import com.unciv.models.Religion
|
||||
import com.unciv.models.ruleset.Belief
|
||||
import com.unciv.models.ruleset.BeliefType
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.components.AutoScrollPane
|
||||
@ -219,8 +220,10 @@ class ReligiousBeliefsPickerScreen (
|
||||
// The Belief is not available because someone already has it
|
||||
beliefButton.disable(redDisableColor)
|
||||
}
|
||||
belief.getMatchingUniques(UniqueType.OnlyAvailableWhen).any { !it.conditionalsApply(choosingCiv) } ->
|
||||
beliefButton.disable(redDisableColor) // Blocked
|
||||
belief.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals)
|
||||
.any { !it.conditionalsApply(choosingCiv) } ->
|
||||
// The Belief is blocked
|
||||
beliefButton.disable(redDisableColor)
|
||||
|
||||
else ->
|
||||
beliefButton.onClickSelect(rightSelection, belief) {
|
||||
|
@ -333,7 +333,7 @@ object UnitActions {
|
||||
for (unique in unit.baseUnit().getMatchingUniques(UniqueType.CanTransform, stateForConditionals)) {
|
||||
val unitToTransformTo = civInfo.getEquivalentUnit(unique.params[0])
|
||||
|
||||
if (unitToTransformTo.getMatchingUniques(UniqueType.OnlyAvailableWhen)
|
||||
if (unitToTransformTo.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals)
|
||||
.any { !it.conditionalsApply(stateForConditionals) })
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user