mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 00:08:58 +07:00
AI chooses to fortify in non-bombardable tiles if possible
Can choose replacement building for Palace to indicate the capital city
This commit is contained in:
@ -1 +0,0 @@
|
|||||||
{checkForDueUnits:false,tutorialsShown:[Happiness,EnemyCity,BarbarianEncountered,ContactMe,NaturalWonders,IdleUnits,Embarking,Experience,GoldenAge,InjuredUnits,Introduction,Workers,CityExpansion,RoadsAndRailroads,SiegeUnits,OtherCivEncountered,CultureAndPolicies,EnemyCityNeedsConqueringWithMeleeUnit,SlowStart,ApolloProgram,Unhappiness],tutorialTasksCompleted:[See your stats breakdown,Enter city screen,Found city,Open the options table,Create a trade route,Conquer a city,Pick construction,Move an air unit,Move unit,Pick technology,Reassign worked tiles,Meet another civilization,Pass a turn,Construct an improvement],soundEffectsVolume:0,musicVolume:0,userId:77da158d-f67a-4c7f-9a4c-535209ed0adf,windowState:{width:1206,height:492},extendedMapEditor:true,spectatorMode:true}
|
|
@ -618,7 +618,6 @@
|
|||||||
"strength": 20,
|
"strength": 20,
|
||||||
"cost": 110,
|
"cost": 110,
|
||||||
"requiredTech": "Chivalry",
|
"requiredTech": "Chivalry",
|
||||||
"obsoleteTech": "Military Science",
|
|
||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"upgradesTo": "Cavalry",
|
"upgradesTo": "Cavalry",
|
||||||
"obsoleteTech": "Military Science",
|
"obsoleteTech": "Military Science",
|
||||||
|
@ -188,8 +188,11 @@ object UnitAutomation {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
val bestTilesForHealing = tilesByHealingRate.maxBy { it.key }!!.value
|
var bestTilesForHealing = tilesByHealingRate.maxBy { it.key }!!.value
|
||||||
// within the tiles with best healing rate (say 15), we'll prefer one which has the highest defensive bonuses
|
// within the tiles with best healing rate (say 15), we'll prefer one which has the highest defensive bonuses
|
||||||
|
val bestTilesWithoutBombardableTiles = bestTilesForHealing.filterNot { it.getTilesInDistance(2)
|
||||||
|
.any { it.isCityCenter() && it.getOwner()!!.isAtWarWith(unit.civInfo) } }
|
||||||
|
if(bestTilesWithoutBombardableTiles.any()) bestTilesForHealing = bestTilesWithoutBombardableTiles
|
||||||
val bestTileForHealing = bestTilesForHealing.maxBy { it.getDefensiveBonus() }!!
|
val bestTileForHealing = bestTilesForHealing.maxBy { it.getDefensiveBonus() }!!
|
||||||
val bestTileForHealingRank = unit.rankTileForHealing(bestTileForHealing)
|
val bestTileForHealingRank = unit.rankTileForHealing(bestTileForHealing)
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import com.unciv.logic.map.TileMap
|
|||||||
import com.unciv.logic.trade.TradeLogic
|
import com.unciv.logic.trade.TradeLogic
|
||||||
import com.unciv.logic.trade.TradeOffer
|
import com.unciv.logic.trade.TradeOffer
|
||||||
import com.unciv.logic.trade.TradeType
|
import com.unciv.logic.trade.TradeType
|
||||||
|
import com.unciv.models.ruleset.Building
|
||||||
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
||||||
import com.unciv.models.ruleset.tile.ResourceType
|
import com.unciv.models.ruleset.tile.ResourceType
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
@ -93,7 +94,7 @@ class CityInfo {
|
|||||||
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
||||||
|
|
||||||
if (civInfo.cities.size == 1) {
|
if (civInfo.cities.size == 1) {
|
||||||
cityConstructions.addBuilding("Palace")
|
cityConstructions.addBuilding(capitalCityIndicator())
|
||||||
}
|
}
|
||||||
|
|
||||||
civInfo.policies.tryAddLegalismBuildings()
|
civInfo.policies.tryAddLegalismBuildings()
|
||||||
@ -144,7 +145,9 @@ class CityInfo {
|
|||||||
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
|
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
|
||||||
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
|
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
|
||||||
|
|
||||||
fun isCapital() = cityConstructions.isBuilt("Palace")
|
fun isCapital(): Boolean = cityConstructions.builtBuildings.contains(capitalCityIndicator())
|
||||||
|
fun capitalCityIndicator(): String = getRuleset().buildings.values.first { it.uniques.contains("Indicates the capital city") }.name
|
||||||
|
|
||||||
fun isConnectedToCapital(connectionTypePredicate: (Set<String>) -> Boolean = {true}): Boolean {
|
fun isConnectedToCapital(connectionTypePredicate: (Set<String>) -> Boolean = {true}): Boolean {
|
||||||
val mediumTypes = civInfo.citiesConnectedToCapitalToMediums[this] ?: return false
|
val mediumTypes = civInfo.citiesConnectedToCapitalToMediums[this] ?: return false
|
||||||
return connectionTypePredicate(mediumTypes)
|
return connectionTypePredicate(mediumTypes)
|
||||||
@ -372,8 +375,10 @@ class CityInfo {
|
|||||||
civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) }
|
civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) }
|
||||||
getCenterTile().improvement = "City ruins"
|
getCenterTile().improvement = "City ruins"
|
||||||
|
|
||||||
if (isCapital() && civInfo.cities.isNotEmpty()) // Move the capital if destroyed (by a nuke or by razing)
|
if (isCapital() && civInfo.cities.isNotEmpty()) { // Move the capital if destroyed (by a nuke or by razing)
|
||||||
civInfo.cities.first().cityConstructions.addBuilding("Palace")
|
val capitalCityBuilding = getRuleset().buildings.values.first { it.uniques.contains("Indicates the capital city") }
|
||||||
|
civInfo.cities.first().cityConstructions.addBuilding(capitalCityBuilding.name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun annexCity() {
|
fun annexCity() {
|
||||||
@ -460,7 +465,7 @@ class CityInfo {
|
|||||||
health = getMaxHealth() / 2 // I think that cities recover to half health when conquered?
|
health = getMaxHealth() / 2 // I think that cities recover to half health when conquered?
|
||||||
reassignPopulation()
|
reassignPopulation()
|
||||||
|
|
||||||
if (foundingCiv.cities.size == 1) cityConstructions.addBuilding("Palace") // Resurrection!
|
if (foundingCiv.cities.size == 1) cityConstructions.addBuilding(capitalCityIndicator()) // Resurrection!
|
||||||
isPuppet = false
|
isPuppet = false
|
||||||
cityStats.update()
|
cityStats.update()
|
||||||
|
|
||||||
@ -521,16 +526,17 @@ class CityInfo {
|
|||||||
cityConstructions.removeBuilding(building.name)
|
cityConstructions.removeBuilding(building.name)
|
||||||
|
|
||||||
// Remove/relocate palace for old Civ
|
// Remove/relocate palace for old Civ
|
||||||
if(cityConstructions.isBuilt("Palace")){
|
val capitalCityIndicator = capitalCityIndicator()
|
||||||
cityConstructions.removeBuilding("Palace")
|
if(cityConstructions.isBuilt(capitalCityIndicator)){
|
||||||
|
cityConstructions.removeBuilding(capitalCityIndicator)
|
||||||
if(oldCiv.cities.isNotEmpty()){
|
if(oldCiv.cities.isNotEmpty()){
|
||||||
oldCiv.cities.first().cityConstructions.addBuilding("Palace") // relocate palace
|
oldCiv.cities.first().cityConstructions.addBuilding(capitalCityIndicator) // relocate palace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate palace for newCiv if this is the only city they have
|
// Locate palace for newCiv if this is the only city they have
|
||||||
if (newCivInfo.cities.count() == 1) {
|
if (newCivInfo.cities.count() == 1) {
|
||||||
cityConstructions.addBuilding("Palace")
|
cityConstructions.addBuilding(capitalCityIndicator)
|
||||||
}
|
}
|
||||||
|
|
||||||
isBeingRazed=false
|
isBeingRazed=false
|
||||||
|
@ -29,8 +29,6 @@ import kotlin.math.roundToInt
|
|||||||
|
|
||||||
class CivilizationInfo {
|
class CivilizationInfo {
|
||||||
|
|
||||||
@Transient private val jsonParser = JsonParser()
|
|
||||||
|
|
||||||
@Transient lateinit var gameInfo: GameInfo
|
@Transient lateinit var gameInfo: GameInfo
|
||||||
@Transient lateinit var nation:Nation
|
@Transient lateinit var nation:Nation
|
||||||
/**
|
/**
|
||||||
@ -410,7 +408,7 @@ class CivilizationInfo {
|
|||||||
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
|
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
|
||||||
if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
|
if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
|
||||||
val greatPerson = greatPeople.getNewGreatPerson()
|
val greatPerson = greatPeople.getNewGreatPerson()
|
||||||
if (greatPerson != null) addUnit(greatPerson)
|
if (greatPerson != null && gameInfo.ruleSet.units.containsKey(greatPerson)) addUnit(greatPerson)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
|
updateViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
|
||||||
|
Reference in New Issue
Block a user