diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 5eaa579e47..aa225f3162 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -12,6 +12,7 @@ import com.unciv.logic.map.TileMap import com.unciv.models.Religion import com.unciv.models.metadata.GameParameters import com.unciv.models.ruleset.Difficulty +import com.unciv.models.ruleset.ModOptionsConstants import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache import java.util.* @@ -131,10 +132,14 @@ class GameInfo { it.setTransients() } - fun hasReligionEnabled() = - // Temporary function to check whether religion should be used for this game - (gameParameters.religionEnabled || ruleSet.hasReligion()) - && (ruleSet.eras.isEmpty() || !ruleSet.eras[gameParameters.startingEra]!!.hasUnique("Starting in this era disables religion")) + fun isReligionEnabled(): Boolean { + if (ruleSet.eras[gameParameters.startingEra]!!.hasUnique("Starting in this era disables religion") + || ruleSet.modOptions.uniques.contains(ModOptionsConstants.disableReligion) + ) { + return false + } + return gameParameters.religionEnabled + } //endregion //region State changing functions diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index a551fca6e7..103a87ba00 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -538,7 +538,7 @@ class CityInfo { } else population.nextTurn(foodForNextTurn()) // This should go after the population change, as that might impact the amount of followers in this city - if (civInfo.gameInfo.hasReligionEnabled()) religion.endTurn() + if (civInfo.gameInfo.isReligionEnabled()) religion.endTurn() if (this in civInfo.cities) { // city was not destroyed health = min(health + 20, getMaxHealth()) diff --git a/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt b/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt index 4677d6848d..40f5a32632 100644 --- a/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt +++ b/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt @@ -272,7 +272,7 @@ class CityInfoConquestFunctions(val city: CityInfo){ } } - if (civInfo.gameInfo.hasReligionEnabled()) religion.removeUnknownPantheons() + if (civInfo.gameInfo.isReligionEnabled()) religion.removeUnknownPantheons() tryUpdateRoadStatus() cityStats.update() diff --git a/core/src/com/unciv/logic/city/CityReligion.kt b/core/src/com/unciv/logic/city/CityReligion.kt index 5633a8c704..90a03ba366 100644 --- a/core/src/com/unciv/logic/city/CityReligion.kt +++ b/core/src/com/unciv/logic/city/CityReligion.kt @@ -82,6 +82,7 @@ class CityInfoReligionManager { } fun addPressure(religionName: String, amount: Int, shouldUpdateFollowers: Boolean = true) { + if (!cityInfo.civInfo.gameInfo.isReligionEnabled()) return // No religion, no pressures pressures.add(religionName, amount) if (shouldUpdateFollowers) { @@ -232,6 +233,7 @@ class CityInfoReligionManager { } private fun getAffectedBySurroundingCities() { + if (!cityInfo.civInfo.gameInfo.isReligionEnabled()) return // No religion, no spreading // We don't update the amount of followers yet, as only the end result should matter // If multiple religions would become the majority religion due to pressure, // this will make it so we only receive a notification for the last one. diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index 8dfce08357..5e81365b8a 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -88,7 +88,8 @@ class PopulationManager { autoAssignPopulation() } - cityInfo.religion.updatePressureOnPopulationChange(changedAmount) + if (cityInfo.civInfo.gameInfo.isReligionEnabled()) + cityInfo.religion.updatePressureOnPopulationChange(changedAmount) } internal fun setPopulation(count: Int) { diff --git a/core/src/com/unciv/logic/civilization/CityStateFunctions.kt b/core/src/com/unciv/logic/civilization/CityStateFunctions.kt index 57d1784e75..b512eecc43 100644 --- a/core/src/com/unciv/logic/civilization/CityStateFunctions.kt +++ b/core/src/com/unciv/logic/civilization/CityStateFunctions.kt @@ -69,7 +69,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) { fun giveGreatPersonToPatron(receivingCiv: CivilizationInfo) { var giftableUnits = civInfo.gameInfo.ruleSet.units.values.filter { it.isGreatPerson() } - if (!civInfo.gameInfo.hasReligionEnabled()) giftableUnits = giftableUnits.filterNot { it.uniques.contains("Great Person - [Faith]")} + if (!civInfo.gameInfo.isReligionEnabled()) giftableUnits = giftableUnits.filterNot { it.uniques.contains("Hidden when religion is disabled")} if (giftableUnits.isEmpty()) // For badly defined mods that don't have great people but do have the policy that makes city states grant them return val giftedUnit = giftableUnits.random() diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 154fd85530..8fc2f6c434 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -564,7 +564,7 @@ class CivilizationInfo { fun getGreatPeople(): HashSet { val greatPeople = gameInfo.ruleSet.units.values.asSequence() .filter { it.isGreatPerson() }.map { getEquivalentUnit(it.name) } - return if (!gameInfo.hasReligionEnabled()) greatPeople.filter { !it.uniques.contains("Great Person - [Faith]")}.toHashSet() + return if (!gameInfo.isReligionEnabled()) greatPeople.filter { !it.uniques.contains("Hidden when religion is disabled")}.toHashSet() else greatPeople.toHashSet() } @@ -883,7 +883,7 @@ class CivilizationInfo { addNotification("A [${unit.name}] has been born in [${cityToAddTo.name}]!", placedUnit.getTile().position, unit.name) } - if (placedUnit.hasUnique("Religious Unit")) { + if (placedUnit.hasUnique("Religious Unit") && gameInfo.isReligionEnabled()) { placedUnit.religion = when { placedUnit.hasUnique("Takes your religion over the one in their birth city") -> diff --git a/core/src/com/unciv/logic/civilization/ReligionManager.kt b/core/src/com/unciv/logic/civilization/ReligionManager.kt index ac977999eb..63b1e710b6 100644 --- a/core/src/com/unciv/logic/civilization/ReligionManager.kt +++ b/core/src/com/unciv/logic/civilization/ReligionManager.kt @@ -1,11 +1,9 @@ package com.unciv.logic.civilization -import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.logic.map.MapUnit import com.unciv.models.Religion import com.unciv.models.ruleset.Belief import com.unciv.models.ruleset.BeliefType -import com.unciv.models.ruleset.Era import com.unciv.ui.pickerscreens.BeliefContainer import com.unciv.ui.utils.toPercent import kotlin.random.Random @@ -87,7 +85,7 @@ class ReligionManager { 10 + (civInfo.gameInfo.civilizations.count { it.isMajorCiv() && it.religionManager.religion != null } + additionalCivs) * 5 fun canFoundPantheon(): Boolean { - if (!civInfo.gameInfo.hasReligionEnabled()) return false + if (!civInfo.gameInfo.isReligionEnabled()) return false if (religionState != ReligionState.None) return false if (!civInfo.isMajorCiv()) return false if (civInfo.gameInfo.ruleSet.beliefs.values.none { isPickablePantheonBelief(it) }) @@ -130,6 +128,7 @@ class ReligionManager { } private fun canGenerateProphet(): Boolean { + if (!civInfo.gameInfo.isReligionEnabled()) return false // No religion, no prophets if (religion == null || religionState == ReligionState.None) return false // First get a pantheon, then we'll talk about a real religion if (getGreatProphetEquivalent() == null) return false if (storedFaith < faithForNextGreatProphet()) return false @@ -159,6 +158,8 @@ class ReligionManager { } 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 @@ -256,6 +257,7 @@ class ReligionManager { } 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 diff --git a/core/src/com/unciv/logic/civilization/RuinsManager/RuinsManager.kt b/core/src/com/unciv/logic/civilization/RuinsManager/RuinsManager.kt index d249571cbc..fcf6e0345c 100644 --- a/core/src/com/unciv/logic/civilization/RuinsManager/RuinsManager.kt +++ b/core/src/com/unciv/logic/civilization/RuinsManager/RuinsManager.kt @@ -41,7 +41,7 @@ class RuinsManager { for (possibleReward in possibleRewards) { if (civInfo.gameInfo.difficulty in possibleReward.excludedDifficulties) continue - if (Constants.hiddenWithoutReligionUnique in possibleReward.uniques && !civInfo.gameInfo.hasReligionEnabled()) continue + if (Constants.hiddenWithoutReligionUnique in possibleReward.uniques && !civInfo.gameInfo.isReligionEnabled()) continue if ("Hidden after generating a Great Prophet" in possibleReward.uniques && civInfo.civConstructions.boughtItemsWithIncreasingPrice[civInfo.religionManager.getGreatProphetEquivalent()] ?: 0 > 0 ) continue diff --git a/core/src/com/unciv/models/ruleset/Belief.kt b/core/src/com/unciv/models/ruleset/Belief.kt index 8eb440212f..07373663ed 100644 --- a/core/src/com/unciv/models/ruleset/Belief.kt +++ b/core/src/com/unciv/models/ruleset/Belief.kt @@ -35,7 +35,7 @@ class Belief : INamed, ICivilopediaText, IHasUniques { private fun getBeliefsMatching(name: String, ruleset: Ruleset): Sequence { if (!UncivGame.isCurrentInitialized()) return sequenceOf() if (!UncivGame.Current.isGameInfoInitialized()) return sequenceOf() - if (!UncivGame.Current.gameInfo.hasReligionEnabled()) return sequenceOf() + if (!UncivGame.Current.gameInfo.isReligionEnabled()) return sequenceOf() return ruleset.beliefs.asSequence().map { it.value } .filter { belief -> belief.uniqueObjects.any { unique -> unique.params.any { it == name } } } diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 74e61ecf71..810948523b 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -464,7 +464,7 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText { rejectionReasons.add(RejectionReason.Obsoleted.apply { errorMessage = unique.text }) Constants.hiddenWithoutReligionUnique -> - if (!civInfo.gameInfo.hasReligionEnabled()) + if (!civInfo.gameInfo.isReligionEnabled()) rejectionReasons.add(RejectionReason.DisabledBySetting) } } diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 99955237e8..96d6b2570d 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -27,6 +27,7 @@ object ModOptionsConstants { const val convertGoldToScience = "Can convert gold to science with sliders" const val allowCityStatesSpawnUnits = "Allow City States to spawn with additional units" const val tradeCivIntroductions = "Can trade civilization introductions for [] Gold" + const val disableReligion = "Disable religion" } class ModOptions : IHasUniques { diff --git a/core/src/com/unciv/models/ruleset/tech/Technology.kt b/core/src/com/unciv/models/ruleset/tech/Technology.kt index 2086b2ef9d..3f89edc9e6 100644 --- a/core/src/com/unciv/models/ruleset/tech/Technology.kt +++ b/core/src/com/unciv/models/ruleset/tech/Technology.kt @@ -111,7 +111,7 @@ class Technology: INamed, ICivilopediaText, IHasUniques { // Helper: common filtering for both getEnabledBuildings and getObsoletedBuildings, difference via predicate parameter private fun getFilteredBuildings(civInfo: CivilizationInfo, predicate: (Building)->Boolean): Sequence { val nuclearWeaponsEnabled = civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled - val religionEnabled = civInfo.gameInfo.hasReligionEnabled() + val religionEnabled = civInfo.gameInfo.isReligionEnabled() return civInfo.gameInfo.ruleSet.buildings.values.asSequence() .filter { @@ -130,7 +130,7 @@ class Technology: INamed, ICivilopediaText, IHasUniques { // Used for Civilopedia, Alert and Picker, so if any of these decide to ignore the "Will not be displayed in Civilopedia" unique this needs refactoring fun getEnabledUnits(civInfo: CivilizationInfo): Sequence { val nuclearWeaponsEnabled = civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled - val religionEnabled = civInfo.gameInfo.hasReligionEnabled() + val religionEnabled = civInfo.gameInfo.isReligionEnabled() return civInfo.gameInfo.ruleSet.units.values.asSequence() .filter { diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index ffdb1ff6ff..eaa48a8a0d 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -163,7 +163,7 @@ class TileImprovement : NamedStats(), ICivilopediaText, IHasUniques { if (isAncientRuinsEquivalent() && ruleset.ruinRewards.isNotEmpty()) { val difficulty = UncivGame.Current.gameInfo.gameParameters.difficulty - val religionEnabled = UncivGame.Current.gameInfo.hasReligionEnabled() + val religionEnabled = UncivGame.Current.gameInfo.isReligionEnabled() textList += FormattedLine() textList += FormattedLine("The possible rewards are:") ruleset.ruinRewards.values.asSequence() diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 7408430ff2..c67556c93e 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -394,7 +394,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText { unit.currentMovement = 0f // If this unit has special abilities that need to be kept track of, start doing so here - if (unit.hasUnique("Religious Unit")) { + if (unit.hasUnique("Religious Unit") && civInfo.gameInfo.isReligionEnabled()) { unit.religion = if (unit.hasUnique("Takes your religion over the one in their birth city")) civInfo.religionManager.religion?.name diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index f6d38cbfd7..0de9b78c9a 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -29,7 +29,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { val miniStatsTable = Table() for ((stat, amount) in cityInfo.cityStats.currentCityStats) { - if (stat == Stat.Faith && !cityInfo.civInfo.gameInfo.hasReligionEnabled()) continue + if (stat == Stat.Faith && !cityInfo.civInfo.gameInfo.isReligionEnabled()) continue miniStatsTable.add(ImageGetter.getStatIcon(stat.name)).size(20f).padRight(5f) val valueToDisplay = if (stat == Stat.Happiness) cityInfo.cityStats.happinessList.values.sum() else amount miniStatsTable.add(round(valueToDisplay).toInt().toLabel()).padRight(10f) @@ -43,7 +43,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() }).row() } - if (cityInfo.religion.getNumberOfFollowers().isNotEmpty()) + if (cityInfo.religion.getNumberOfFollowers().isNotEmpty() && cityInfo.civInfo.gameInfo.isReligionEnabled()) addReligionInfo() pack() diff --git a/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt b/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt index 43f8981a25..03cddd16d8 100644 --- a/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt +++ b/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt @@ -158,7 +158,7 @@ class CivilopediaScreen( val imageSize = 50f onBackButtonClicked { UncivGame.Current.setWorldScreen() } - val hideReligionItems = !game.gameInfo.hasReligionEnabled() + val hideReligionItems = !game.gameInfo.isReligionEnabled() fun shouldBeDisplayed(uniqueObjects: List): Boolean { val uniques = uniqueObjects.map { it.placeholderText } diff --git a/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt b/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt index 2b3e8623d4..952d1f4b41 100644 --- a/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt +++ b/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt @@ -24,7 +24,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val } private val columnsNames = arrayListOf("Population", "Food", "Gold", "Science", "Production", "Culture", "Happiness") - .apply { if (viewingPlayer.gameInfo.hasReligionEnabled()) add("Faith") } + .apply { if (viewingPlayer.gameInfo.isReligionEnabled()) add("Faith") } init { val numHeaderCells = columnsNames.size + 2 // +1 City +1 Filler diff --git a/core/src/com/unciv/ui/overviewscreen/EmpireOverviewScreen.kt b/core/src/com/unciv/ui/overviewscreen/EmpireOverviewScreen.kt index 68d4cff005..8dede45016 100644 --- a/core/src/com/unciv/ui/overviewscreen/EmpireOverviewScreen.kt +++ b/core/src/com/unciv/ui/overviewscreen/EmpireOverviewScreen.kt @@ -86,7 +86,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa addCategory("Units", UnitOverviewTable(viewingPlayer, this), viewingPlayer.getCivUnits().none()) addCategory("Diplomacy", DiplomacyOverviewTable(viewingPlayer, this), viewingPlayer.diplomacy.isEmpty()) addCategory("Resources", ResourcesOverviewTable(viewingPlayer, this), viewingPlayer.detailedCivResources.isEmpty()) - if (viewingPlayer.gameInfo.hasReligionEnabled()) + if (viewingPlayer.gameInfo.isReligionEnabled()) addCategory("Religion", ReligionOverviewTable(viewingPlayer, this), viewingPlayer.gameInfo.religions.isEmpty()) val closeButton = Constants.close.toTextButton().apply { diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt index 19534df5a8..b7fcbdfb3c 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt @@ -125,7 +125,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() { cultureLabel.onClick(invokePoliciesPage) cultureImage.onClick(invokePoliciesPage) - if(worldScreen.gameInfo.hasReligionEnabled()) { + if(worldScreen.gameInfo.isReligionEnabled()) { statsTable.add(faithLabel).padLeft(20f) val faithImage = ImageGetter.getStatIcon("Faith") statsTable.add(faithImage).padBottom(6f).size(20f) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index e8f7849b2f..1691e0f7d4 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -533,13 +533,13 @@ object UnitActions { private fun useActionWithLimitedUses(unit: MapUnit, action: String) { unit.abilityUsesLeft[action] = unit.abilityUsesLeft[action]!! - 1 if (unit.abilityUsesLeft[action]!! <= 0) { - if (unit.isGreatPerson()) - addStatsPerGreatPersonUsage(unit) + addStatsPerGreatPersonUsage(unit) unit.destroy() } } private fun addSpreadReligionActions(unit: MapUnit, actionList: ArrayList, city: CityInfo) { + if (!unit.civInfo.gameInfo.isReligionEnabled()) return val blockedByInquisitor = city.getCenterTile() .getTilesInDistance(1) @@ -565,6 +565,7 @@ object UnitActions { } private fun addRemoveHeresyActions(unit: MapUnit, actionList: ArrayList, city: CityInfo) { + if (!unit.civInfo.gameInfo.isReligionEnabled()) return if (city.civInfo != unit.civInfo) return // Only allow the action if the city actually has any foreign religion // This will almost be always due to pressure from cities close-by