mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
Console command to change difficulty (#12039)
This commit is contained in:
@ -149,7 +149,7 @@ class DiplomacyFunctions(val civInfo: Civilization) {
|
|||||||
fun canPassThroughTiles(otherCiv: Civilization): Boolean {
|
fun canPassThroughTiles(otherCiv: Civilization): Boolean {
|
||||||
if (otherCiv == civInfo) return true
|
if (otherCiv == civInfo) return true
|
||||||
if (otherCiv.isBarbarian) return true
|
if (otherCiv.isBarbarian) return true
|
||||||
if (civInfo.isBarbarian && civInfo.gameInfo.turns >= civInfo.gameInfo.difficultyObject.turnBarbariansCanEnterPlayerTiles)
|
if (civInfo.isBarbarian && civInfo.gameInfo.turns >= civInfo.gameInfo.getDifficulty().turnBarbariansCanEnterPlayerTiles)
|
||||||
return true
|
return true
|
||||||
val diplomacyManager = civInfo.diplomacy[otherCiv.civName]
|
val diplomacyManager = civInfo.diplomacy[otherCiv.civName]
|
||||||
if (diplomacyManager != null && (diplomacyManager.hasOpenBorders || diplomacyManager.diplomaticStatus == DiplomaticStatus.War))
|
if (diplomacyManager != null && (diplomacyManager.hasOpenBorders || diplomacyManager.diplomaticStatus == DiplomaticStatus.War))
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.unciv.ui.screens.devconsole
|
||||||
|
|
||||||
|
internal class ConsoleGameCommands : ConsoleCommandNode {
|
||||||
|
override val subcommands = hashMapOf<String, ConsoleCommand>(
|
||||||
|
"setdifficulty" to ConsoleAction("game setdifficulty <difficulty>") { console, params ->
|
||||||
|
val difficulty = params[0].findOrNull(console.gameInfo.ruleset.difficulties.values)
|
||||||
|
?: throw ConsoleErrorException("Unrecognized difficulty")
|
||||||
|
console.gameInfo.difficulty = difficulty.name
|
||||||
|
console.gameInfo.setTransients()
|
||||||
|
DevConsoleResponse.OK
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
@ -35,6 +35,7 @@ internal enum class ConsoleParameterType(
|
|||||||
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.values().filter { it.canAcceptUniqueTarget(UniqueTarget.Triggerable) }.map { it.text } }, preferquoted = true ),
|
||||||
|
difficulty( { ruleset.difficulties.keys } )
|
||||||
;
|
;
|
||||||
|
|
||||||
private fun getOptions(console: DevConsolePopup) = console.gameInfo.getOptions()
|
private fun getOptions(console: DevConsolePopup) = console.gameInfo.getOptions()
|
||||||
|
@ -91,6 +91,7 @@ internal class ConsoleCommandRoot : ConsoleCommandNode {
|
|||||||
"history" to ConsoleAction("history") { console, _ ->
|
"history" to ConsoleAction("history") { console, _ ->
|
||||||
console.showHistory()
|
console.showHistory()
|
||||||
DevConsoleResponse.hint("") // Trick console into staying open
|
DevConsoleResponse.hint("") // Trick console into staying open
|
||||||
}
|
},
|
||||||
|
"game" to ConsoleGameCommands()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user