From f7415bf0a99d691cd6bd1e5fea787b05dee8ac0b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 21 Aug 2023 11:16:07 -0400 Subject: [PATCH] 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 --- .../assets/jsons/translations/template.properties | 1 + .../screens/pickerscreens/ImprovementPickerScreen.kt | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 18ebe6e9ac..24af28d408 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -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 = diff --git a/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt index 8c85d71d30..f3457debc9 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt @@ -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)