Visual indicator for building outside workable tiles 9486 (#9935)

* Added warning to improvement picker buttons for improvements out of range for population to work

City population can not work tiles farther than 3 tiles from the city center. The improvement picker did not warn that improvements providing stat increases would not be workable, so the improvement might be worthless. The ImprovementPicker screen will now warn on the improvement button if the improvement provides a stat increase, but is farther than 3 tiles from the owning city center. The warning happens for all improvements that increase the tile stats, including Luxury and Strategic resource improvements. The warning does not disallow building the improvement.

* Changed methods for finding positive stat increases and added translation for warning text

* Condensed conditional for warning text in ImprovementPicker
This commit is contained in:
Brian 2023-08-21 11:16:07 -04:00 committed by GitHub
parent f3ff1033ea
commit f7415bf0a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -1172,6 +1172,7 @@ Pick improvement =
Provides [resource] =
Provides [amount] [resource] =
Replaces [improvement] =
Not in city work range =
Pick now! =
Remove [feature] first =
Research [tech] first =

View File

@ -163,6 +163,18 @@ class ImprovementPickerScreen(
tile.getCity(),
cityUniqueCache
)
//Warn when the current improvement will increase a stat for the tile,
// but the tile is outside of the range (> 3 tiles from city center) that can be
// worked by a city's population
if (stats.values.any { it > 0f }
&& !improvement.name.startsWith(Constants.remove)
&& !improvement.isRoad()
&& tile.owningCity != null
&& !tile.owningCity!!.getWorkableTiles().contains(tile)
)
labelText += "\n" + "Not in city work range".tr()
val statsTable = getStatsTable(stats)
statIcons.add(statsTable).padLeft(13f)