Bombard notification (#5637)

* add notification when able to bombard

* harmonize with enemy unit notification

* use city.range
This commit is contained in:
SimonCeder 2021-11-04 17:36:50 +01:00 committed by GitHub
parent 25cad3aef2
commit 010931ca42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 649 additions and 624 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@ -579,6 +579,8 @@ Our [attackerName] was attacked by an intercepting [interceptorName] =
Our [interceptorName] intercepted and attacked an enemy [attackerName] =
An enemy [unit] was spotted near our territory =
An enemy [unit] was spotted in our territory =
Your city [cityName] can bombard the enemy! =
[amount] of your cities can bombard the enemy! =
[amount] enemy units were spotted near our territory =
[amount] enemy units were spotted in our territory =
A(n) [nukeType] exploded in our territory! =

View File

@ -279,6 +279,12 @@ class GameInfo {
enemyUnitsCloseToTerritory.filter { it.getOwner() != thisPlayer },
"near"
)
addBombardNotification(thisPlayer,
thisPlayer.cities.filter { city -> city.canBombard() &&
enemyUnitsCloseToTerritory.any { tile -> tile.aerialDistanceTo(city.getCenterTile()) <= city.range }
}
)
}
private fun addEnemyUnitNotification(thisPlayer: CivilizationInfo, tiles: List<TileInfo>, inOrNear: String) {
@ -294,6 +300,15 @@ class GameInfo {
}
}
private fun addBombardNotification(thisPlayer: CivilizationInfo, cities: List<CityInfo>) {
if (cities.count() < 3) {
for (city in cities)
thisPlayer.addNotification("Your city [${city.name}] can bombard the enemy!", city.location, NotificationIcon.City, NotificationIcon.Crosshair)
} else
thisPlayer.addNotification("[${cities.count()}] of your cities can bombard the enemy!", LocationAction(cities.map { it.location }), NotificationIcon.City, NotificationIcon.Crosshair)
}
fun notifyExploredResources(civInfo: CivilizationInfo, resourceName: String, maxDistance: Int, showForeign: Boolean) {
// Calling with `maxDistance = 0` removes distance limitation.
data class CityTileAndDistance(val city: CityInfo, val tile: TileInfo, val distance: Int)

View File

@ -28,6 +28,7 @@ object NotificationIcon {
const val Production = "StatIcons/Production"
const val Food = "StatIcons/Food"
const val Faith = "StatIcons/Faith"
const val Crosshair = "OtherIcons/CrosshairB"
}
/**