mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-26 07:39:44 +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
|
DevConsoleResponse.OK
|
||||||
},
|
},
|
||||||
|
|
||||||
"addtile" to ConsoleAction("city addtile <cityName>") { console, params ->
|
"addtile" to ConsoleAction("city addtile <cityName> [radius]") { console, params ->
|
||||||
val selectedTile = console.getSelectedTile()
|
val selectedTile = console.getSelectedTile()
|
||||||
val city = console.getCity(params[0])
|
val city = console.getCity(params[0])
|
||||||
if (selectedTile.neighbors.none { it.getCity() == city })
|
if (selectedTile.neighbors.none { it.getCity() == city })
|
||||||
throw ConsoleErrorException("Tile is not adjacent to any tile already owned by the city")
|
throw ConsoleErrorException("Tile is not adjacent to any tile already owned by the city")
|
||||||
if (selectedTile.isCityCenter()) throw ConsoleErrorException("Cannot transfer city center")
|
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
|
DevConsoleResponse.OK
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class DevConsolePopup(val screen: WorldScreen) : Popup(screen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleCommand(): DevConsoleResponse {
|
private fun handleCommand(): DevConsoleResponse {
|
||||||
val params = textField.text.splitToCliInput()
|
val params = textField.text.trim().splitToCliInput()
|
||||||
return commandRoot.handle(this, params)
|
return commandRoot.handle(this, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user