mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 21:35:14 -04:00
Fix issues from gaining free beliefs (#9764)
* Fix issues from gaining free beliefs * chooseBeliefs code I forgot * Revert changes to next turn actions and allow for free beliefs while founding/expanding * Missed a spot
This commit is contained in:
parent
1ca9766811
commit
b37aaeb3c6
@ -286,6 +286,37 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
|
||||
fun mayEnhanceReligionAtAll(prophet: MapUnit): Boolean {
|
||||
if (!civInfo.gameInfo.isReligionEnabled()) return false // No religion, no enhancing
|
||||
if (religion == null) return false // First found a pantheon
|
||||
if (religionState != ReligionState.Religion) return false // First found an actual religion
|
||||
// Already used its power for other things
|
||||
if (prophet.abilityUsesLeft.any { it.value != prophet.maxAbilityUses[it.key] }) return false
|
||||
if (!civInfo.isMajorCiv()) return false // Only major civs
|
||||
|
||||
if (numberOfBeliefsAvailable(BeliefType.Follower) == 0)
|
||||
return false // Mod maker did not provide enough follower beliefs
|
||||
|
||||
if (numberOfBeliefsAvailable(BeliefType.Enhancer) == 0)
|
||||
return false // Mod maker did not provide enough enhancer beliefs
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun mayEnhanceReligionNow(prophet: MapUnit): Boolean {
|
||||
if (!mayEnhanceReligionAtAll(prophet)) return false
|
||||
if (!prophet.getTile().isCityCenter()) return false
|
||||
return true
|
||||
}
|
||||
|
||||
fun useProphetForEnhancingReligion(prophet: MapUnit) {
|
||||
if (!mayEnhanceReligionNow(prophet)) return // How did you do this?
|
||||
religionState = ReligionState.EnhancingReligion
|
||||
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnhancingReligion))
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unifies the selection of what beliefs are available for when a great prophet is expended. Also
|
||||
* accounts for the number of remaining beliefs of each type so that the player is not given a
|
||||
@ -317,7 +348,8 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
if (enhancingReligion) {
|
||||
chooseBeliefToAdd(BeliefType.Enhancer, 1)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
chooseBeliefToAdd(BeliefType.Founder, 1)
|
||||
if (shouldChoosePantheonBelief)
|
||||
chooseBeliefToAdd(BeliefType.Pantheon, 1)
|
||||
@ -334,6 +366,9 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
chooseBeliefToAdd(BeliefType.Any, unique.params[0].toInt())
|
||||
}
|
||||
|
||||
for (type in freeBeliefsAsEnums())
|
||||
chooseBeliefToAdd(type.key, type.value)
|
||||
|
||||
return beliefsToChoose
|
||||
}
|
||||
|
||||
@ -341,11 +376,13 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
fun getBeliefsToChooseAtEnhancing(): Counter<BeliefType> = getBeliefsToChooseAtProphetUse(true)
|
||||
|
||||
fun chooseBeliefs(beliefs: List<Belief>, useFreeBeliefs: Boolean = false) {
|
||||
// Remove the free beliefs in case we had them
|
||||
// Must be done first in case when gain more later
|
||||
freeBeliefs.clear()
|
||||
|
||||
when (religionState) {
|
||||
ReligionState.EnhancingReligion -> {
|
||||
religionState = ReligionState.EnhancedReligion
|
||||
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponEnhancingReligion))
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
}
|
||||
ReligionState.None -> {
|
||||
foundPantheon(beliefs[0].name, useFreeBeliefs)
|
||||
@ -371,20 +408,9 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
triggerNotificationText = "due to adopting [${belief.name}]")
|
||||
|
||||
for (belief in beliefs)
|
||||
for (unique in belief.uniqueObjects)
|
||||
for (unique in belief.uniqueObjects.filter { !it.hasTriggerConditional() })
|
||||
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
|
||||
|
||||
// decrement free beliefs if used
|
||||
if (useFreeBeliefs && hasFreeBeliefs()) {
|
||||
for (belief in beliefs) {
|
||||
freeBeliefs[belief.type.name] = max(freeBeliefs[belief.type.name] - 1, 0)
|
||||
}
|
||||
}
|
||||
// limit the number of free beliefs available to number of remaining beliefs even if player
|
||||
// didn't use free beliefs (e.g., used a prophet or pantheon)
|
||||
for (type in freeBeliefs.keys) {
|
||||
freeBeliefs[type] = min(freeBeliefs[type], numberOfBeliefsAvailable(BeliefType.valueOf(type)))
|
||||
}
|
||||
civInfo.updateStatsForNextTurn() // a belief can have an immediate effect on stats
|
||||
}
|
||||
|
||||
@ -414,34 +440,6 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
unit.religion = newReligion.name
|
||||
}
|
||||
|
||||
fun mayEnhanceReligionAtAll(prophet: MapUnit): Boolean {
|
||||
if (!civInfo.gameInfo.isReligionEnabled()) return false // No religion, no enhancing
|
||||
if (religion == null) return false // First found a pantheon
|
||||
if (religionState != ReligionState.Religion) return false // First found an actual religion
|
||||
// Already used its power for other things
|
||||
if (prophet.abilityUsesLeft.any { it.value != prophet.maxAbilityUses[it.key] }) return false
|
||||
if (!civInfo.isMajorCiv()) return false // Only major civs
|
||||
|
||||
if (numberOfBeliefsAvailable(BeliefType.Follower) == 0)
|
||||
return false // Mod maker did not provide enough follower beliefs
|
||||
|
||||
if (numberOfBeliefsAvailable(BeliefType.Enhancer) == 0)
|
||||
return false // Mod maker did not provide enough enhancer beliefs
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun mayEnhanceReligionNow(prophet: MapUnit): Boolean {
|
||||
if (!mayEnhanceReligionAtAll(prophet)) return false
|
||||
if (!prophet.getTile().isCityCenter()) return false
|
||||
return true
|
||||
}
|
||||
|
||||
fun useProphetForEnhancingReligion(prophet: MapUnit) {
|
||||
if (!mayEnhanceReligionNow(prophet)) return // How did you do this?
|
||||
religionState = ReligionState.EnhancingReligion
|
||||
}
|
||||
|
||||
fun maySpreadReligionAtAll(missionary: MapUnit): Boolean {
|
||||
if (!civInfo.isMajorCiv()) return false // Only major civs
|
||||
if (!civInfo.gameInfo.isReligionEnabled()) return false // No religion, no spreading
|
||||
|
Loading…
x
Reference in New Issue
Block a user