Added mutually exclusive tech paths using "Incompatible with [otherTech]" unique for techs

This commit is contained in:
Yair Morgenstern 2021-01-30 19:59:34 +02:00
parent bc4829a424
commit 8016a64b97
2 changed files with 13 additions and 4 deletions

View File

@ -119,6 +119,8 @@ class TechManager {
fun canBeResearched(techName: String): Boolean {
val tech = getRuleset().technologies[techName]!!
if (tech.uniqueObjects.any { it.placeholderText=="Incompatible with []" && isResearched(it.params[0]) })
return false
if (isResearched(tech.name) && !tech.isContinuallyResearchable())
return false
return tech.prerequisites.all { isResearched(it) }
@ -128,7 +130,7 @@ class TechManager {
//endregion
fun getRequiredTechsToDestination(destinationTech: Technology): List<String> {
fun getRequiredTechsToDestination(destinationTech: Technology): List<Technology> {
val prerequisites = Stack<Technology>()
val checkPrerequisites = ArrayDeque<Technology>()
@ -146,7 +148,7 @@ class TechManager {
prerequisites.add(techToCheck)
}
return prerequisites.sortedBy { it.column!!.columnNumber }.map { it.name }
return prerequisites.sortedBy { it.column!!.columnNumber }
}
fun getScienceFromGreatScientist(): Int {

View File

@ -248,10 +248,17 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
return
}
val pathToTech = civTech.getRequiredTechsToDestination(tech)
for (requiredTech in pathToTech)
for (unique in requiredTech.uniqueObjects)
if (unique.placeholderText == "Incompatible with []" && civTech.isResearched(unique.params[0])) {
rightSideButton.setText(unique.text.tr())
rightSideButton.disable()
return
}
tempTechsToResearch.clear()
tempTechsToResearch.addAll(civTech.getRequiredTechsToDestination(tech))
tempTechsToResearch.addAll(pathToTech.map { it.name })
pick("Research [${tempTechsToResearch[0]}]".tr())
setButtonsInfo()