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