mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 18:59:15 +07:00
Fixed a bug where the resource supply overview would not add up (#6381)
This commit is contained in:
@ -656,7 +656,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
||||
for (city in civInfo.cities) {
|
||||
for (resourceSupply in city.getCityResources())
|
||||
if (resourceSupply.amount > 0) // IGNORE the fact that they consume their own resources - #4769
|
||||
newDetailedCivResources.add(resourceSupply.resource, resourceSupply.amount, "City-States")
|
||||
newDetailedCivResources.add(resourceSupply.resource, resourceSupply.amount, "City-State")
|
||||
}
|
||||
return newDetailedCivResources
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.civilization
|
||||
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.tile.ResourceSupply
|
||||
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
|
||||
@ -168,19 +169,27 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
for (city in civInfo.cities) newDetailedCivResources.add(city.getCityResources())
|
||||
|
||||
if (!civInfo.isCityState()) {
|
||||
// First we get all these resources of each city state separately
|
||||
val cityStateProvidedResources = ResourceSupplyList()
|
||||
var resourceBonusPercentage = 1f
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.CityStateResources))
|
||||
resourceBonusPercentage += unique.params[0].toFloat() / 100
|
||||
for (cityStateAlly in civInfo.getKnownCivs().filter { it.getAllyCiv() == civInfo.civName }) {
|
||||
for (resource in cityStateAlly.cityStateFunctions.getCityStateResourcesForAlly()) {
|
||||
newDetailedCivResources.add(
|
||||
cityStateProvidedResources.add(
|
||||
resource.apply { amount = (amount * resourceBonusPercentage).toInt() }
|
||||
)
|
||||
}
|
||||
}
|
||||
// Then we combine these into one
|
||||
for (resourceSupply in cityStateProvidedResources.groupBy { it.resource }) {
|
||||
newDetailedCivResources.add(ResourceSupply(resourceSupply.key, resourceSupply.value.sumOf { it.amount }, "City-States"))
|
||||
}
|
||||
|
||||
for (dip in civInfo.diplomacy.values) newDetailedCivResources.add(dip.resourcesFromTrade())
|
||||
}
|
||||
|
||||
|
||||
for (diplomacyManager in civInfo.diplomacy.values) newDetailedCivResources.add(diplomacyManager.resourcesFromTrade())
|
||||
for (unit in civInfo.getCivUnits())
|
||||
for ((resource, amount) in unit.baseUnit.getResourceRequirements())
|
||||
newDetailedCivResources.add(civInfo.gameInfo.ruleSet.tileResources[resource]!!, -amount, "Units")
|
||||
|
@ -42,8 +42,7 @@ class ResourcesOverviewTab(
|
||||
overviewScreen.game.setWorldScreen()
|
||||
}
|
||||
holder.addActor(resourceImage)
|
||||
holder.setSize(resourceImage.width,
|
||||
resourceImage.height + labelPadding)
|
||||
holder.setSize(resourceImage.width, resourceImage.height + labelPadding)
|
||||
// Center-align all labels, but right-align the last couple resources' labels
|
||||
// because they may get clipped otherwise. The leftmost label should be fine
|
||||
// center-aligned (if there are more than 2 resources), because the left side
|
||||
|
Reference in New Issue
Block a user