mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Resolved #3326 - Settling a city removes the improvement in progress
This commit is contained in:
parent
5e116867e6
commit
86c6624f8e
@ -71,18 +71,17 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
* For more infos: https://developer.android.com/training/notify-user/channels.html#CreateChannel
|
||||
*/
|
||||
fun createNotificationChannelInfo(appContext: Context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val name = appContext.resources.getString(R.string.Notify_ChannelInfo_Short)
|
||||
val descriptionText = appContext.resources.getString(R.string.Notify_ChannelInfo_Long)
|
||||
val importance = NotificationManager.IMPORTANCE_HIGH
|
||||
val mChannel = NotificationChannel(NOTIFICATION_CHANNEL_ID_INFO, name, importance)
|
||||
mChannel.description = descriptionText
|
||||
mChannel.setShowBadge(true)
|
||||
mChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
||||
val name = appContext.resources.getString(R.string.Notify_ChannelInfo_Short)
|
||||
val descriptionText = appContext.resources.getString(R.string.Notify_ChannelInfo_Long)
|
||||
val importance = NotificationManager.IMPORTANCE_HIGH
|
||||
val mChannel = NotificationChannel(NOTIFICATION_CHANNEL_ID_INFO, name, importance)
|
||||
mChannel.description = descriptionText
|
||||
mChannel.setShowBadge(true)
|
||||
mChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
|
||||
val notificationManager = appContext.getSystemService(AndroidApplication.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(mChannel)
|
||||
}
|
||||
val notificationManager = appContext.getSystemService(AndroidApplication.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(mChannel)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,18 +92,17 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
* For more infos: https://developer.android.com/training/notify-user/channels.html#CreateChannel
|
||||
*/
|
||||
fun createNotificationChannelService(appContext: Context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val name = appContext.resources.getString(R.string.Notify_ChannelService_Short)
|
||||
val descriptionText = appContext.resources.getString(R.string.Notify_ChannelService_Long)
|
||||
val importance = NotificationManager.IMPORTANCE_MIN
|
||||
val mChannel = NotificationChannel(NOTIFICATION_CHANNEL_ID_SERVICE, name, importance)
|
||||
mChannel.setShowBadge(false)
|
||||
mChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
mChannel.description = descriptionText
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
||||
val name = appContext.resources.getString(R.string.Notify_ChannelService_Short)
|
||||
val descriptionText = appContext.resources.getString(R.string.Notify_ChannelService_Long)
|
||||
val importance = NotificationManager.IMPORTANCE_MIN
|
||||
val mChannel = NotificationChannel(NOTIFICATION_CHANNEL_ID_SERVICE, name, importance)
|
||||
mChannel.setShowBadge(false)
|
||||
mChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
mChannel.description = descriptionText
|
||||
|
||||
val notificationManager = appContext.getSystemService(AndroidApplication.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(mChannel)
|
||||
}
|
||||
val notificationManager = appContext.getSystemService(AndroidApplication.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.createNotificationChannel(mChannel)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,12 +192,11 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
|
||||
* Therefore Unciv needs to create new ones and delete legacy ones.
|
||||
*/
|
||||
private fun destroyOldChannels(appContext: Context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val notificationManager = appContext.getSystemService(AndroidApplication.NOTIFICATION_SERVICE) as NotificationManager
|
||||
HISTORIC_NOTIFICATION_CHANNELS.forEach {
|
||||
if (null != notificationManager.getNotificationChannel(it)) {
|
||||
notificationManager.deleteNotificationChannel(it)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
||||
val notificationManager = appContext.getSystemService(AndroidApplication.NOTIFICATION_SERVICE) as NotificationManager
|
||||
HISTORIC_NOTIFICATION_CHANNELS.forEach {
|
||||
if (null != notificationManager.getNotificationChannel(it)) {
|
||||
notificationManager.deleteNotificationChannel(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,16 +76,7 @@ class CityInfo {
|
||||
this.location = cityLocation
|
||||
setTransients()
|
||||
|
||||
val nationCities = civInfo.nation.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==1) "New "
|
||||
else "Neo "
|
||||
|
||||
name = cityNamePrefix + cityName
|
||||
setNewCityName(civInfo)
|
||||
|
||||
isOriginalCapital = civInfo.citiesCreated == 0
|
||||
civInfo.citiesCreated++
|
||||
@ -93,21 +84,22 @@ class CityInfo {
|
||||
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
|
||||
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
||||
|
||||
if (civInfo.cities.size == 1) {
|
||||
cityConstructions.addBuilding(capitalCityIndicator())
|
||||
}
|
||||
if (civInfo.cities.size == 1) cityConstructions.addBuilding(capitalCityIndicator())
|
||||
|
||||
civInfo.policies.tryAddLegalismBuildings()
|
||||
|
||||
expansion.reset()
|
||||
|
||||
val tile = getCenterTile()
|
||||
|
||||
tryUpdateRoadStatus()
|
||||
|
||||
if (getRuleset().tileImprovements.containsKey("Remove "+tile.terrainFeature))
|
||||
val tile = getCenterTile()
|
||||
if (getRuleset().tileImprovements.containsKey("Remove " + tile.terrainFeature))
|
||||
tile.terrainFeature = null
|
||||
|
||||
tile.improvement = null
|
||||
tile.improvementInProgress = null
|
||||
|
||||
workedTiles = hashSetOf() //reassign 1st working tile
|
||||
population.autoAssignPopulation()
|
||||
cityStats.update()
|
||||
@ -115,6 +107,19 @@ class CityInfo {
|
||||
triggerCitiesSettledNearOtherCiv()
|
||||
}
|
||||
|
||||
private fun setNewCityName(civInfo: CivilizationInfo) {
|
||||
val nationCities = civInfo.nation.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 == 1) "New "
|
||||
else "Neo "
|
||||
|
||||
name = cityNamePrefix + cityName
|
||||
}
|
||||
|
||||
|
||||
//region pure functions
|
||||
fun clone(): CityInfo {
|
||||
|
@ -349,7 +349,8 @@ class MapUnit {
|
||||
if (tile.improvementInProgress == "Remove Road" || tile.improvementInProgress == "Remove Railroad")
|
||||
tile.roadStatus = RoadStatus.None
|
||||
else {
|
||||
if (tile.tileMap.gameInfo.ruleSet.terrains[tile.terrainFeature]!!.uniques
|
||||
// We put "tile.terrainFeature!=null" because of a strange edge case that SHOULD be solved from 3.11.11+, so we should remove it then and see
|
||||
if (tile.terrainFeature!=null && tile.tileMap.gameInfo.ruleSet.terrains[tile.terrainFeature!!]!!.uniques
|
||||
.contains("Provides a one-time Production bonus to the closest city when cut down"))
|
||||
tryProvideProductionToClosestCity()
|
||||
tile.terrainFeature = null
|
||||
|
@ -137,7 +137,6 @@ object UnitActions {
|
||||
action = {
|
||||
UncivGame.Current.settings.addCompletedTutorialTask("Found city")
|
||||
unit.civInfo.addCity(tile.position)
|
||||
tile.improvement = null
|
||||
unit.destroy()
|
||||
}.takeIf { unit.currentMovement > 0 && !tile.getTilesInDistance(3).any { it.isCityCenter() } })
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user