Console: civ addtech / civ removetech commands

This commit is contained in:
yairm210
2024-06-09 19:25:44 +03:00
parent 616a297f49
commit d61df7fe51
2 changed files with 26 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package com.unciv.ui.screens.devconsole
import com.unciv.logic.civilization.PlayerType
import com.unciv.models.ruleset.Policy
import com.unciv.models.ruleset.tech.Technology
import com.unciv.models.ruleset.unique.Unique
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
import com.unciv.models.stats.Stat
@ -59,5 +60,29 @@ internal class ConsoleCivCommands : ConsoleCommandNode {
DevConsoleResponse.OK
}
},
"addtech" to ConsoleAction("civ addtechnology <civName> <techName>") { console, params ->
val civ = console.getCivByName(params[0])
val tech = console.findCliInput<Technology>(params[1])
?: throw ConsoleErrorException("Unrecognized technology")
if (civ.tech.isResearched(tech.name))
DevConsoleResponse.hint("${civ.civName} already has researched ${tech.name}")
else {
civ.tech.addTechnology(tech.name, false)
DevConsoleResponse.OK
}
},
"removetech" to ConsoleAction("civ removetechnology <civName> <techName>") { console, params ->
val civ = console.getCivByName(params[0])
val tech = console.findCliInput<Technology>(params[1])
?: throw ConsoleErrorException("Unrecognized technology")
if (!civ.tech.isResearched(tech.name))
DevConsoleResponse.hint("${civ.civName} does not have ${tech.name}")
else {
civ.tech.techsResearched.removeAll { it == tech.name } // Can have multiple for researchable techs
DevConsoleResponse.OK
}
},
)
}

View File

@ -32,6 +32,7 @@ internal enum class ConsoleParameterType(
buildingName( { ruleset.buildings.keys } ),
direction( { RiverGenerator.RiverDirections.names } ),
policyName( { ruleset.policyBranches.keys + ruleset.policies.keys } ),
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 ),
;