From 557735cb0e8c2d630242c69f3474638b455e3feb Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 15 Dec 2022 09:30:14 +0200 Subject: [PATCH] Modding: Can provide resources as a global unique --- core/src/com/unciv/logic/city/CityInfo.kt | 2 +- .../logic/civilization/CivInfoTransientUpdater.kt | 10 ++++++++++ core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 56292440c3..2dca535863 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -438,7 +438,7 @@ class CityInfo : IsPartOfGameInfoSerialization { val resource = getRuleset().tileResources[unique.params[1]] ?: continue cityResources.add( - resource, "Buildings+", + resource, "Buildings", unique.params[0].toInt() * civInfo.getResourceModifier(resource) ) } diff --git a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt index 4432cdb57b..bf1dbb7f51 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt @@ -5,6 +5,7 @@ import com.unciv.UncivGame import com.unciv.logic.map.MapShape import com.unciv.logic.map.TileInfo import com.unciv.models.ruleset.tile.ResourceSupplyList +import com.unciv.models.ruleset.unique.UniqueTarget import com.unciv.models.ruleset.unique.UniqueType /** CivInfo class was getting too crowded */ @@ -190,6 +191,15 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) { newDetailedCivResources.addByResource(cityStateProvidedResources, Constants.cityStates) } + for (unique in civInfo.getMatchingUniques(UniqueType.ProvidesResources)) { + if (unique.sourceObjectType == UniqueTarget.Building || unique.sourceObjectType == UniqueTarget.Wonder) continue // already calculated in city + newDetailedCivResources.add( + civInfo.gameInfo.ruleSet.tileResources[unique.params[1]]!!, + unique.sourceObjectType?.name ?: "", + unique.params[1].toInt() + ) + } + for (diplomacyManager in civInfo.diplomacy.values) newDetailedCivResources.add(diplomacyManager.resourcesFromTrade()) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 24d7a6c6e9..77c660272d 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -143,7 +143,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: CannotBuildUnits("Cannot build [baseUnitFilter] units", UniqueTarget.Global), ConsumesResources("Consumes [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit), - ProvidesResources("Provides [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building), + ProvidesResources("Provides [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Global), GrowthPercentBonus("[relativeAmount]% growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), CarryOverFood("[relativeAmount]% Food is carried over after population increases [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),