mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-29 06:09:24 +07:00
Non-integer resource modifier now applied to the civ-wide scope (#8592)
This commit is contained in:
@ -167,7 +167,7 @@ class City : IsPartOfGameInfoSerialization {
|
||||
|
||||
for (tileInfo in getTiles().filter { it.resource != null }) {
|
||||
val resource = tileInfo.tileResource
|
||||
val amount = getTileResourceAmount(tileInfo) * civ.getResourceModifier(resource)
|
||||
val amount = getTileResourceAmount(tileInfo)
|
||||
if (amount > 0) cityResources.add(resource, "Tiles", amount)
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ class City : IsPartOfGameInfoSerialization {
|
||||
val resource = getRuleset().tileResources[unique.params[1]] ?: continue
|
||||
cityResources.add(
|
||||
resource, "Improvements",
|
||||
unique.params[0].toInt() * civ.getResourceModifier(resource)
|
||||
unique.params[0].toInt()
|
||||
)
|
||||
}
|
||||
for (unique in tileImprovement.getMatchingUniques(UniqueType.ConsumesResources, stateForConditionals)) {
|
||||
@ -203,7 +203,7 @@ class City : IsPartOfGameInfoSerialization {
|
||||
?: continue
|
||||
cityResources.add(
|
||||
resource, "Buildings",
|
||||
unique.params[0].toInt() * civ.getResourceModifier(resource)
|
||||
unique.params[0].toInt()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
return hashMap
|
||||
}
|
||||
|
||||
fun getResourceModifier(resource: TileResource): Int {
|
||||
fun getResourceModifier(resource: TileResource): Float {
|
||||
var resourceModifier = 1f
|
||||
for (unique in getMatchingUniques(UniqueType.DoubleResourceProduced))
|
||||
if (unique.params[0] == resource.name)
|
||||
@ -420,7 +420,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
.map { it.params[0].toFloat() / 100f }.sum()
|
||||
|
||||
}
|
||||
return resourceModifier.toInt()
|
||||
return resourceModifier
|
||||
}
|
||||
|
||||
fun hasResource(resourceName: String): Boolean = getCivResourcesByName()[resourceName]!! > 0
|
||||
|
@ -255,6 +255,10 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
val newDetailedCivResources = ResourceSupplyList()
|
||||
for (city in civInfo.cities) newDetailedCivResources.add(city.getCityResources())
|
||||
|
||||
for (resourceSupply in newDetailedCivResources)
|
||||
if(resourceSupply.amount > 0)
|
||||
resourceSupply.amount = (resourceSupply.amount * civInfo.getResourceModifier(resourceSupply.resource)).toInt()
|
||||
|
||||
if (!civInfo.isCityState()) {
|
||||
// First we get all these resources of each city state separately
|
||||
val cityStateProvidedResources = ResourceSupplyList()
|
||||
|
Reference in New Issue
Block a user