From 9ef3fec0ea9858087ec55563748e70fad3b7b2f3 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Mon, 10 Jun 2024 21:22:56 +0200 Subject: [PATCH] Reenable console `unit sethealth ` and `setmovement` with trailing blank (#11726) --- .../com/unciv/ui/screens/devconsole/ConsoleUnitCommands.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/screens/devconsole/ConsoleUnitCommands.kt b/core/src/com/unciv/ui/screens/devconsole/ConsoleUnitCommands.kt index da814ee0ad..9aa593c71d 100644 --- a/core/src/com/unciv/ui/screens/devconsole/ConsoleUnitCommands.kt +++ b/core/src/com/unciv/ui/screens/devconsole/ConsoleUnitCommands.kt @@ -59,14 +59,14 @@ internal class ConsoleUnitCommands : ConsoleCommandNode { "setmovement" to ConsoleAction("unit setmovement [amount]") { console, params -> // Note amount defaults to maxMovement, but is not limited by it - it's an arbitrary choice to allow that val unit = console.getSelectedUnit() - val movement = params.firstOrNull()?.toFloat() ?: unit.getMaxMovement().toFloat() + val movement = params.firstOrNull()?.takeUnless { it.isEmpty() }?.toFloat() ?: unit.getMaxMovement().toFloat() if (movement < 0f) throw ConsoleErrorException("Number out of range") unit.currentMovement = movement DevConsoleResponse.OK }, "sethealth" to ConsoleAction("unit sethealth [amount]") { console, params -> - val health = params.firstOrNull()?.toInt() ?: 100 + val health = params.firstOrNull()?.takeUnless { it.isEmpty() }?.toInt() ?: 100 if (health !in 1..100) throw ConsoleErrorException("Number out of range") val unit = console.getSelectedUnit() unit.health = health