From 4df083197bccaf8db75af8c08a7a948efdcc2802 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 28 May 2021 14:54:02 +0300 Subject: [PATCH] City-states get all civs known by at least half of major civs, not 'by any civ' --- .../unciv/logic/automation/NextTurnAutomation.kt | 14 +++++++------- .../unciv/ui/cityscreen/CityConstructionsTable.kt | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index a8514d766e..fa6b93f0e3 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -141,13 +141,13 @@ object NextTurnAutomation { } private fun getFreeTechForCityStates(civInfo: CivilizationInfo) { - //City-States automatically get all invented techs - for (otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }) { - for (entry in otherCiv.tech.techsResearched - .filterNot { civInfo.tech.isResearched(it) } - .filter { civInfo.tech.canBeResearched(it) }) { - civInfo.tech.addTechnology(entry) - } + // City-States automatically get all techs that at least half of the major civs know + val researchableTechs = civInfo.gameInfo.ruleSet.technologies.keys + .filter { civInfo.tech.canBeResearched(it) } + for (tech in researchableTechs) { + val aliveMajorCivs = civInfo.gameInfo.getAliveMajorCivs() + if (aliveMajorCivs.count { it.tech.isResearched(tech) } >= aliveMajorCivs.count() / 2) + civInfo.tech.addTechnology(tech) } return } diff --git a/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt index c36d7998fd..08b8d26273 100644 --- a/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt @@ -18,7 +18,6 @@ import com.unciv.models.stats.Stat import com.unciv.models.translations.tr import com.unciv.ui.utils.* import kotlin.concurrent.thread -import kotlin.math.min import com.unciv.ui.utils.AutoScrollPane as ScrollPane class CityConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScreen.skin) {