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