Merge remote-tracking branch 'origin/master'

This commit is contained in:
yairm210 2021-09-15 00:59:40 +03:00
commit b7eb21b606
27 changed files with 73 additions and 38 deletions

View File

@ -256,8 +256,9 @@
{
"name": "Mount Fuji",
"type": "NaturalWonder",
"gold": 1,
"culture": 5,
"gold": 2,
"culture": 3,
"faith": 3,
"occursOn": ["Grassland","Plains"],
"turnsInto": "Mountain",
"impassable": true,

View File

@ -146,13 +146,13 @@
{
"name": "Medic",
"prerequisites": ["Shock I", "Drill I", "Scouting II", "Survivalism II"],
"uniques": ["[+5] HP when healing", "All adjacent units heal [5] HP when healing"],
"uniques": ["All adjacent units heal [+5] HP when healing"],
"unitTypes": ["Sword","Gunpowder","Mounted","Scout"]
},
{
"name": "Medic II",
"prerequisites": ["Medic"],
"uniques": ["[+5] HP when healing", "[+5] HP when healing in [Foreign Land] tiles", "All adjacent units heal [5] HP when healing"],
"uniques": ["[+5] HP when healing in [Foreign Land] tiles", "All adjacent units heal [+5] HP when healing"],
"unitTypes": ["Sword","Gunpowder","Mounted","Scout"]
},

View File

@ -1537,7 +1537,7 @@
"uniqueTo": "Mongolia",
"replaces": "Great General",
"uniques": ["Can start an [8]-turn golden age","Bonus for units in 2 tile radius 15%",
"Heal adjacent units for an additional 15 HP per turn", "Can construct [Citadel]", "Great Person - [War]", "Unbuildable", "Uncapturable"],
"All adjacent units heal [+15] HP when healing", "[+15] HP when healing", "Can construct [Citadel]", "Great Person - [War]", "Unbuildable", "Uncapturable"],
"movement": 5
},

View File

@ -953,6 +953,8 @@ Tutorials =
Cost =
May contain [listOfResources] =
May contain: =
Can upgrade from [unit] =
Can upgrade from: =
Upgrades to [upgradedUnit] =
Obsolete with [obsoleteTech] =
Occurs on [listOfTerrains] =

View File

@ -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

View File

@ -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())

View File

@ -272,7 +272,7 @@ class CityInfoConquestFunctions(val city: CityInfo){
}
}
if (civInfo.gameInfo.hasReligionEnabled()) religion.removeUnknownPantheons()
if (civInfo.gameInfo.isReligionEnabled()) religion.removeUnknownPantheons()
tryUpdateRoadStatus()
cityStats.update()

View File

@ -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) {
@ -112,11 +113,13 @@ class CityInfoReligionManager {
}
private fun triggerReligionAdoption(newMajorityReligion: String) {
cityInfo.civInfo.addNotification("Your city [${cityInfo.name}] was converted to [$newMajorityReligion]!", cityInfo.location, NotificationIcon.Faith)
val newMajorityReligionObject = cityInfo.civInfo.gameInfo.religions[newMajorityReligion]!!
cityInfo.civInfo.addNotification("Your city [${cityInfo.name}] was converted to [${newMajorityReligionObject.getReligionDisplayName()}]!", cityInfo.location, NotificationIcon.Faith)
if (newMajorityReligion in religionsAtSomePointAdopted) return
val religionOwningCiv = cityInfo.civInfo.gameInfo.getCivilization(cityInfo.civInfo.gameInfo.religions[newMajorityReligion]!!.foundingCivName)
for (unique in cityInfo.civInfo.gameInfo.religions[newMajorityReligion]!!.getFounderUniques()) {
val religionOwningCiv = cityInfo.civInfo.gameInfo.getCivilization(newMajorityReligionObject.foundingCivName)
for (unique in newMajorityReligionObject.getFounderUniques()) {
val statsGranted = when (unique.placeholderText) {
"[] when a city adopts this religion for the first time (modified by game speed)" ->
unique.stats.times(cityInfo.civInfo.gameInfo.gameParameters.gameSpeed.modifier)
@ -230,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.

View File

@ -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) {

View File

@ -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()

View File

@ -564,7 +564,7 @@ class CivilizationInfo {
fun getGreatPeople(): HashSet<BaseUnit> {
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") ->

View File

@ -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

View File

@ -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

View File

@ -571,7 +571,7 @@ class MapUnit {
amountToHealBy += getMatchingUniques("[] HP when healing").sumOf { it.params[0].toInt() }
val maxAdjacentHealingBonus = currentTile.getTilesInDistance(1)
val maxAdjacentHealingBonus = currentTile.neighbors
.flatMap { it.getUnits().asSequence() }.map { it.adjacentHealingBonus() }.maxOrNull()
if (maxAdjacentHealingBonus != null)
amountToHealBy += maxAdjacentHealingBonus

View File

@ -35,7 +35,7 @@ class Belief : INamed, ICivilopediaText, IHasUniques {
private fun getBeliefsMatching(name: String, ruleset: Ruleset): Sequence<Belief> {
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 } }
}

View File

@ -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)
}
}

View File

@ -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 {

View File

@ -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<Building> {
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<BaseUnit> {
val nuclearWeaponsEnabled = civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled
val religionEnabled = civInfo.gameInfo.hasReligionEnabled()
val religionEnabled = civInfo.gameInfo.isReligionEnabled()
return civInfo.gameInfo.ruleSet.units.values.asSequence()
.filter {

View File

@ -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()

View File

@ -154,6 +154,24 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
if (requiredTech != null || upgradesTo != null || obsoleteTech != null) textList += FormattedLine()
if (requiredTech != null) textList += FormattedLine("Required tech: [$requiredTech]", link="Technology/$requiredTech")
val canUpgradeFrom = ruleset.units
.filterValues {
(it.upgradesTo == name || it.upgradesTo != null && it.upgradesTo == replaces)
&& (it.uniqueTo == uniqueTo || it.uniqueTo == null)
}.keys
if (canUpgradeFrom.isNotEmpty()) {
if (canUpgradeFrom.size == 1)
textList += FormattedLine("Can upgrade from [${canUpgradeFrom.first()}]", link = "Unit/${canUpgradeFrom.first()}")
else {
textList += FormattedLine()
textList += FormattedLine("Can upgrade from:")
for (unitName in canUpgradeFrom.sorted())
textList += FormattedLine(unitName, indent = 2, link = "Unit/$unitName")
textList += FormattedLine()
}
}
if (upgradesTo != null) textList += FormattedLine("Upgrades to [$upgradesTo]", link="Unit/$upgradesTo")
if (obsoleteTech != null) textList += FormattedLine("Obsolete with [$obsoleteTech]", link="Technology/$obsoleteTech")
@ -394,7 +412,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

View File

@ -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()

View File

@ -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<Unique>): Boolean {
val uniques = uniqueObjects.map { it.placeholderText }

View File

@ -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

View File

@ -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 {

View File

@ -131,7 +131,7 @@ class ReligiousBeliefsPickerScreen (
private fun setupVisibleReligionIcons() {
topReligionIcons.clear()
val descriptionLabel = choosingCiv.religionManager.religion!!.name.toLabel()
val descriptionLabel = choosingCiv.religionManager.religion!!.getReligionDisplayName().toLabel()
val iconsTable = Table()

View File

@ -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)

View File

@ -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<UnitAction>, 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<UnitAction>, 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