mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 03:38:55 +07:00
Console: civ addtech
/ civ removetech
commands
This commit is contained in:
@ -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
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -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 ),
|
||||
;
|
||||
|
Reference in New Issue
Block a user