mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 00:39:56 +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 {
|
||||
if (otherCiv == civInfo) 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
|
||||
val diplomacyManager = civInfo.diplomacy[otherCiv.civName]
|
||||
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 } ),
|
||||
cityName( { civilizations.flatMap { civ -> civ.cities.map { it.name } } } ),
|
||||
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()
|
||||
|
@ -91,6 +91,7 @@ internal class ConsoleCommandRoot : ConsoleCommandNode {
|
||||
"history" to ConsoleAction("history") { console, _ ->
|
||||
console.showHistory()
|
||||
DevConsoleResponse.hint("") // Trick console into staying open
|
||||
}
|
||||
},
|
||||
"game" to ConsoleGameCommands()
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user