mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 06:08:46 +07:00
Civ city name generation now done by a global counter - enables city name changes later
This commit is contained in:
@ -41,16 +41,18 @@ class CityInfo {
|
|||||||
this.location = cityLocation
|
this.location = cityLocation
|
||||||
setTransients()
|
setTransients()
|
||||||
|
|
||||||
// Since cities can be captures between civilizations,
|
val nationCities = civInfo.getNation().cities
|
||||||
// we need to check which other cities exist globally and name accordingly
|
val cityNameIndex = civInfo.citiesCreated % nationCities.size
|
||||||
val allExistingCityNames = civInfo.gameInfo.civilizations.flatMap { it.cities }.map { it.name }.toHashSet()
|
val cityName = nationCities[cityNameIndex]
|
||||||
val probablyName = civInfo.getNation().cities.firstOrNull { !allExistingCityNames.contains(it) }
|
|
||||||
if(probablyName!=null) name=probablyName
|
val cityNameRounds = civInfo.citiesCreated / nationCities.size
|
||||||
else {
|
val cityNamePrefix = if(cityNameRounds==0) ""
|
||||||
val newName = civInfo.getNation().cities.map { "New $it" }.firstOrNull{ !allExistingCityNames.contains(it) }
|
else if(cityNameRounds==2) "New "
|
||||||
if(newName!=null) name=newName
|
else "Newer "
|
||||||
else name = civInfo.getNation().cities.map { "Newer $it" }.first{ !allExistingCityNames.contains(it) }
|
|
||||||
}
|
name = cityNamePrefix + cityName
|
||||||
|
|
||||||
|
civInfo.citiesCreated++
|
||||||
|
|
||||||
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
|
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
|
||||||
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
||||||
|
@ -58,6 +58,7 @@ class CivilizationInfo {
|
|||||||
// we won't get concurrent modification exceptions.
|
// we won't get concurrent modification exceptions.
|
||||||
// This is basically a way to ensure our lists are immutable.
|
// This is basically a way to ensure our lists are immutable.
|
||||||
var cities = listOf<CityInfo>()
|
var cities = listOf<CityInfo>()
|
||||||
|
var citiesCreated = 0
|
||||||
var exploredTiles = HashSet<Vector2>()
|
var exploredTiles = HashSet<Vector2>()
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
@ -303,6 +304,9 @@ class CivilizationInfo {
|
|||||||
if(policies.adoptedPolicies.size>0 && policies.numberOfAdoptedPolicies == 0)
|
if(policies.adoptedPolicies.size>0 && policies.numberOfAdoptedPolicies == 0)
|
||||||
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !it.endsWith("Complete") }
|
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !it.endsWith("Complete") }
|
||||||
|
|
||||||
|
if(citiesCreated==0 && cities.any())
|
||||||
|
citiesCreated = cities.filter { it.name in getNation().cities }.count()
|
||||||
|
|
||||||
tech.civInfo = this
|
tech.civInfo = this
|
||||||
tech.setTransients()
|
tech.setTransients()
|
||||||
diplomacy.values.forEach { it.civInfo=this}
|
diplomacy.values.forEach { it.civInfo=this}
|
||||||
|
Reference in New Issue
Block a user