mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
modding: 'Only available when' applies to beliefs
This commit is contained in:
parent
9201ea2cfa
commit
e5452f5605
@ -601,13 +601,13 @@ object NextTurnAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseBeliefOfType(civInfo: Civilization, beliefType: BeliefType, additionalBeliefsToExclude: HashSet<Belief> = hashSetOf()): Belief? {
|
private fun chooseBeliefOfType(civInfo: Civilization, beliefType: BeliefType, additionalBeliefsToExclude: HashSet<Belief> = hashSetOf()): Belief? {
|
||||||
return civInfo.gameInfo.ruleset.beliefs
|
return civInfo.gameInfo.ruleset.beliefs.values
|
||||||
.filter {
|
.filter {
|
||||||
(it.value.type == beliefType || beliefType == BeliefType.Any)
|
(it.type == beliefType || beliefType == BeliefType.Any)
|
||||||
&& !additionalBeliefsToExclude.contains(it.value)
|
&& !additionalBeliefsToExclude.contains(it)
|
||||||
&& civInfo.religionManager.getReligionWithBelief(it.value) == null
|
&& civInfo.religionManager.getReligionWithBelief(it) == null
|
||||||
|
&& it.getMatchingUniques(UniqueType.OnlyAvailableWhen).none { !it.conditionalsApply(civInfo) }
|
||||||
}
|
}
|
||||||
.map { it.value }
|
|
||||||
.maxByOrNull { ReligionAutomation.rateBelief(civInfo, it) }
|
.maxByOrNull { ReligionAutomation.rateBelief(civInfo, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
|||||||
HiddenBeforeAmountPolicies("Hidden until [amount] social policy branches have been completed", UniqueTarget.Building, UniqueTarget.Unit),
|
HiddenBeforeAmountPolicies("Hidden until [amount] social policy branches have been completed", UniqueTarget.Building, UniqueTarget.Unit),
|
||||||
// Meant to be used together with conditionals, like "Only available <after adopting [policy]> <while the empire is happy>"
|
// Meant to be used together with conditionals, like "Only available <after adopting [policy]> <while the empire is happy>"
|
||||||
OnlyAvailableWhen("Only available", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Improvement,
|
OnlyAvailableWhen("Only available", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Improvement,
|
||||||
UniqueTarget.Policy, UniqueTarget.Tech, UniqueTarget.Promotion, UniqueTarget.Ruins),
|
UniqueTarget.Policy, UniqueTarget.Tech, UniqueTarget.Promotion, UniqueTarget.Ruins, UniqueTarget.FollowerBelief, UniqueTarget.FounderBelief),
|
||||||
|
|
||||||
ConvertFoodToProductionWhenConstructed("Excess Food converted to Production when under construction", UniqueTarget.Building, UniqueTarget.Unit),
|
ConvertFoodToProductionWhenConstructed("Excess Food converted to Production when under construction", UniqueTarget.Building, UniqueTarget.Unit),
|
||||||
RequiresPopulation("Requires at least [amount] population", UniqueTarget.Building, UniqueTarget.Unit),
|
RequiresPopulation("Requires at least [amount] population", UniqueTarget.Building, UniqueTarget.Unit),
|
||||||
|
@ -25,7 +25,7 @@ import com.unciv.ui.components.extensions.onClick
|
|||||||
import com.unciv.ui.components.extensions.toLabel
|
import com.unciv.ui.components.extensions.toLabel
|
||||||
|
|
||||||
abstract class ReligionPickerScreenCommon(
|
abstract class ReligionPickerScreenCommon(
|
||||||
private val choosingCiv: Civilization,
|
protected val choosingCiv: Civilization,
|
||||||
disableScroll: Boolean = false
|
disableScroll: Boolean = false
|
||||||
) : PickerScreen(disableScroll) {
|
) : PickerScreen(disableScroll) {
|
||||||
|
|
||||||
|
@ -10,9 +10,8 @@ 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.UniqueType
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.images.ImageGetter
|
|
||||||
import com.unciv.ui.popups.AskTextPopup
|
|
||||||
import com.unciv.ui.components.AutoScrollPane
|
import com.unciv.ui.components.AutoScrollPane
|
||||||
import com.unciv.ui.components.extensions.addSeparator
|
import com.unciv.ui.components.extensions.addSeparator
|
||||||
import com.unciv.ui.components.extensions.addSeparatorVertical
|
import com.unciv.ui.components.extensions.addSeparatorVertical
|
||||||
@ -21,10 +20,12 @@ import com.unciv.ui.components.extensions.enable
|
|||||||
import com.unciv.ui.components.extensions.onClick
|
import com.unciv.ui.components.extensions.onClick
|
||||||
import com.unciv.ui.components.extensions.packIfNeeded
|
import com.unciv.ui.components.extensions.packIfNeeded
|
||||||
import com.unciv.ui.components.extensions.surroundWithCircle
|
import com.unciv.ui.components.extensions.surroundWithCircle
|
||||||
|
import com.unciv.ui.images.ImageGetter
|
||||||
|
import com.unciv.ui.popups.AskTextPopup
|
||||||
|
|
||||||
class ReligiousBeliefsPickerScreen (
|
class ReligiousBeliefsPickerScreen (
|
||||||
choosingCiv: Civilization,
|
choosingCiv: Civilization,
|
||||||
newBeliefsToChoose: Counter<BeliefType>,
|
numberOfBeliefsCanChoose: Counter<BeliefType>,
|
||||||
pickIconAndName: Boolean
|
pickIconAndName: Boolean
|
||||||
): ReligionPickerScreenCommon(choosingCiv, disableScroll = true) {
|
): ReligionPickerScreenCommon(choosingCiv, disableScroll = true) {
|
||||||
// Roughly follows the layout of the original (although I am not very good at UI designing, so please improve this)
|
// Roughly follows the layout of the original (although I am not very good at UI designing, so please improve this)
|
||||||
@ -44,7 +45,7 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
// One entry per new Belief to choose - the left side will offer these below the choices from earlier in the game
|
// One entry per new Belief to choose - the left side will offer these below the choices from earlier in the game
|
||||||
class BeliefToChoose(val type: BeliefType, var belief: Belief? = null)
|
class BeliefToChoose(val type: BeliefType, var belief: Belief? = null)
|
||||||
private val beliefsToChoose: Array<BeliefToChoose> =
|
private val beliefsToChoose: Array<BeliefToChoose> =
|
||||||
newBeliefsToChoose.flatMap { entry -> (0 until entry.value).map { BeliefToChoose(entry.key) } }.toTypedArray()
|
numberOfBeliefsCanChoose.flatMap { entry -> (0 until entry.value).map { BeliefToChoose(entry.key) } }.toTypedArray()
|
||||||
|
|
||||||
private var leftSelection = Selection()
|
private var leftSelection = Selection()
|
||||||
private var leftSelectedIndex = -1
|
private var leftSelectedIndex = -1
|
||||||
@ -193,8 +194,10 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
rightBeliefsToChoose.clear()
|
rightBeliefsToChoose.clear()
|
||||||
rightSelection.clear()
|
rightSelection.clear()
|
||||||
val availableBeliefs = ruleset.beliefs.values
|
val availableBeliefs = ruleset.beliefs.values
|
||||||
.filter { (it.type == beliefType || beliefType == BeliefType.Any) }
|
.filter { it.type == beliefType || beliefType == BeliefType.Any }
|
||||||
|
|
||||||
val civReligionManager = currentReligion.getFounder().religionManager
|
val civReligionManager = currentReligion.getFounder().religionManager
|
||||||
|
|
||||||
for (belief in availableBeliefs) {
|
for (belief in availableBeliefs) {
|
||||||
val beliefButton = getBeliefButton(belief)
|
val beliefButton = getBeliefButton(belief)
|
||||||
when {
|
when {
|
||||||
@ -213,6 +216,9 @@ 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) } ->
|
||||||
|
beliefButton.disable(redDisableColor) // Blocked
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
beliefButton.onClickSelect(rightSelection, belief) {
|
beliefButton.onClickSelect(rightSelection, belief) {
|
||||||
beliefsToChoose[leftButtonIndex].belief = belief
|
beliefsToChoose[leftButtonIndex].belief = belief
|
||||||
|
@ -881,7 +881,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
|||||||
Applicable to: Tech
|
Applicable to: Tech
|
||||||
|
|
||||||
??? example "Only available"
|
??? example "Only available"
|
||||||
Applicable to: Tech, Policy, Building, Unit, Promotion, Improvement, Ruins
|
Applicable to: Tech, Policy, FounderBelief, FollowerBelief, Building, Unit, Promotion, Improvement, Ruins
|
||||||
|
|
||||||
??? example "Cannot be hurried"
|
??? example "Cannot be hurried"
|
||||||
Applicable to: Tech, Building
|
Applicable to: Tech, Building
|
||||||
|
Loading…
x
Reference in New Issue
Block a user