This commit is contained in:
SomeTroglodyte
2024-01-08 11:23:13 +01:00
parent cbea5e1a14
commit 7936c87962

View File

@ -166,39 +166,41 @@ object GameStarter {
}
private fun addCivTechs(gameInfo: GameInfo, ruleset: Ruleset, gameSetupInfo: GameSetupInfo) {
for (civInfo in gameInfo.civilizations.filter { !it.isBarbarian() }) {
fun Civilization.addTechSilently(name: String) {
// check if the technology is in the ruleset and not already researched
if (!ruleset.technologies.containsKey(name)) return
if (tech.isResearched(name)) return
tech.addTechnology(name, false)
}
for(tech in ruleset.technologies.values.filter { it.hasUnique(UniqueType.StartingTech) })
{
civInfo.tech.addTechnology(tech.name, false)
}
for (civInfo in gameInfo.civilizations) {
if (civInfo.isBarbarian()) continue
for (tech in ruleset.technologies.values.filter { it.hasUnique(UniqueType.StartingTech) })
civInfo.addTechSilently(tech.name)
if (!civInfo.isHuman())
for (tech in gameInfo.getDifficulty().aiFreeTechs)
civInfo.tech.addTechnology(tech, false)
civInfo.addTechSilently(tech)
// generic start with technology unique
for (unique in civInfo.getMatchingUniques(UniqueType.StartsWithTech)) {
// get the parameter from the unique
val techName = unique.params[0]
// check if the technology is in the ruleset and not already researched
if (ruleset.technologies.containsKey(techName) && !civInfo.tech.isResearched(techName))
civInfo.tech.addTechnology(techName, false)
}
for (unique in civInfo.getMatchingUniques(UniqueType.StartsWithTech))
civInfo.addTechSilently(unique.params[0])
// add all techs to spectators
if (civInfo.isSpectator())
for (tech in ruleset.technologies.values)
if (!civInfo.tech.isResearched(tech.name))
civInfo.tech.addTechnology(tech.name, false)
civInfo.addTechSilently(tech.name)
for (tech in ruleset.technologies.values
.filter { ruleset.eras[it.era()]!!.eraNumber < ruleset.eras[gameSetupInfo.gameParameters.startingEra]!!.eraNumber })
if (!civInfo.tech.isResearched(tech.name))
civInfo.tech.addTechnology(tech.name, false)
// Add techs for advanced starting era
val startingEraNumber = ruleset.eras[gameSetupInfo.gameParameters.startingEra]!!.eraNumber
for (tech in ruleset.technologies.values) {
if (ruleset.eras[tech.era()]!!.eraNumber >= startingEraNumber) continue
civInfo.addTechSilently(tech.name)
}
civInfo.popupAlerts.clear() // Since adding technologies generates popups...
// Since adding technologies generates popups (addTechnology parameter showNotification only suppresses Notifications)
civInfo.popupAlerts.clear()
}
}