mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Fix crashes when a civ does not have a capital (#6889)
This commit is contained in:
parent
740886c890
commit
39bbb2de1c
@ -100,8 +100,8 @@ class BarbarianManager {
|
|||||||
if (campsToAdd <= 0) return
|
if (campsToAdd <= 0) return
|
||||||
|
|
||||||
// Camps can't spawn within 7 tiles of each other or within 4 tiles of major civ capitals
|
// Camps can't spawn within 7 tiles of each other or within 4 tiles of major civ capitals
|
||||||
val tooCloseToCapitals = gameInfo.civilizations.filterNot { it.isBarbarian() || it.isSpectator() || it.cities.isEmpty() || it.isCityState() }
|
val tooCloseToCapitals = gameInfo.civilizations.filterNot { it.isBarbarian() || it.isSpectator() || it.cities.isEmpty() || it.isCityState() || it.getCapital() == null }
|
||||||
.flatMap { it.getCapital().getCenterTile().getTilesInDistance(4) }.toSet()
|
.flatMap { it.getCapital()!!.getCenterTile().getTilesInDistance(4) }.toSet()
|
||||||
val tooCloseToCamps = camps
|
val tooCloseToCamps = camps
|
||||||
.flatMap { tileMap[it.key].getTilesInDistance(
|
.flatMap { tileMap[it.key].getTilesInDistance(
|
||||||
if (it.value.destroyed) 4 else 7
|
if (it.value.destroyed) 4 else 7
|
||||||
|
@ -345,7 +345,7 @@ class GameInfo {
|
|||||||
getAliveCityStates()
|
getAliveCityStates()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it.cityStateResource == resourceName }
|
.filter { it.cityStateResource == resourceName }
|
||||||
.map { it.getCapital().getCenterTile() }
|
.map { it.getCapital()!!.getCenterTile() }
|
||||||
} else {
|
} else {
|
||||||
tileMap.values
|
tileMap.values
|
||||||
.asSequence()
|
.asSequence()
|
||||||
|
@ -213,7 +213,7 @@ object Automation {
|
|||||||
|
|
||||||
// If we have vision of our entire starting continent (ish) we are not afraid
|
// If we have vision of our entire starting continent (ish) we are not afraid
|
||||||
civInfo.gameInfo.tileMap.assignContinents(TileMap.AssignContinentsMode.Ensure)
|
civInfo.gameInfo.tileMap.assignContinents(TileMap.AssignContinentsMode.Ensure)
|
||||||
val startingContinent = civInfo.getCapital().getCenterTile().getContinent()
|
val startingContinent = civInfo.getCapital()!!.getCenterTile().getContinent()
|
||||||
val startingContinentSize = civInfo.gameInfo.tileMap.continentSizes[startingContinent]
|
val startingContinentSize = civInfo.gameInfo.tileMap.continentSizes[startingContinent]
|
||||||
if (startingContinentSize != null && startingContinentSize < civInfo.viewableTiles.size * multiplier)
|
if (startingContinentSize != null && startingContinentSize < civInfo.viewableTiles.size * multiplier)
|
||||||
return false
|
return false
|
||||||
|
@ -722,7 +722,7 @@ object NextTurnAutomation {
|
|||||||
&& (owner == otherCiv || owner == null || civInfo.canPassThroughTiles(owner))
|
&& (owner == otherCiv || owner == null || civInfo.canPassThroughTiles(owner))
|
||||||
}
|
}
|
||||||
|
|
||||||
val reachableEnemyCitiesBfs = BFS(civInfo.getCapital().getCenterTile()) { isTileCanMoveThrough(it) }
|
val reachableEnemyCitiesBfs = BFS(civInfo.getCapital()!!.getCenterTile()) { isTileCanMoveThrough(it) }
|
||||||
reachableEnemyCitiesBfs.stepToEnd()
|
reachableEnemyCitiesBfs.stepToEnd()
|
||||||
val reachableEnemyCities = otherCiv.cities.filter { reachableEnemyCitiesBfs.hasReachedTile(it.getCenterTile()) }
|
val reachableEnemyCities = otherCiv.cities.filter { reachableEnemyCitiesBfs.hasReachedTile(it.getCenterTile()) }
|
||||||
if (reachableEnemyCities.isEmpty()) return 0 // Can't even reach the enemy city, no point in war.
|
if (reachableEnemyCities.isEmpty()) return 0 // Can't even reach the enemy city, no point in war.
|
||||||
|
@ -279,7 +279,8 @@ object SpecificUnitAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun automateAddInCapital(unit: MapUnit) {
|
fun automateAddInCapital(unit: MapUnit) {
|
||||||
val capitalTile = unit.civInfo.getCapital().getCenterTile()
|
if (unit.civInfo.getCapital() == null) return // safeguard
|
||||||
|
val capitalTile = unit.civInfo.getCapital()!!.getCenterTile()
|
||||||
if (unit.movement.canReach(capitalTile))
|
if (unit.movement.canReach(capitalTile))
|
||||||
unit.movement.headTowards(capitalTile)
|
unit.movement.headTowards(capitalTile)
|
||||||
if (unit.getTile() == capitalTile) {
|
if (unit.getTile() == capitalTile) {
|
||||||
|
@ -57,7 +57,7 @@ class WorkerAutomation(
|
|||||||
&& !it.isCapital() && !it.isBeingRazed // Cities being razed should not be connected.
|
&& !it.isCapital() && !it.isBeingRazed // Cities being razed should not be connected.
|
||||||
&& !it.cityStats.isConnectedToCapital(bestRoadAvailable)
|
&& !it.cityStats.isConnectedToCapital(bestRoadAvailable)
|
||||||
}.sortedBy {
|
}.sortedBy {
|
||||||
it.getCenterTile().aerialDistanceTo(civInfo.getCapital().getCenterTile())
|
it.getCenterTile().aerialDistanceTo(civInfo.getCapital()!!.getCenterTile())
|
||||||
}.toList()
|
}.toList()
|
||||||
if (WorkerAutomationConst.consoleOutput) {
|
if (WorkerAutomationConst.consoleOutput) {
|
||||||
println("WorkerAutomation citiesThatNeedConnecting for ${civInfo.civName} turn $cachedForTurn:")
|
println("WorkerAutomation citiesThatNeedConnecting for ${civInfo.civName} turn $cachedForTurn:")
|
||||||
|
@ -49,9 +49,9 @@ object BattleDamage {
|
|||||||
for (unique in combatant.getMatchingUniques(
|
for (unique in combatant.getMatchingUniques(
|
||||||
UniqueType.StrengthNearCapital, conditionalState, true
|
UniqueType.StrengthNearCapital, conditionalState, true
|
||||||
)) {
|
)) {
|
||||||
if (civInfo.cities.isEmpty()) break
|
if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) break
|
||||||
val distance =
|
val distance =
|
||||||
combatant.getTile().aerialDistanceTo(civInfo.getCapital().getCenterTile())
|
combatant.getTile().aerialDistanceTo(civInfo.getCapital()!!.getCenterTile())
|
||||||
// https://steamcommunity.com/sharedfiles/filedetails/?id=326411722#464287
|
// https://steamcommunity.com/sharedfiles/filedetails/?id=326411722#464287
|
||||||
val effect = unique.params[0].toInt() - 3 * distance
|
val effect = unique.params[0].toInt() - 3 * distance
|
||||||
if (effect <= 0) continue
|
if (effect <= 0) continue
|
||||||
|
@ -83,7 +83,7 @@ class CityStats(val cityInfo: CityInfo) {
|
|||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
if (!cityInfo.isCapital() && cityInfo.isConnectedToCapital()) {
|
if (!cityInfo.isCapital() && cityInfo.isConnectedToCapital()) {
|
||||||
val civInfo = cityInfo.civInfo
|
val civInfo = cityInfo.civInfo
|
||||||
stats.gold = civInfo.getCapital().population.population * 0.15f + cityInfo.population.population * 1.1f - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
|
stats.gold = civInfo.getCapital()!!.population.population * 0.15f + cityInfo.population.population * 1.1f - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
|
||||||
for (unique in cityInfo.getMatchingUniques(UniqueType.StatsFromTradeRoute))
|
for (unique in cityInfo.getMatchingUniques(UniqueType.StatsFromTradeRoute))
|
||||||
stats.add(unique.stats)
|
stats.add(unique.stats)
|
||||||
val percentageStats = Stats()
|
val percentageStats = Stats()
|
||||||
@ -317,7 +317,8 @@ class CityStats(val cityInfo: CityInfo) {
|
|||||||
|
|
||||||
if (currentConstruction is Building
|
if (currentConstruction is Building
|
||||||
&& cityInfo.civInfo.cities.isNotEmpty()
|
&& cityInfo.civInfo.cities.isNotEmpty()
|
||||||
&& cityInfo.civInfo.getCapital().cityConstructions.builtBuildings.contains(currentConstruction.name)
|
&& cityInfo.civInfo.getCapital() != null
|
||||||
|
&& cityInfo.civInfo.getCapital()!!.cityConstructions.builtBuildings.contains(currentConstruction.name)
|
||||||
) {
|
) {
|
||||||
for (unique in cityInfo.getMatchingUniques(UniqueType.PercentProductionBuildingsInCapital))
|
for (unique in cityInfo.getMatchingUniques(UniqueType.PercentProductionBuildingsInCapital))
|
||||||
addUniqueStats(unique, Stat.Production, unique.params[0].toFloat())
|
addUniqueStats(unique, Stat.Production, unique.params[0].toFloat())
|
||||||
|
@ -8,7 +8,7 @@ import kotlin.collections.set
|
|||||||
|
|
||||||
class CapitalConnectionsFinder(private val civInfo: CivilizationInfo) {
|
class CapitalConnectionsFinder(private val civInfo: CivilizationInfo) {
|
||||||
private val citiesReachedToMediums = HashMap<CityInfo, MutableSet<String>>()
|
private val citiesReachedToMediums = HashMap<CityInfo, MutableSet<String>>()
|
||||||
private var citiesToCheck = mutableListOf(civInfo.getCapital())
|
private var citiesToCheck = mutableListOf(civInfo.getCapital()!!)
|
||||||
private lateinit var newCitiesToCheck: MutableList<CityInfo>
|
private lateinit var newCitiesToCheck: MutableList<CityInfo>
|
||||||
|
|
||||||
private val openBordersCivCities = civInfo.gameInfo.getCities().filter { civInfo.canEnterBordersOf(it.civInfo) }
|
private val openBordersCivCities = civInfo.gameInfo.getCities().filter { civInfo.canEnterBordersOf(it.civInfo) }
|
||||||
@ -24,7 +24,7 @@ class CapitalConnectionsFinder(private val civInfo: CivilizationInfo) {
|
|||||||
private val railroadIsResearched = ruleset.tileImprovements.containsKey(railroad) && civInfo.tech.isResearched(ruleset.tileImprovements[railroad]!!.techRequired!!)
|
private val railroadIsResearched = ruleset.tileImprovements.containsKey(railroad) && civInfo.tech.isResearched(ruleset.tileImprovements[railroad]!!.techRequired!!)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
citiesReachedToMediums[civInfo.getCapital()] = hashSetOf("Start")
|
citiesReachedToMediums[civInfo.getCapital()!!] = hashSetOf("Start")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun find(): Map<CityInfo, Set<String>> {
|
fun find(): Map<CityInfo, Set<String>> {
|
||||||
|
@ -111,7 +111,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
val placedUnit = receivingCiv.placeUnitNearTile(city.location, militaryUnit.name) ?: return
|
val placedUnit = receivingCiv.placeUnitNearTile(city.location, militaryUnit.name) ?: return
|
||||||
|
|
||||||
// The unit should have bonuses from Barracks, Alhambra etc as if it was built in the CS capital
|
// The unit should have bonuses from Barracks, Alhambra etc as if it was built in the CS capital
|
||||||
militaryUnit.addConstructionBonuses(placedUnit, civInfo.getCapital().cityConstructions)
|
militaryUnit.addConstructionBonuses(placedUnit, civInfo.getCapital()!!.cityConstructions)
|
||||||
|
|
||||||
// Siam gets +10 XP for all CS units
|
// Siam gets +10 XP for all CS units
|
||||||
for (unique in receivingCiv.getMatchingUniques(UniqueType.CityStateGiftedUnitsStartWithXp)) {
|
for (unique in receivingCiv.getMatchingUniques(UniqueType.CityStateGiftedUnitsStartWithXp)) {
|
||||||
@ -236,7 +236,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
|
|
||||||
// If the city-state is captured by a civ, it stops being the ally of the civ it was previously an ally of.
|
// If the city-state is captured by a civ, it stops being the ally of the civ it was previously an ally of.
|
||||||
// This means that it will NOT HAVE a capital at that time, so if we run getCapital we'll get a crash!
|
// This means that it will NOT HAVE a capital at that time, so if we run getCapital we'll get a crash!
|
||||||
val capitalLocation = if (civInfo.cities.isNotEmpty()) civInfo.getCapital().location else null
|
val capitalLocation = if (civInfo.cities.isNotEmpty() && civInfo.getCapital() != null) civInfo.getCapital()!!.location else null
|
||||||
|
|
||||||
if (newAllyName != null) {
|
if (newAllyName != null) {
|
||||||
val newAllyCiv = civInfo.gameInfo.getCivilization(newAllyName)
|
val newAllyCiv = civInfo.gameInfo.getCivilization(newAllyName)
|
||||||
@ -300,10 +300,10 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
|
|
||||||
otherCiv.addGold(-getDiplomaticMarriageCost())
|
otherCiv.addGold(-getDiplomaticMarriageCost())
|
||||||
otherCiv.addNotification("We have married into the ruling family of [${civInfo.civName}], bringing them under our control.",
|
otherCiv.addNotification("We have married into the ruling family of [${civInfo.civName}], bringing them under our control.",
|
||||||
civInfo.getCapital().location, civInfo.civName, NotificationIcon.Diplomacy, otherCiv.civName)
|
civInfo.getCapital()!!.location, civInfo.civName, NotificationIcon.Diplomacy, otherCiv.civName)
|
||||||
for (civ in civInfo.gameInfo.civilizations.filter { it != otherCiv })
|
for (civ in civInfo.gameInfo.civilizations.filter { it != otherCiv })
|
||||||
civ.addNotification("[${otherCiv.civName}] has married into the ruling family of [${civInfo.civName}], bringing them under their control.",
|
civ.addNotification("[${otherCiv.civName}] has married into the ruling family of [${civInfo.civName}], bringing them under their control.",
|
||||||
civInfo.getCapital().location, civInfo.civName, NotificationIcon.Diplomacy, otherCiv.civName)
|
civInfo.getCapital()!!.location, civInfo.civName, NotificationIcon.Diplomacy, otherCiv.civName)
|
||||||
for (unit in civInfo.getCivUnits())
|
for (unit in civInfo.getCivUnits())
|
||||||
unit.gift(otherCiv)
|
unit.gift(otherCiv)
|
||||||
for (city in civInfo.cities) {
|
for (city in civInfo.cities) {
|
||||||
@ -326,7 +326,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
modifiers["Major Civ"] = -999
|
modifiers["Major Civ"] = -999
|
||||||
return modifiers
|
return modifiers
|
||||||
}
|
}
|
||||||
if (civInfo.cities.isEmpty()) {
|
if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) {
|
||||||
modifiers["No Cities"] = -999
|
modifiers["No Cities"] = -999
|
||||||
return modifiers
|
return modifiers
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
modifiers["Has Protector"] = -20
|
modifiers["Has Protector"] = -20
|
||||||
if (demandingWorker)
|
if (demandingWorker)
|
||||||
modifiers["Demanding a Worker"] = -30
|
modifiers["Demanding a Worker"] = -30
|
||||||
if (demandingWorker && civInfo.getCapital().population.population < 4)
|
if (demandingWorker && civInfo.getCapital()!!.population.population < 4)
|
||||||
modifiers["Demanding a Worker from small City-State"] = -300
|
modifiers["Demanding a Worker from small City-State"] = -300
|
||||||
val recentBullying = civInfo.getRecentBullyingCountdown()
|
val recentBullying = civInfo.getRecentBullyingCountdown()
|
||||||
if (recentBullying != null && recentBullying > 10)
|
if (recentBullying != null && recentBullying > 10)
|
||||||
@ -365,13 +365,13 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
return modifiers
|
return modifiers
|
||||||
|
|
||||||
val bullyRange = (civInfo.gameInfo.tileMap.tileMatrix.size / 10).coerceIn(5, 10) // Longer range for larger maps
|
val bullyRange = (civInfo.gameInfo.tileMap.tileMatrix.size / 10).coerceIn(5, 10) // Longer range for larger maps
|
||||||
val inRangeTiles = civInfo.getCapital().getCenterTile().getTilesInDistanceRange(1..bullyRange)
|
val inRangeTiles = civInfo.getCapital()!!.getCenterTile().getTilesInDistanceRange(1..bullyRange)
|
||||||
val forceNearCity = inRangeTiles
|
val forceNearCity = inRangeTiles
|
||||||
.sumOf { if (it.militaryUnit?.civInfo == demandingCiv)
|
.sumOf { if (it.militaryUnit?.civInfo == demandingCiv)
|
||||||
it.militaryUnit!!.getForceEvaluation()
|
it.militaryUnit!!.getForceEvaluation()
|
||||||
else 0
|
else 0
|
||||||
}
|
}
|
||||||
val csForce = civInfo.getCapital().getForceEvaluation() + inRangeTiles
|
val csForce = civInfo.getCapital()!!.getForceEvaluation() + inRangeTiles
|
||||||
.sumOf { if (it.militaryUnit?.civInfo == civInfo)
|
.sumOf { if (it.militaryUnit?.civInfo == civInfo)
|
||||||
it.militaryUnit!!.getForceEvaluation()
|
it.militaryUnit!!.getForceEvaluation()
|
||||||
else 0
|
else 0
|
||||||
@ -426,7 +426,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
it.value.isCivilian() && it.value.isBuildable(civInfo)
|
it.value.isCivilian() && it.value.isBuildable(civInfo)
|
||||||
}
|
}
|
||||||
if (buildableWorkerLikeUnits.isEmpty()) return // Bad luck?
|
if (buildableWorkerLikeUnits.isEmpty()) return // Bad luck?
|
||||||
demandingCiv.placeUnitNearTile(civInfo.getCapital().location, buildableWorkerLikeUnits.keys.random())
|
demandingCiv.placeUnitNearTile(civInfo.getCapital()!!.location, buildableWorkerLikeUnits.keys.random())
|
||||||
|
|
||||||
civInfo.getDiplomacyManager(demandingCiv).addInfluence(-50f)
|
civInfo.getDiplomacyManager(demandingCiv).addInfluence(-50f)
|
||||||
cityStateBullied(demandingCiv)
|
cityStateBullied(demandingCiv)
|
||||||
@ -660,7 +660,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
|||||||
) {
|
) {
|
||||||
thirdCiv.addNotification(
|
thirdCiv.addNotification(
|
||||||
"[${civInfo.civName}] is being attacked by [${attacker.civName}] and asks all major civilizations to help them out by gifting them military units.",
|
"[${civInfo.civName}] is being attacked by [${attacker.civName}] and asks all major civilizations to help them out by gifting them military units.",
|
||||||
civInfo.getCapital().location,
|
civInfo.getCapital()!!.location,
|
||||||
civInfo.civName,
|
civInfo.civName,
|
||||||
"OtherIcons/Present",
|
"OtherIcons/Present",
|
||||||
)
|
)
|
||||||
|
@ -145,13 +145,13 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateCitiesConnectedToCapital(initialSetup: Boolean = false) {
|
fun updateCitiesConnectedToCapital(initialSetup: Boolean = false) {
|
||||||
if (civInfo.cities.isEmpty()) return // eg barbarians
|
if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) return // eg barbarians
|
||||||
|
|
||||||
val citiesReachedToMediums = CapitalConnectionsFinder(civInfo).find()
|
val citiesReachedToMediums = CapitalConnectionsFinder(civInfo).find()
|
||||||
|
|
||||||
if (!initialSetup) { // In the initial setup we're loading an old game state, so it doesn't really count
|
if (!initialSetup) { // In the initial setup we're loading an old game state, so it doesn't really count
|
||||||
for (city in citiesReachedToMediums.keys)
|
for (city in citiesReachedToMediums.keys)
|
||||||
if (city !in civInfo.citiesConnectedToCapitalToMediums && city.civInfo == civInfo && city != civInfo.getCapital())
|
if (city !in civInfo.citiesConnectedToCapitalToMediums && city.civInfo == civInfo && city != civInfo.getCapital()!!)
|
||||||
civInfo.addNotification("[${city.name}] has been connected to your capital!", city.location, NotificationIcon.Gold)
|
civInfo.addNotification("[${city.name}] has been connected to your capital!", city.location, NotificationIcon.Gold)
|
||||||
|
|
||||||
// This may still contain cities that have just been destroyed by razing - thus the population test
|
// This may still contain cities that have just been destroyed by razing - thus the population test
|
||||||
|
@ -303,7 +303,7 @@ class CivilizationInfo {
|
|||||||
compareByDescending<CivilizationInfo> { it.isMajorCiv() }
|
compareByDescending<CivilizationInfo> { it.isMajorCiv() }
|
||||||
.thenBy (UncivGame.Current.settings.getCollatorFromLocale()) { it.civName.tr() }
|
.thenBy (UncivGame.Current.settings.getCollatorFromLocale()) { it.civName.tr() }
|
||||||
)
|
)
|
||||||
fun getCapital() = cities.first { it.isCapital() }
|
fun getCapital() = cities.firstOrNull { it.isCapital() }
|
||||||
fun isPlayerCivilization() = playerType == PlayerType.Human
|
fun isPlayerCivilization() = playerType == PlayerType.Human
|
||||||
fun isOneCityChallenger() = (
|
fun isOneCityChallenger() = (
|
||||||
playerType == PlayerType.Human &&
|
playerType == PlayerType.Human &&
|
||||||
@ -536,7 +536,7 @@ class CivilizationInfo {
|
|||||||
if (!(isCityState() && otherCiv.isMajorCiv())) return
|
if (!(isCityState() && otherCiv.isMajorCiv())) return
|
||||||
if (warOnContact || otherCiv.isMinorCivAggressor()) return // No gift if they are bad people, or we are just about to be at war
|
if (warOnContact || otherCiv.isMinorCivAggressor()) return // No gift if they are bad people, or we are just about to be at war
|
||||||
|
|
||||||
val cityStateLocation = if (cities.isEmpty()) null else getCapital().location
|
val cityStateLocation = if (cities.isEmpty()) null else getCapital()!!.location
|
||||||
|
|
||||||
val giftAmount = Stats(gold = 15f)
|
val giftAmount = Stats(gold = 15f)
|
||||||
val faithAmount = Stats(faith = 4f)
|
val faithAmount = Stats(faith = 4f)
|
||||||
@ -563,7 +563,7 @@ class CivilizationInfo {
|
|||||||
otherCiv.addStat(key, value.toInt())
|
otherCiv.addStat(key, value.toInt())
|
||||||
|
|
||||||
if (cities.isNotEmpty())
|
if (cities.isNotEmpty())
|
||||||
otherCiv.exploredTiles = otherCiv.exploredTiles.withItem(getCapital().location)
|
otherCiv.exploredTiles = otherCiv.exploredTiles.withItem(getCapital()!!.location)
|
||||||
|
|
||||||
questManager.justMet(otherCiv) // Include them in war with major pseudo-quest
|
questManager.justMet(otherCiv) // Include them in war with major pseudo-quest
|
||||||
}
|
}
|
||||||
@ -1000,6 +1000,7 @@ class CivilizationInfo {
|
|||||||
flagsCountdown[CivFlags.ShowDiplomaticVotingResults.name] == 0
|
flagsCountdown[CivFlags.ShowDiplomaticVotingResults.name] == 0
|
||||||
&& gameInfo.civilizations.any { it.isMajorCiv() && !it.isDefeated() && it != this }
|
&& gameInfo.civilizations.any { it.isMajorCiv() && !it.isDefeated() && it != this }
|
||||||
|
|
||||||
|
|
||||||
private fun updateRevolts() {
|
private fun updateRevolts() {
|
||||||
if (gameInfo.civilizations.none { it.isBarbarian() }) {
|
if (gameInfo.civilizations.none { it.isBarbarian() }) {
|
||||||
// Can't spawn revolts without barbarians ¯\_(ツ)_/¯
|
// Can't spawn revolts without barbarians ¯\_(ツ)_/¯
|
||||||
@ -1272,7 +1273,7 @@ class CivilizationInfo {
|
|||||||
|
|
||||||
// Check if different continents (unless already max distance, or water map)
|
// Check if different continents (unless already max distance, or water map)
|
||||||
if (connections > 0 && proximity != Proximity.Distant && !gameInfo.tileMap.isWaterMap()
|
if (connections > 0 && proximity != Proximity.Distant && !gameInfo.tileMap.isWaterMap()
|
||||||
&& getCapital().getCenterTile().getContinent() != otherCiv.getCapital().getCenterTile().getContinent()
|
&& getCapital()!!.getCenterTile().getContinent() != otherCiv.getCapital()!!.getCenterTile().getContinent()
|
||||||
) {
|
) {
|
||||||
// Different continents - increase separation by one step
|
// Different continents - increase separation by one step
|
||||||
proximity = when (proximity) {
|
proximity = when (proximity) {
|
||||||
@ -1299,8 +1300,9 @@ class CivilizationInfo {
|
|||||||
* Removes current capital then moves capital to argument city if not null
|
* Removes current capital then moves capital to argument city if not null
|
||||||
*/
|
*/
|
||||||
fun moveCapitalTo(city: CityInfo?) {
|
fun moveCapitalTo(city: CityInfo?) {
|
||||||
if (cities.isNotEmpty()) {
|
if (cities.isNotEmpty() && getCapital() != null) {
|
||||||
getCapital().cityConstructions.removeBuilding(getCapital().capitalCityIndicator())
|
val oldCapital = getCapital()!!
|
||||||
|
oldCapital.cityConstructions.removeBuilding(oldCapital.capitalCityIndicator())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (city == null) return // can't move a non-existent city but we can always remove our old capital
|
if (city == null) return // can't move a non-existent city but we can always remove our old capital
|
||||||
@ -1311,7 +1313,7 @@ class CivilizationInfo {
|
|||||||
|
|
||||||
fun moveCapitalToNextLargest() {
|
fun moveCapitalToNextLargest() {
|
||||||
moveCapitalTo(cities
|
moveCapitalTo(cities
|
||||||
.filterNot { it == getCapital() }
|
.filterNot { it.isCapital() }
|
||||||
.maxByOrNull { it.population.population})
|
.maxByOrNull { it.population.population})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ class QuestManager {
|
|||||||
&& !it.isAtWarWith(civInfo)
|
&& !it.isAtWarWith(civInfo)
|
||||||
&& it.getProximity(civInfo) <= Proximity.Far }) {
|
&& it.getProximity(civInfo) <= Proximity.Far }) {
|
||||||
otherCiv.addNotification("[${civInfo.civName}] is being invaded by Barbarians! Destroy Barbarians near their territory to earn Influence.",
|
otherCiv.addNotification("[${civInfo.civName}] is being invaded by Barbarians! Destroy Barbarians near their territory to earn Influence.",
|
||||||
civInfo.getCapital().location, civInfo.civName, NotificationIcon.War)
|
civInfo.getCapital()!!.location, civInfo.civName, NotificationIcon.War)
|
||||||
}
|
}
|
||||||
civInfo.addFlag(CivFlags.TurnsTillCallForBarbHelp.name, 30)
|
civInfo.addFlag(CivFlags.TurnsTillCallForBarbHelp.name, 30)
|
||||||
}
|
}
|
||||||
@ -358,10 +358,10 @@ class QuestManager {
|
|||||||
return when (quest.name) {
|
return when (quest.name) {
|
||||||
QuestName.ClearBarbarianCamp.value -> getBarbarianEncampmentForQuest() != null
|
QuestName.ClearBarbarianCamp.value -> getBarbarianEncampmentForQuest() != null
|
||||||
QuestName.Route.value -> !challenger.cities.none()
|
QuestName.Route.value -> !challenger.cities.none()
|
||||||
&& !challenger.isCapitalConnectedToCity(civInfo.getCapital())
|
&& !challenger.isCapitalConnectedToCity(civInfo.getCapital()!!)
|
||||||
// Need to have a city within 7 tiles on the same continent
|
// Need to have a city within 7 tiles on the same continent
|
||||||
&& challenger.cities.any { it.getCenterTile().aerialDistanceTo(civInfo.getCapital().getCenterTile()) <= 7
|
&& challenger.cities.any { it.getCenterTile().aerialDistanceTo(civInfo.getCapital()!!.getCenterTile()) <= 7
|
||||||
&& it.getCenterTile().getContinent() == civInfo.getCapital().getCenterTile().getContinent() }
|
&& it.getCenterTile().getContinent() == civInfo.getCapital()!!.getCenterTile().getContinent() }
|
||||||
QuestName.ConnectResource.value -> getResourceForQuest(challenger) != null
|
QuestName.ConnectResource.value -> getResourceForQuest(challenger) != null
|
||||||
QuestName.ConstructWonder.value -> getWonderToBuildForQuest(challenger) != null
|
QuestName.ConstructWonder.value -> getWonderToBuildForQuest(challenger) != null
|
||||||
QuestName.GreatPerson.value -> getGreatPersonForQuest(challenger) != null
|
QuestName.GreatPerson.value -> getGreatPersonForQuest(challenger) != null
|
||||||
@ -373,7 +373,7 @@ class QuestManager {
|
|||||||
&& !challenger.getDiplomacyManager(mostRecentBully).hasFlag(DiplomacyFlags.Denunciation)
|
&& !challenger.getDiplomacyManager(mostRecentBully).hasFlag(DiplomacyFlags.Denunciation)
|
||||||
&& challenger.getDiplomacyManager(mostRecentBully).diplomaticStatus != DiplomaticStatus.War
|
&& challenger.getDiplomacyManager(mostRecentBully).diplomaticStatus != DiplomaticStatus.War
|
||||||
&& !( challenger.playerType == PlayerType.Human && civInfo.gameInfo.getCivilization(mostRecentBully).playerType == PlayerType.Human)
|
&& !( challenger.playerType == PlayerType.Human && civInfo.gameInfo.getCivilization(mostRecentBully).playerType == PlayerType.Human)
|
||||||
QuestName.SpreadReligion.value -> playerReligion != null && civInfo.getCapital().religion.getMajorityReligion()?.name != playerReligion
|
QuestName.SpreadReligion.value -> playerReligion != null && civInfo.getCapital()!!.religion.getMajorityReligion()?.name != playerReligion
|
||||||
QuestName.ConquerCityState.value -> getCityStateTarget(challenger) != null && civInfo.cityStatePersonality != CityStatePersonality.Friendly
|
QuestName.ConquerCityState.value -> getCityStateTarget(challenger) != null && civInfo.cityStatePersonality != CityStatePersonality.Friendly
|
||||||
QuestName.BullyCityState.value -> getCityStateTarget(challenger) != null
|
QuestName.BullyCityState.value -> getCityStateTarget(challenger) != null
|
||||||
QuestName.ContestFaith.value -> civInfo.gameInfo.isReligionEnabled()
|
QuestName.ContestFaith.value -> civInfo.gameInfo.isReligionEnabled()
|
||||||
@ -385,7 +385,7 @@ class QuestManager {
|
|||||||
private fun isComplete(assignedQuest: AssignedQuest): Boolean {
|
private fun isComplete(assignedQuest: AssignedQuest): Boolean {
|
||||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||||
return when (assignedQuest.questName) {
|
return when (assignedQuest.questName) {
|
||||||
QuestName.Route.value -> assignee.isCapitalConnectedToCity(civInfo.getCapital())
|
QuestName.Route.value -> assignee.isCapitalConnectedToCity(civInfo.getCapital()!!)
|
||||||
QuestName.ConnectResource.value -> assignee.detailedCivResources.map { it.resource }.contains(civInfo.gameInfo.ruleSet.tileResources[assignedQuest.data1])
|
QuestName.ConnectResource.value -> assignee.detailedCivResources.map { it.resource }.contains(civInfo.gameInfo.ruleSet.tileResources[assignedQuest.data1])
|
||||||
QuestName.ConstructWonder.value -> assignee.cities.any { it.cityConstructions.isBuilt(assignedQuest.data1) }
|
QuestName.ConstructWonder.value -> assignee.cities.any { it.cityConstructions.isBuilt(assignedQuest.data1) }
|
||||||
QuestName.GreatPerson.value -> assignee.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleSet).name == assignedQuest.data1 }
|
QuestName.GreatPerson.value -> assignee.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleSet).name == assignedQuest.data1 }
|
||||||
@ -393,7 +393,7 @@ class QuestManager {
|
|||||||
QuestName.FindNaturalWonder.value -> assignee.naturalWonders.contains(assignedQuest.data1)
|
QuestName.FindNaturalWonder.value -> assignee.naturalWonders.contains(assignedQuest.data1)
|
||||||
QuestName.PledgeToProtect.value -> assignee in civInfo.getProtectorCivs()
|
QuestName.PledgeToProtect.value -> assignee in civInfo.getProtectorCivs()
|
||||||
QuestName.DenounceCiv.value -> assignee.getDiplomacyManager(assignedQuest.data1).hasFlag(DiplomacyFlags.Denunciation)
|
QuestName.DenounceCiv.value -> assignee.getDiplomacyManager(assignedQuest.data1).hasFlag(DiplomacyFlags.Denunciation)
|
||||||
QuestName.SpreadReligion.value -> civInfo.getCapital().religion.getMajorityReligion() == civInfo.gameInfo.religions[assignedQuest.data2]
|
QuestName.SpreadReligion.value -> civInfo.getCapital()!!.religion.getMajorityReligion() == civInfo.gameInfo.religions[assignedQuest.data2]
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ class QuestManager {
|
|||||||
if (rewardInfluence > 0)
|
if (rewardInfluence > 0)
|
||||||
assignee.addNotification(
|
assignee.addNotification(
|
||||||
"[${civInfo.civName}] rewarded you with [${rewardInfluence.toInt()}] influence for completing the [${assignedQuest.questName}] quest.",
|
"[${civInfo.civName}] rewarded you with [${rewardInfluence.toInt()}] influence for completing the [${assignedQuest.questName}] quest.",
|
||||||
civInfo.getCapital().location, civInfo.civName, "OtherIcons/Quest"
|
civInfo.getCapital()!!.location, civInfo.civName, "OtherIcons/Quest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// We may have received bonuses from city-state friend-ness or ally-ness
|
// We may have received bonuses from city-state friend-ness or ally-ness
|
||||||
@ -436,11 +436,11 @@ class QuestManager {
|
|||||||
if (winners.isEmpty()) {
|
if (winners.isEmpty()) {
|
||||||
assignee.addNotification(
|
assignee.addNotification(
|
||||||
"[${civInfo.civName}] no longer needs your help with the [${assignedQuest.questName}] quest.",
|
"[${civInfo.civName}] no longer needs your help with the [${assignedQuest.questName}] quest.",
|
||||||
civInfo.getCapital().location, civInfo.civName, "OtherIcons/Quest")
|
civInfo.getCapital()!!.location, civInfo.civName, "OtherIcons/Quest")
|
||||||
} else {
|
} else {
|
||||||
assignee.addNotification(
|
assignee.addNotification(
|
||||||
"The [${assignedQuest.questName}] quest for [${civInfo.civName}] has ended. It was won by [${winners.joinToString { it.assignee.tr() }}].",
|
"The [${assignedQuest.questName}] quest for [${civInfo.civName}] has ended. It was won by [${winners.joinToString { it.assignee.tr() }}].",
|
||||||
civInfo.getCapital().location, civInfo.civName, "OtherIcons/Quest")
|
civInfo.getCapital()!!.location, civInfo.civName, "OtherIcons/Quest")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,8 +532,8 @@ class QuestManager {
|
|||||||
unitsToKillForCiv[attacker.civName] = unitsToKill
|
unitsToKillForCiv[attacker.civName] = unitsToKill
|
||||||
|
|
||||||
|
|
||||||
val location = if (civInfo.cities.isEmpty()) null
|
val location = if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) null
|
||||||
else civInfo.getCapital().location
|
else civInfo.getCapital()!!.location
|
||||||
|
|
||||||
// Ask for assistance
|
// Ask for assistance
|
||||||
for (thirdCiv in civInfo.getKnownCivs().filter { it.isAlive() && !it.isAtWarWith(civInfo) && it.isMajorCiv() }) {
|
for (thirdCiv in civInfo.getKnownCivs().filter { it.isAlive() && !it.isAtWarWith(civInfo) && it.isMajorCiv() }) {
|
||||||
@ -571,8 +571,8 @@ class QuestManager {
|
|||||||
|
|
||||||
/** Called when a major civ meets the city-state for the first time. Mainly for war with major pseudo-quest. */
|
/** Called when a major civ meets the city-state for the first time. Mainly for war with major pseudo-quest. */
|
||||||
fun justMet(otherCiv: CivilizationInfo) {
|
fun justMet(otherCiv: CivilizationInfo) {
|
||||||
val location = if (civInfo.cities.isEmpty()) null
|
val location = if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) null
|
||||||
else civInfo.getCapital().location
|
else civInfo.getCapital()!!.location
|
||||||
|
|
||||||
for ((attackerName, unitsToKill) in unitsToKillForCiv) {
|
for ((attackerName, unitsToKill) in unitsToKillForCiv) {
|
||||||
if (location != null)
|
if (location != null)
|
||||||
@ -755,7 +755,7 @@ class QuestManager {
|
|||||||
* to be destroyed
|
* to be destroyed
|
||||||
*/
|
*/
|
||||||
private fun getBarbarianEncampmentForQuest(): TileInfo? {
|
private fun getBarbarianEncampmentForQuest(): TileInfo? {
|
||||||
val encampments = civInfo.getCapital().getCenterTile().getTilesInDistance(8)
|
val encampments = civInfo.getCapital()!!.getCenterTile().getTilesInDistance(8)
|
||||||
.filter { it.improvement == Constants.barbarianEncampment }.toList()
|
.filter { it.improvement == Constants.barbarianEncampment }.toList()
|
||||||
|
|
||||||
if (encampments.isNotEmpty())
|
if (encampments.isNotEmpty())
|
||||||
@ -923,7 +923,7 @@ class AssignedQuest(val questName: String = "",
|
|||||||
}
|
}
|
||||||
QuestName.Route.value -> {
|
QuestName.Route.value -> {
|
||||||
game.resetToWorldScreen()
|
game.resetToWorldScreen()
|
||||||
game.worldScreen.mapHolder.setCenterPosition(gameInfo.getCivilization(assigner).getCapital().location, selectUnit = false)
|
game.worldScreen.mapHolder.setCenterPosition(gameInfo.getCivilization(assigner).getCapital()!!.location, selectUnit = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,9 +240,9 @@ class DiplomacyManager() {
|
|||||||
for (unique in otherCiv().getMatchingUniques(UniqueType.CityStateRestingPoint))
|
for (unique in otherCiv().getMatchingUniques(UniqueType.CityStateRestingPoint))
|
||||||
restingPoint += unique.params[0].toInt()
|
restingPoint += unique.params[0].toInt()
|
||||||
|
|
||||||
if (civInfo.cities.any()) // no capital if no cities
|
if (civInfo.cities.any() && civInfo.getCapital() != null)
|
||||||
for (unique in otherCiv().getMatchingUniques(UniqueType.RestingPointOfCityStatesFollowingReligionChange))
|
for (unique in otherCiv().getMatchingUniques(UniqueType.RestingPointOfCityStatesFollowingReligionChange))
|
||||||
if (otherCiv().religionManager.religion?.name == civInfo.getCapital().religion.getMajorityReligionName())
|
if (otherCiv().religionManager.religion?.name == civInfo.getCapital()!!.religion.getMajorityReligionName())
|
||||||
restingPoint += unique.params[0].toInt()
|
restingPoint += unique.params[0].toInt()
|
||||||
|
|
||||||
if (diplomaticStatus == DiplomaticStatus.Protector) restingPoint += 10
|
if (diplomaticStatus == DiplomaticStatus.Protector) restingPoint += 10
|
||||||
@ -266,8 +266,8 @@ class DiplomacyManager() {
|
|||||||
for (unique in otherCiv().getMatchingUniques(UniqueType.CityStateInfluenceDegradation))
|
for (unique in otherCiv().getMatchingUniques(UniqueType.CityStateInfluenceDegradation))
|
||||||
modifierPercent += unique.params[0].toFloat()
|
modifierPercent += unique.params[0].toFloat()
|
||||||
|
|
||||||
val religion = if (civInfo.cities.isEmpty()) null
|
val religion = if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) null
|
||||||
else civInfo.getCapital().religion.getMajorityReligionName()
|
else civInfo.getCapital()!!.religion.getMajorityReligionName()
|
||||||
if (religion != null && religion == otherCiv().religionManager.religion?.name)
|
if (religion != null && religion == otherCiv().religionManager.religion?.name)
|
||||||
modifierPercent -= 25f // 25% slower degrade when sharing a religion
|
modifierPercent -= 25f // 25% slower degrade when sharing a religion
|
||||||
|
|
||||||
@ -291,8 +291,8 @@ class DiplomacyManager() {
|
|||||||
if (otherCiv().hasUnique(UniqueType.CityStateInfluenceRecoversTwiceNormalRate))
|
if (otherCiv().hasUnique(UniqueType.CityStateInfluenceRecoversTwiceNormalRate))
|
||||||
modifierPercent += 100f
|
modifierPercent += 100f
|
||||||
|
|
||||||
val religion = if (civInfo.cities.isEmpty()) null
|
val religion = if (civInfo.cities.isEmpty() || civInfo.getCapital() == null) null
|
||||||
else civInfo.getCapital().religion.getMajorityReligionName()
|
else civInfo.getCapital()!!.religion.getMajorityReligionName()
|
||||||
if (religion != null && religion == otherCiv().religionManager.religion?.name)
|
if (religion != null && religion == otherCiv().religionManager.religion?.name)
|
||||||
modifierPercent += 50f // 50% quicker recovery when sharing a religion
|
modifierPercent += 50f // 50% quicker recovery when sharing a religion
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!civInfo.isDefeated()) { // don't display city state relationship notifications when the city state is currently defeated
|
if (!civInfo.isDefeated()) { // don't display city state relationship notifications when the city state is currently defeated
|
||||||
val civCapitalLocation = if (civInfo.cities.isNotEmpty()) civInfo.getCapital().location else null
|
val civCapitalLocation = if (civInfo.cities.isNotEmpty() || civInfo.getCapital() != null) civInfo.getCapital()!!.location else null
|
||||||
if (getTurnsToRelationshipChange() == 1) {
|
if (getTurnsToRelationshipChange() == 1) {
|
||||||
val text = "Your relationship with [${civInfo.civName}] is about to degrade"
|
val text = "Your relationship with [${civInfo.civName}] is about to degrade"
|
||||||
if (civCapitalLocation != null) otherCiv().addNotification(text, civCapitalLocation, civInfo.civName, NotificationIcon.Diplomacy)
|
if (civCapitalLocation != null) otherCiv().addNotification(text, civCapitalLocation, civInfo.civName, NotificationIcon.Diplomacy)
|
||||||
|
@ -230,7 +230,7 @@ class TradeEvaluation {
|
|||||||
val city = civInfo.cities.firstOrNull { it.id == offer.name }
|
val city = civInfo.cities.firstOrNull { it.id == offer.name }
|
||||||
?: throw Exception("Got an offer to sell city id " + offer.name + " which does't seem to exist for this civ!")
|
?: throw Exception("Got an offer to sell city id " + offer.name + " which does't seem to exist for this civ!")
|
||||||
|
|
||||||
val capitalcity = civInfo.getCapital()
|
val capitalcity = civInfo.getCapital()!!
|
||||||
val distanceCost = distanceCityTradeModifier(civInfo, capitalcity, city)
|
val distanceCost = distanceCityTradeModifier(civInfo, capitalcity, city)
|
||||||
val stats = city.cityStats.currentCityStats
|
val stats = city.cityStats.currentCityStats
|
||||||
val sumOfStats =
|
val sumOfStats =
|
||||||
|
@ -219,8 +219,8 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
|
|||||||
}
|
}
|
||||||
UniqueType.ConditionalForeignContinent ->
|
UniqueType.ConditionalForeignContinent ->
|
||||||
state.civInfo != null && relevantTile != null
|
state.civInfo != null && relevantTile != null
|
||||||
&& (state.civInfo.cities.isEmpty()
|
&& (state.civInfo.cities.isEmpty() || state.civInfo.getCapital() == null
|
||||||
|| state.civInfo.getCapital().getCenterTile().getContinent()
|
|| state.civInfo.getCapital()!!.getCenterTile().getContinent()
|
||||||
!= relevantTile!!.getContinent()
|
!= relevantTile!!.getContinent()
|
||||||
)
|
)
|
||||||
UniqueType.ConditionalAdjacentUnit ->
|
UniqueType.ConditionalAdjacentUnit ->
|
||||||
|
@ -491,7 +491,7 @@ class DiplomacyScreen(
|
|||||||
return diplomacyTable
|
return diplomacyTable
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getImprovableResourceTiles(otherCiv:CivilizationInfo) = otherCiv.getCapital().getTiles().filter {
|
fun getImprovableResourceTiles(otherCiv:CivilizationInfo) = otherCiv.getCapital()!!.getTiles().filter {
|
||||||
it.hasViewableResource(otherCiv)
|
it.hasViewableResource(otherCiv)
|
||||||
&& it.tileResource.resourceType != ResourceType.Bonus
|
&& it.tileResource.resourceType != ResourceType.Bonus
|
||||||
&& (it.improvement == null || !it.tileResource.isImprovedBy(it.improvement!!))
|
&& (it.improvement == null || !it.tileResource.isImprovedBy(it.improvement!!))
|
||||||
@ -751,7 +751,7 @@ class DiplomacyScreen(
|
|||||||
diplomacyTable.add(demandsButton).row()
|
diplomacyTable.add(demandsButton).row()
|
||||||
if (isNotPlayersTurn()) demandsButton.disable()
|
if (isNotPlayersTurn()) demandsButton.disable()
|
||||||
|
|
||||||
if (otherCiv.cities.isNotEmpty() && otherCiv.getCapital().location in viewingCiv.exploredTiles)
|
if (otherCiv.cities.isNotEmpty() && otherCiv.getCapital() != null && otherCiv.getCapital()!!.location in viewingCiv.exploredTiles)
|
||||||
diplomacyTable.add(getGoToOnMapButton(otherCiv)).row()
|
diplomacyTable.add(getGoToOnMapButton(otherCiv)).row()
|
||||||
|
|
||||||
if (!otherCiv.isPlayerCivilization()) { // human players make their own choices
|
if (!otherCiv.isPlayerCivilization()) { // human players make their own choices
|
||||||
@ -938,7 +938,7 @@ class DiplomacyScreen(
|
|||||||
val goToOnMapButton = "Go to on map".toTextButton()
|
val goToOnMapButton = "Go to on map".toTextButton()
|
||||||
goToOnMapButton.onClick {
|
goToOnMapButton.onClick {
|
||||||
UncivGame.Current.resetToWorldScreen()
|
UncivGame.Current.resetToWorldScreen()
|
||||||
UncivGame.Current.worldScreen.mapHolder.setCenterPosition(civilization.getCapital().location, selectUnit = false)
|
UncivGame.Current.worldScreen.mapHolder.setCenterPosition(civilization.getCapital()!!.location, selectUnit = false)
|
||||||
}
|
}
|
||||||
return goToOnMapButton
|
return goToOnMapButton
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
|
|
||||||
val tileToCenterOn: Vector2 =
|
val tileToCenterOn: Vector2 =
|
||||||
when {
|
when {
|
||||||
viewingCiv.cities.isNotEmpty() -> viewingCiv.getCapital().location
|
viewingCiv.cities.isNotEmpty() && viewingCiv.getCapital() != null -> viewingCiv.getCapital()!!.location
|
||||||
viewingCiv.getCivUnits().any() -> viewingCiv.getCivUnits().first().getTile().position
|
viewingCiv.getCivUnits().any() -> viewingCiv.getCivUnits().first().getTile().position
|
||||||
else -> Vector2.Zero
|
else -> Vector2.Zero
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
keyPressDispatcher[Input.Keys.F12] = quickLoad // Quick Load
|
keyPressDispatcher[Input.Keys.F12] = quickLoad // Quick Load
|
||||||
keyPressDispatcher[Input.Keys.HOME] = { // Capital City View
|
keyPressDispatcher[Input.Keys.HOME] = { // Capital City View
|
||||||
val capital = gameInfo.currentPlayerCiv.getCapital()
|
val capital = gameInfo.currentPlayerCiv.getCapital()
|
||||||
if (!mapHolder.setCenterPosition(capital.location))
|
if (capital != null && !mapHolder.setCenterPosition(capital.location))
|
||||||
game.setScreen(CityScreen(capital))
|
game.setScreen(CityScreen(capital))
|
||||||
}
|
}
|
||||||
keyPressDispatcher[KeyCharAndCode.ctrl('O')] = { // Game Options
|
keyPressDispatcher[KeyCharAndCode.ctrl('O')] = { // Game Options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user