Future tech fix (#8917)

* Future Tech - fix research progress

* Some minor linting

* Tech - Prefer kotlin libraries
This commit is contained in:
SomeTroglodyte 2023-03-16 10:24:08 +01:00 committed by GitHub
parent 9a112728c1
commit 461fc4f191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -66,7 +66,8 @@ data class CompatibilityVersion(
} }
data class VictoryData(val winningCiv: String, val victoryType: String, val victoryTurn: Int) { data class VictoryData(val winningCiv: String, val victoryType: String, val victoryTurn: Int) {
constructor(): this("","",0) // for serializer @Suppress("unused") // used by json serialization
constructor(): this("","",0)
} }
class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion { class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion {
@ -419,7 +420,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
} }
/** Generate a notification pointing out resources. /** Generate a notification pointing out resources.
* Used by [addTechnology][TechManager.addTechnology] and [ResourcesOverviewTab][com.unciv.ui.overviewscreen.ResourcesOverviewTab] * Used by [addTechnology][TechManager.addTechnology] and [ResourcesOverviewTab][com.unciv.ui.screens.overviewscreen.ResourcesOverviewTab]
* @param maxDistance from next City, 0 removes distance limitation. * @param maxDistance from next City, 0 removes distance limitation.
* @param showForeign Disables filter to exclude foreign territory. * @param showForeign Disables filter to exclude foreign territory.
* @return `false` if no resources were found and no notification was added. * @return `false` if no resources were found and no notification was added.
@ -546,12 +547,11 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
convertFortify() convertFortify()
for (civInfo in sequence { for (civInfo in civilizations.asSequence()
// update city-state resource first since the happiness of major civ depends on it. // update city-state resource first since the happiness of major civ depends on it.
// See issue: https://github.com/yairm210/Unciv/issues/7781 // See issue: https://github.com/yairm210/Unciv/issues/7781
yieldAll(civilizations.filter { it.isCityState() }) .sortedByDescending { it.isCityState() }
yieldAll(civilizations.filter { !it.isCityState() }) ) {
}) {
for (unit in civInfo.units.getCivUnits()) for (unit in civInfo.units.getCivUnits())
unit.updateVisibleTiles(false) // this needs to be done after all the units are assigned to their civs and all other transients are set unit.updateVisibleTiles(false) // this needs to be done after all the units are assigned to their civs and all other transients are set
if(civInfo.playerType == PlayerType.Human) if(civInfo.playerType == PlayerType.Human)

View File

@ -23,7 +23,6 @@ import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.ui.components.MayaCalendar import com.unciv.ui.components.MayaCalendar
import com.unciv.ui.components.extensions.toPercent import com.unciv.ui.components.extensions.toPercent
import com.unciv.ui.components.extensions.withItem import com.unciv.ui.components.extensions.withItem
import java.util.*
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.max import kotlin.math.max
import kotlin.math.min import kotlin.math.min
@ -153,13 +152,13 @@ class TechManager : IsPartOfGameInfoSerialization {
//endregion //endregion
fun getRequiredTechsToDestination(destinationTech: Technology): List<Technology> { fun getRequiredTechsToDestination(destinationTech: Technology): List<Technology> {
val prerequisites = Stack<Technology>() val prerequisites = mutableListOf<Technology>()
val checkPrerequisites = ArrayDeque<Technology>() val checkPrerequisites = ArrayDeque<Technology>()
checkPrerequisites.add(destinationTech) checkPrerequisites.add(destinationTech)
while (!checkPrerequisites.isEmpty()) { while (!checkPrerequisites.isEmpty()) {
val techToCheck = checkPrerequisites.pop() val techToCheck = checkPrerequisites.removeFirst()
// future tech can have been researched even when we're researching it, // future tech can have been researched even when we're researching it,
// so...if we skip it we'll end up with 0 techs in the "required techs", which will mean that we don't have anything to research. Yeah. // so...if we skip it we'll end up with 0 techs in the "required techs", which will mean that we don't have anything to research. Yeah.
if (!techToCheck.isContinuallyResearchable() && if (!techToCheck.isContinuallyResearchable() &&
@ -256,6 +255,7 @@ class TechManager : IsPartOfGameInfoSerialization {
techsToResearch.remove(techName) techsToResearch.remove(techName)
else else
repeatingTechsResearched++ repeatingTechsResearched++
techsInProgress.remove(techName)
researchedTechnologies = researchedTechnologies.withItem(newTech) researchedTechnologies = researchedTechnologies.withItem(newTech)
addTechToTransients(newTech) addTechToTransients(newTech)