mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Added building-maintenance-decreasing unique
This commit is contained in:
parent
83427fec85
commit
93f0b4ae42
@ -1,6 +1,5 @@
|
|||||||
package com.unciv.logic.city
|
package com.unciv.logic.city
|
||||||
|
|
||||||
import com.unciv.Constants
|
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.civilization.CityStateType
|
import com.unciv.logic.civilization.CityStateType
|
||||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||||
@ -9,7 +8,6 @@ import com.unciv.models.Counter
|
|||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.ruleset.unit.UnitType
|
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
|
|
||||||
@ -417,7 +415,7 @@ class CityStats {
|
|||||||
updateCityHappiness()
|
updateCityHappiness()
|
||||||
updateStatPercentBonusList(currentConstruction, citySpecificUniques)
|
updateStatPercentBonusList(currentConstruction, citySpecificUniques)
|
||||||
|
|
||||||
updateFinalStatList(currentConstruction) // again, we don't edit the existing currentCityStats directly, in order to avoid concurrency exceptions
|
updateFinalStatList(currentConstruction, citySpecificUniques) // again, we don't edit the existing currentCityStats directly, in order to avoid concurrency exceptions
|
||||||
|
|
||||||
val newCurrentCityStats = Stats()
|
val newCurrentCityStats = Stats()
|
||||||
for (stat in finalStatList.values) newCurrentCityStats.add(stat)
|
for (stat in finalStatList.values) newCurrentCityStats.add(stat)
|
||||||
@ -426,7 +424,7 @@ class CityStats {
|
|||||||
cityInfo.civInfo.updateStatsForNextTurn()
|
cityInfo.civInfo.updateStatsForNextTurn()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFinalStatList(currentConstruction: IConstruction) {
|
private fun updateFinalStatList(currentConstruction: IConstruction, citySpecificUniques: Sequence<Unique>) {
|
||||||
val newFinalStatList = LinkedHashMap<String, Stats>() // again, we don't edit the existing currentCityStats directly, in order to avoid concurrency exceptions
|
val newFinalStatList = LinkedHashMap<String, Stats>() // again, we don't edit the existing currentCityStats directly, in order to avoid concurrency exceptions
|
||||||
|
|
||||||
for (entry in baseStatList)
|
for (entry in baseStatList)
|
||||||
@ -490,12 +488,7 @@ class CityStats {
|
|||||||
totalFood = newFinalStatList.values.map { it.food }.sum() // recalculate again
|
totalFood = newFinalStatList.values.map { it.food }.sum() // recalculate again
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val buildingsMaintenance = getBuildingMaintenanceCosts(citySpecificUniques) // this is AFTER the bonus calculation!
|
||||||
// Same here - will have a different UI display.
|
|
||||||
var buildingsMaintenance = cityInfo.cityConstructions.getMaintenanceCosts().toFloat() // this is AFTER the bonus calculation!
|
|
||||||
if (!cityInfo.civInfo.isPlayerCivilization()) {
|
|
||||||
buildingsMaintenance *= cityInfo.civInfo.gameInfo.getDifficulty().aiBuildingMaintenanceModifier
|
|
||||||
}
|
|
||||||
newFinalStatList["Maintenance"] = Stats().apply { gold -= buildingsMaintenance.toInt() }
|
newFinalStatList["Maintenance"] = Stats().apply { gold -= buildingsMaintenance.toInt() }
|
||||||
|
|
||||||
|
|
||||||
@ -513,6 +506,21 @@ class CityStats {
|
|||||||
finalStatList = newFinalStatList
|
finalStatList = newFinalStatList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getBuildingMaintenanceCosts(citySpecificUniques: Sequence<Unique>): Float {
|
||||||
|
// Same here - will have a different UI display.
|
||||||
|
var buildingsMaintenance = cityInfo.cityConstructions.getMaintenanceCosts().toFloat() // this is AFTER the bonus calculation!
|
||||||
|
if (!cityInfo.civInfo.isPlayerCivilization()) {
|
||||||
|
buildingsMaintenance *= cityInfo.civInfo.gameInfo.getDifficulty().aiBuildingMaintenanceModifier
|
||||||
|
}
|
||||||
|
|
||||||
|
// e.g. "-[50]% Maintenance costs [in this city]"
|
||||||
|
val maintenanceUniqueTemplate = "-[]% building maintenance costs []"
|
||||||
|
val maintenanceUniques = citySpecificUniques.filter { it.placeholderText == maintenanceUniqueTemplate } +
|
||||||
|
cityInfo.civInfo.getMatchingUniques(maintenanceUniqueTemplate).filter { cityInfo.matchesFilter(it.params[1]) }
|
||||||
|
for (unique in maintenanceUniques) buildingsMaintenance *= (1f - unique.params[0].toFloat() / 100)
|
||||||
|
return buildingsMaintenance
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateFoodEaten() {
|
private fun updateFoodEaten() {
|
||||||
foodEaten = cityInfo.population.population.toFloat() * 2
|
foodEaten = cityInfo.population.population.toFloat() * 2
|
||||||
if (cityInfo.civInfo.hasUnique("-50% food consumption by specialists"))
|
if (cityInfo.civInfo.hasUnique("-50% food consumption by specialists"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user