mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-29 22:29:15 +07:00
Fix effect of new Beliefs not immediately visible in top bar (#6888)
* Fix effect of new Beliefs not immediately visible in top bar * Fix effect of new Beliefs not immediately visible - reviews
This commit is contained in:
@ -68,7 +68,7 @@ class ReligionManager {
|
||||
fun endTurn(faithFromNewTurn: Int) {
|
||||
storedFaith += faithFromNewTurn
|
||||
}
|
||||
|
||||
|
||||
fun isMajorityReligionForCiv(religion: Religion): Boolean {
|
||||
return civInfo.cities.count { it.religion.getMajorityReligion() == religion } >= civInfo.cities.size / 2
|
||||
}
|
||||
@ -82,7 +82,7 @@ class ReligionManager {
|
||||
if (!civInfo.isMajorCiv()) return false
|
||||
if (civInfo.gameInfo.ruleSet.beliefs.values.none { isPickablePantheonBelief(it) })
|
||||
return false
|
||||
if (civInfo.gameInfo.civilizations.any { it.religionManager.religionState == ReligionState.EnhancedReligion })
|
||||
if (civInfo.gameInfo.civilizations.any { it.religionManager.religionState == ReligionState.EnhancedReligion })
|
||||
return false
|
||||
return storedFaith >= faithForPantheon()
|
||||
}
|
||||
@ -98,17 +98,18 @@ class ReligionManager {
|
||||
religion!!.followerBeliefs.add(belief.name)
|
||||
civInfo.gameInfo.religions[belief.name] = religion!!
|
||||
for (city in civInfo.cities)
|
||||
city.religion.addPressure(belief.name, 200 * city.population.population)
|
||||
city.religion.addPressure(belief.name, 200 * city.population.population)
|
||||
religionState = ReligionState.Pantheon
|
||||
civInfo.updateStatsForNextTurn() // a belief can have an immediate effect on stats
|
||||
}
|
||||
|
||||
// https://www.reddit.com/r/civ/comments/2m82wu/can_anyone_detail_the_finer_points_of_great/
|
||||
// Game files (globaldefines.xml)
|
||||
fun faithForNextGreatProphet(): Int {
|
||||
val greatProphetsEarned = civInfo.civConstructions.boughtItemsWithIncreasingPrice[getGreatProphetEquivalent()!!] ?: 0
|
||||
|
||||
var faithCost =
|
||||
(200 + 100 * greatProphetsEarned * (greatProphetsEarned + 1) / 2f) *
|
||||
|
||||
var faithCost =
|
||||
(200 + 100 * greatProphetsEarned * (greatProphetsEarned + 1) / 2f) *
|
||||
civInfo.gameInfo.gameParameters.gameSpeed.modifier
|
||||
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.FaithCostOfGreatProphetChange))
|
||||
@ -126,14 +127,14 @@ class ReligionManager {
|
||||
if (civInfo.hasUnique(UniqueType.MayNotGenerateGreatProphet)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
fun getGreatProphetEquivalent(): String? {
|
||||
return civInfo.gameInfo.ruleSet.units.values.firstOrNull { it.hasUnique(UniqueType.MayFoundReligion) }?.name
|
||||
}
|
||||
|
||||
private fun generateProphet() {
|
||||
val prophetUnitName = getGreatProphetEquivalent() ?: return // No prophet units in this mod
|
||||
|
||||
|
||||
val prophetSpawnChange = (5f + storedFaith - faithForNextGreatProphet()) / 100f
|
||||
|
||||
if (Random(civInfo.gameInfo.turns).nextFloat() < prophetSpawnChange) {
|
||||
@ -146,12 +147,12 @@ class ReligionManager {
|
||||
civInfo.civConstructions.boughtItemsWithIncreasingPrice.add(prophetUnitName, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun amountOfFoundableReligions() = civInfo.gameInfo.civilizations.count { it.isMajorCiv() } / 2 + 1
|
||||
|
||||
fun mayFoundReligionAtAll(prophet: MapUnit): Boolean {
|
||||
if (!civInfo.gameInfo.isReligionEnabled()) return false // No religion
|
||||
|
||||
|
||||
if (religionState >= ReligionState.Religion) return false // Already created a major religion
|
||||
|
||||
// Already used its power for other things
|
||||
@ -165,7 +166,7 @@ class ReligionManager {
|
||||
|
||||
if (foundedReligionsCount >= amountOfFoundableReligions())
|
||||
return false // Too bad, too many religions have already been founded
|
||||
|
||||
|
||||
if (foundedReligionsCount >= civInfo.gameInfo.ruleSet.religions.size)
|
||||
return false // Mod maker did not provide enough religions for the amount of civs present
|
||||
|
||||
@ -184,8 +185,8 @@ class ReligionManager {
|
||||
fun mayFoundReligionNow(prophet: MapUnit): Boolean {
|
||||
if (!mayFoundReligionAtAll(prophet)) return false
|
||||
if (!prophet.getTile().isCityCenter()) return false
|
||||
if (prophet.getTile().getCity()!!.isHolyCity()) return false
|
||||
// No double holy cities. Not sure if these were allowed in the base game
|
||||
if (prophet.getTile().getCity()!!.isHolyCity()) return false
|
||||
// No double holy cities. Not sure if these were allowed in the base game
|
||||
return true
|
||||
}
|
||||
|
||||
@ -202,7 +203,7 @@ class ReligionManager {
|
||||
beliefsToChoose.add(BeliefType.Follower, 1)
|
||||
if (shouldChoosePantheonBelief)
|
||||
beliefsToChoose.add(BeliefType.Pantheon, 1)
|
||||
|
||||
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.FreeExtraBeliefs)) {
|
||||
if (unique.params[2] != "founding") continue
|
||||
beliefsToChoose.add(BeliefType.valueOf(unique.params[1]), unique.params[0].toInt())
|
||||
@ -211,17 +212,19 @@ class ReligionManager {
|
||||
if (unique.params[1] != "founding") continue
|
||||
beliefsToChoose.add(BeliefType.Any, unique.params[0].toInt())
|
||||
}
|
||||
|
||||
|
||||
return beliefsToChoose
|
||||
}
|
||||
|
||||
fun chooseBeliefs(iconName: String?, religionName: String?, beliefs: List<Belief>) {
|
||||
if (religionState == ReligionState.FoundingReligion) {
|
||||
foundReligion(iconName!!, religionName!!, beliefs)
|
||||
return
|
||||
when(religionState) {
|
||||
ReligionState.FoundingReligion ->
|
||||
foundReligion(iconName!!, religionName!!, beliefs)
|
||||
ReligionState.EnhancingReligion ->
|
||||
enhanceReligion(beliefs)
|
||||
else -> return
|
||||
}
|
||||
if (religionState == ReligionState.EnhancingReligion)
|
||||
enhanceReligion(beliefs)
|
||||
civInfo.updateStatsForNextTurn() // a belief can have an immediate effect on stats
|
||||
}
|
||||
|
||||
|
||||
@ -256,7 +259,7 @@ class ReligionManager {
|
||||
foundingCityId = null
|
||||
shouldChoosePantheonBelief = false
|
||||
|
||||
for (unit in civInfo.getCivUnits())
|
||||
for (unit in civInfo.getCivUnits())
|
||||
if (unit.hasUnique(UniqueType.ReligiousUnit) && unit.hasUnique(UniqueType.TakeReligionOverBirthCity))
|
||||
unit.religion = newReligion.name
|
||||
}
|
||||
@ -269,13 +272,13 @@ class ReligionManager {
|
||||
if (prophet.abilityUsesLeft.any { it.value != prophet.maxAbilityUses[it.key] }) return false
|
||||
if (!civInfo.isMajorCiv()) return false // Only major civs
|
||||
|
||||
if (civInfo.gameInfo.ruleSet.beliefs.values.none {
|
||||
it.type == BeliefType.Follower
|
||||
if (civInfo.gameInfo.ruleSet.beliefs.values.none {
|
||||
it.type == BeliefType.Follower
|
||||
&& civInfo.gameInfo.religions.values.none { religion -> religion.getBeliefs(BeliefType.Follower).contains(it) }
|
||||
}) return false // Mod maker did not provide enough follower beliefs
|
||||
|
||||
if (civInfo.gameInfo.ruleSet.beliefs.values.none {
|
||||
it.type == BeliefType.Enhancer
|
||||
if (civInfo.gameInfo.ruleSet.beliefs.values.none {
|
||||
it.type == BeliefType.Enhancer
|
||||
&& civInfo.gameInfo.religions.values.none { religion -> religion.getBeliefs(BeliefType.Enhancer).contains(it) }
|
||||
}) return false // Mod maker did not provide enough enhancer beliefs
|
||||
|
||||
@ -306,7 +309,7 @@ class ReligionManager {
|
||||
if (unique.params[1] != "enhancing") continue
|
||||
beliefsToChoose.add(BeliefType.Any, unique.params[0].toInt())
|
||||
}
|
||||
|
||||
|
||||
return beliefsToChoose
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user