mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-13 06:12:17 -04:00
Resolved #12521 - Added 'tile setpillaged' to dev console commands
This commit is contained in:
parent
a14c78f28d
commit
86b6fbf7bc
@ -138,6 +138,10 @@ internal class CliInput(
|
|||||||
* @throws ConsoleErrorException if the string is not a valid representation of a number. */
|
* @throws ConsoleErrorException if the string is not a valid representation of a number. */
|
||||||
fun toFloat(): Float = content.toFloatOrNull() ?: throw ConsoleErrorException("'$this' is not a valid number.")
|
fun toFloat(): Float = content.toFloatOrNull() ?: throw ConsoleErrorException("'$this' is not a valid number.")
|
||||||
|
|
||||||
|
/** Parses `this` parameter as a Boolean.
|
||||||
|
* @throws ConsoleErrorException if the string is not 'true' or 'false'. */
|
||||||
|
fun toBoolean(): Boolean = content.toBooleanStrictOrNull() ?: throw ConsoleErrorException("'$this' is not a valid boolean value.")
|
||||||
|
|
||||||
/** Parses `this` parameter as the name of a [Stat].
|
/** Parses `this` parameter as the name of a [Stat].
|
||||||
* @throws ConsoleErrorException if the string is not a Stat name. */
|
* @throws ConsoleErrorException if the string is not a Stat name. */
|
||||||
fun toStat(): Stat = enumValueOrNull<Stat>() ?: throw ConsoleErrorException("'$this' is not an acceptable Stat.")
|
fun toStat(): Stat = enumValueOrNull<Stat>() ?: throw ConsoleErrorException("'$this' is not an acceptable Stat.")
|
||||||
|
@ -34,14 +34,15 @@ internal enum class ConsoleParameterType(
|
|||||||
policyName( { ruleset.policyBranches.keys + ruleset.policies.keys } ),
|
policyName( { ruleset.policyBranches.keys + ruleset.policies.keys } ),
|
||||||
techName( { ruleset.technologies.keys } ),
|
techName( { ruleset.technologies.keys } ),
|
||||||
cityName( { civilizations.flatMap { civ -> civ.cities.map { it.name } } } ),
|
cityName( { civilizations.flatMap { civ -> civ.cities.map { it.name } } } ),
|
||||||
triggeredUniqueTemplate( { UniqueType.values().filter { it.canAcceptUniqueTarget(UniqueTarget.Triggerable) }.map { it.text } }, preferquoted = true ),
|
triggeredUniqueTemplate( { UniqueType.entries.filter { it.canAcceptUniqueTarget(UniqueTarget.Triggerable) }.map { it.text } }, preferquoted = true ),
|
||||||
difficulty( { ruleset.difficulties.keys } )
|
difficulty( { ruleset.difficulties.keys } ),
|
||||||
|
boolean( { listOf("true", "false") }),
|
||||||
;
|
;
|
||||||
|
|
||||||
private fun getOptions(console: DevConsolePopup) = console.gameInfo.getOptions()
|
private fun getOptions(console: DevConsolePopup) = console.gameInfo.getOptions()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun safeValueOf(name: String): ConsoleParameterType = values().firstOrNull { it.name == name } ?: none
|
fun safeValueOf(name: String): ConsoleParameterType = entries.firstOrNull { it.name == name } ?: none
|
||||||
fun getOptions(name: String, console: DevConsolePopup) = safeValueOf(name).let { type ->
|
fun getOptions(name: String, console: DevConsolePopup) = safeValueOf(name).let { type ->
|
||||||
if (type.preferquoted) type.getOptions(console).map { CliInput(it, CliInput.Method.Quoted) }
|
if (type.preferquoted) type.getOptions(console).map { CliInput(it, CliInput.Method.Quoted) }
|
||||||
else type.getOptions(console).map { CliInput(it) }
|
else type.getOptions(console).map { CliInput(it) }
|
||||||
|
@ -39,6 +39,14 @@ internal class ConsoleTileCommands: ConsoleCommandNode {
|
|||||||
DevConsoleResponse.OK
|
DevConsoleResponse.OK
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"setpillaged" to ConsoleAction("tile setpillaged <boolean>"){ console, params ->
|
||||||
|
val selectedTile = console.getSelectedTile()
|
||||||
|
val setPillaged = params[0].toBoolean()
|
||||||
|
if (setPillaged) selectedTile.setPillaged()
|
||||||
|
else selectedTile.setRepaired()
|
||||||
|
DevConsoleResponse.OK
|
||||||
|
},
|
||||||
|
|
||||||
"removeroad" to ConsoleAction("tile removeroad") { console, _ ->
|
"removeroad" to ConsoleAction("tile removeroad") { console, _ ->
|
||||||
val selectedTile = console.getSelectedTile()
|
val selectedTile = console.getSelectedTile()
|
||||||
selectedTile.removeRoad()
|
selectedTile.removeRoad()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user