Civ city name generation now done by a global counter - enables city name changes later

This commit is contained in:
Yair Morgenstern 2019-02-10 09:50:36 +02:00
parent cc0a999471
commit 4b7a447eae
2 changed files with 16 additions and 10 deletions

View file

@ -41,16 +41,18 @@ class CityInfo {
this.location = cityLocation
setTransients()
// Since cities can be captures between civilizations,
// we need to check which other cities exist globally and name accordingly
val allExistingCityNames = civInfo.gameInfo.civilizations.flatMap { it.cities }.map { it.name }.toHashSet()
val probablyName = civInfo.getNation().cities.firstOrNull { !allExistingCityNames.contains(it) }
if(probablyName!=null) name=probablyName
else {
val newName = civInfo.getNation().cities.map { "New $it" }.firstOrNull{ !allExistingCityNames.contains(it) }
if(newName!=null) name=newName
else name = civInfo.getNation().cities.map { "Newer $it" }.first{ !allExistingCityNames.contains(it) }
}
val nationCities = civInfo.getNation().cities
val cityNameIndex = civInfo.citiesCreated % nationCities.size
val cityName = nationCities[cityNameIndex]
val cityNameRounds = civInfo.citiesCreated / nationCities.size
val cityNamePrefix = if(cityNameRounds==0) ""
else if(cityNameRounds==2) "New "
else "Newer "
name = cityNamePrefix + cityName
civInfo.citiesCreated++
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)

View file

@ -58,6 +58,7 @@ class CivilizationInfo {
// we won't get concurrent modification exceptions.
// This is basically a way to ensure our lists are immutable.
var cities = listOf<CityInfo>()
var citiesCreated = 0
var exploredTiles = HashSet<Vector2>()
constructor()
@ -303,6 +304,9 @@ class CivilizationInfo {
if(policies.adoptedPolicies.size>0 && policies.numberOfAdoptedPolicies == 0)
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.setTransients()
diplomacy.values.forEach { it.civInfo=this}