mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 05:14:32 -04:00
Added mutually exclusive tech paths using "Incompatible with [otherTech]" unique for techs
This commit is contained in:
parent
bc4829a424
commit
8016a64b97
@ -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 {
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user