mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 04:38:18 +07:00
Console: city addtile <cityName>
takes an optional [radius]
parameter
This commit is contained in:
@ -40,13 +40,17 @@ internal class ConsoleCityCommands : ConsoleCommandNode {
|
||||
DevConsoleResponse.OK
|
||||
},
|
||||
|
||||
"addtile" to ConsoleAction("city addtile <cityName>") { console, params ->
|
||||
"addtile" to ConsoleAction("city addtile <cityName> [radius]") { console, params ->
|
||||
val selectedTile = console.getSelectedTile()
|
||||
val city = console.getCity(params[0])
|
||||
if (selectedTile.neighbors.none { it.getCity() == city })
|
||||
throw ConsoleErrorException("Tile is not adjacent to any tile already owned by the city")
|
||||
if (selectedTile.isCityCenter()) throw ConsoleErrorException("Cannot transfer city center")
|
||||
city.expansion.takeOwnership(selectedTile)
|
||||
val radius = params.getOrNull(1)?.toInt() ?: 0
|
||||
for (tile in selectedTile.getTilesInDistance(radius)) {
|
||||
if (tile.getCity() != city && !tile.isCityCenter())
|
||||
city.expansion.takeOwnership(tile)
|
||||
}
|
||||
DevConsoleResponse.OK
|
||||
},
|
||||
|
||||
|
@ -163,7 +163,7 @@ class DevConsolePopup(val screen: WorldScreen) : Popup(screen) {
|
||||
}
|
||||
|
||||
private fun handleCommand(): DevConsoleResponse {
|
||||
val params = textField.text.splitToCliInput()
|
||||
val params = textField.text.trim().splitToCliInput()
|
||||
return commandRoot.handle(this, params)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user