mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-24 22:59:34 +07:00
Unified science addition logic
This commit is contained in:
@ -174,28 +174,26 @@ class TechManager {
|
|||||||
|
|
||||||
fun nextTurn(scienceForNewTurn: Int) {
|
fun nextTurn(scienceForNewTurn: Int) {
|
||||||
addCurrentScienceToScienceOfLast8Turns()
|
addCurrentScienceToScienceOfLast8Turns()
|
||||||
val currentTechnology = currentTechnologyName()
|
if (currentTechnologyName() == null) return
|
||||||
if (currentTechnology == null) return
|
|
||||||
techsInProgress[currentTechnology] = researchOfTech(currentTechnology) + scienceForNewTurn
|
var finalScienceToAdd = scienceForNewTurn
|
||||||
|
|
||||||
if (scienceFromResearchAgreements != 0) {
|
if (scienceFromResearchAgreements != 0) {
|
||||||
techsInProgress[currentTechnology] = techsInProgress[currentTechnology]!! + scienceFromResearchAgreements()
|
finalScienceToAdd += scienceFromResearchAgreements()
|
||||||
scienceFromResearchAgreements = 0
|
scienceFromResearchAgreements = 0
|
||||||
}
|
}
|
||||||
if (overflowScience != 0) { // https://forums.civfanatics.com/threads/the-mechanics-of-overflow-inflation.517970/
|
if (overflowScience != 0) { // https://forums.civfanatics.com/threads/the-mechanics-of-overflow-inflation.517970/
|
||||||
val techsResearchedKnownCivs = civInfo.getKnownCivs()
|
val techsResearchedKnownCivs = civInfo.getKnownCivs()
|
||||||
.count { it.isMajorCiv() && it.tech.isResearched(currentTechnologyName()!!) }
|
.count { it.isMajorCiv() && it.tech.isResearched(currentTechnologyName()!!) }
|
||||||
val undefeatedCivs = civInfo.gameInfo.civilizations.count { it.isMajorCiv() && !it.isDefeated() }
|
val undefeatedCivs = civInfo.gameInfo.civilizations.count { it.isMajorCiv() && !it.isDefeated() }
|
||||||
techsInProgress[currentTechnology] = techsInProgress[currentTechnology]!! + ((1 + techsResearchedKnownCivs / undefeatedCivs.toFloat() * 0.3f) * overflowScience).toInt()
|
val finalScienceFromOverflow = ((1 + techsResearchedKnownCivs / undefeatedCivs.toFloat() * 0.3f) * overflowScience).toInt()
|
||||||
|
finalScienceToAdd += finalScienceFromOverflow
|
||||||
overflowScience = 0
|
overflowScience = 0
|
||||||
}
|
}
|
||||||
if (techsInProgress[currentTechnology]!! < costOfTech(currentTechnology))
|
|
||||||
return
|
|
||||||
|
|
||||||
// We finished it!
|
addScience(finalScienceToAdd)
|
||||||
val overflowscience = techsInProgress[currentTechnology]!! - costOfTech(currentTechnology)
|
|
||||||
overflowScience = limitOverflowScience(overflowscience)
|
|
||||||
addTechnology(currentTechnology)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addScience(scienceGet : Int) {
|
fun addScience(scienceGet : Int) {
|
||||||
val currentTechnology = currentTechnologyName()
|
val currentTechnology = currentTechnologyName()
|
||||||
if (currentTechnology == null) return
|
if (currentTechnology == null) return
|
||||||
@ -209,6 +207,7 @@ class TechManager {
|
|||||||
overflowScience += limitOverflowScience(extraScienceLeftOver)
|
overflowScience += limitOverflowScience(extraScienceLeftOver)
|
||||||
addTechnology(currentTechnology)
|
addTechnology(currentTechnology)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFreeTechnology(techName: String) {
|
fun getFreeTechnology(techName: String) {
|
||||||
freeTechs--
|
freeTechs--
|
||||||
addTechnology(techName)
|
addTechnology(techName)
|
||||||
@ -297,14 +296,11 @@ class TechManager {
|
|||||||
|
|
||||||
fun updateTransientBooleans() {
|
fun updateTransientBooleans() {
|
||||||
wayfinding = civInfo.hasUnique("Can embark and move over Coasts and Oceans immediately")
|
wayfinding = civInfo.hasUnique("Can embark and move over Coasts and Oceans immediately")
|
||||||
if (researchedTechUniques.contains("Enables embarkation for land units") || wayfinding)
|
unitsCanEmbark = wayfinding || researchedTechUniques.contains("Enables embarkation for land units")
|
||||||
unitsCanEmbark = true
|
|
||||||
|
|
||||||
if (researchedTechUniques.contains("Enables embarked units to enter ocean tiles") || wayfinding)
|
embarkedUnitsCanEnterOcean = wayfinding || researchedTechUniques.contains("Enables embarked units to enter ocean tiles")
|
||||||
embarkedUnitsCanEnterOcean = true
|
movementSpeedOnRoadsImproved = researchedTechUniques.contains("Improves movement speed on roads")
|
||||||
|
roadsConnectAcrossRivers = researchedTechUniques.contains("Roads connect tiles across rivers")
|
||||||
if (researchedTechUniques.contains("Improves movement speed on roads")) movementSpeedOnRoadsImproved = true
|
|
||||||
if (researchedTechUniques.contains("Roads connect tiles across rivers")) roadsConnectAcrossRivers = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBestRoadAvailable(): RoadStatus {
|
fun getBestRoadAvailable(): RoadStatus {
|
||||||
|
Reference in New Issue
Block a user