Add configurable natural wonder discovery stat bonuses (#11249)

* Added configurable natural wonder discovery stats

* Shortened the code

* Updated the base rulesets with new unique

* Updated the El Dorado unique

* Applied the suggestions

* Reintroduced the implementation for deprecated uniques

* Changed tile.naturalWonder to naturalWonder
This commit is contained in:
PLynx 2024-04-04 22:39:31 +02:00 committed by GitHub
parent 0474755a0d
commit 0caf0cb4fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 73 additions and 15 deletions

View File

@ -597,7 +597,7 @@
"innerColor": [255,168,168],
"favoredReligion": "Christianity",
"uniqueName": "Seven Cities of Gold",
"uniques": ["100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)",
"uniques": ["[+100 Gold] for discovering a Natural Wonder (bonus enhanced to [+500 Gold] if first to discover it)",
"[+1 Happiness] for every known Natural Wonder", "[+100]% Yield from every [Natural Wonder]"],
"cities": ["Madrid","Barcelona","Seville","Cordoba","Toledo","Santiago","Salamanca","Murcia","Valencia","Zaragoza","Pamplona",
"Vitoria","Santander","Oviedo","Jaen","Logroño","Valladolid","Palma","Teruel","Almeria","Leon","Zamora","Mida",

View File

@ -375,7 +375,7 @@
"unbuildable": true,
"uniques": ["Must be adjacent to [0] [Coast] tiles",
"Must be adjacent to [1] to [6] [Jungle] tiles",
"Grants 500 Gold to the first civilization to discover it"],
"Grants [+500 Gold] to the first civilization to discover it"],
"weight": 2
},
{ // This will count as "Fresh water" in civ 6

View File

@ -555,7 +555,7 @@
"outerColor": [84,26,26],
"innerColor": [255,168,168],
"uniqueName": "Seven Cities of Gold",
"uniques": ["100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)",
"uniques": ["[+100 Gold] for discovering a Natural Wonder (bonus enhanced to [+500 Gold] if first to discover it)",
"[+1 Happiness] for every known Natural Wonder", "[+100]% Yield from every [Natural Wonder]"],
"cities": ["Madrid","Barcelona","Seville","Cordoba","Toledo","Santiago","Salamanca","Murcia","Valencia","Zaragoza","Pamplona",
"Vitoria","Santander","Oviedo","Jaen","Logroño","Valladolid","Palma","Teruel","Almeria","Leon","Zamora","Mida",

View File

@ -376,7 +376,7 @@
"unbuildable": true,
"uniques": ["Must be adjacent to [0] [Coast] tiles",
"Must be adjacent to [1] to [6] [Jungle] tiles",
"Grants 500 Gold to the first civilization to discover it"],
"Grants [+500 Gold] to the first civilization to discover it"],
"weight": 2
},
{ // This will count as "Fresh water" in civ 6

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Vector2
import com.unciv.Constants
import com.unciv.logic.city.City
import com.unciv.logic.civilization.Civilization
import com.unciv.logic.civilization.Notification
import com.unciv.logic.civilization.NotificationCategory
import com.unciv.logic.civilization.NotificationIcon
import com.unciv.logic.civilization.PlayerType
@ -18,6 +19,7 @@ import com.unciv.models.ruleset.unique.UniqueTarget
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.stats.Stats
import com.unciv.utils.DebugUtils
/** CivInfo class was getting too crowded */
@ -215,23 +217,72 @@ class CivInfoTransientCache(val civInfo: Civilization) {
civInfo.addNotification("We have discovered [${tile.naturalWonder}]!",
tile.position, NotificationCategory.General, "StatIcons/Happiness")
var goldGained = 0
val statsGained = Stats()
val discoveredNaturalWonders = civInfo.gameInfo.civilizations.filter { it != civInfo && it.isMajorCiv() }
.flatMap { it.naturalWonders }
if (tile.terrainHasUnique(UniqueType.GrantsGoldToFirstToDiscover)
if (tile.terrainHasUnique(UniqueType.GrantsStatsToFirstToDiscover)
&& !discoveredNaturalWonders.contains(tile.naturalWonder!!)) {
goldGained += 500
for (unique in tile.getTerrainMatchingUniques(UniqueType.GrantsStatsToFirstToDiscover)) {
statsGained.add(unique.stats)
}
}
if (civInfo.hasUnique(UniqueType.GoldWhenDiscoveringNaturalWonder)) {
goldGained += if (discoveredNaturalWonders.contains(tile.naturalWonder!!)) 100 else 500
for (unique in civInfo.getMatchingUniques(UniqueType.StatBonusWhenDiscoveringNaturalWonder)) {
val normalBonus = Stats.parse(unique.params[0])
val firstDiscoveredBonus = Stats.parse(unique.params[1])
if (discoveredNaturalWonders.contains(tile.naturalWonder!!))
statsGained.add(normalBonus)
else
statsGained.add(firstDiscoveredBonus)
}
// Variable for support of twooo deprecated uniques
var goldGained = 0
// Support for depreciated GoldWhenDiscoveringNaturalWonder unique
for (unique in civInfo.getMatchingUniques(UniqueType.GoldWhenDiscoveringNaturalWonder)) {
goldGained += if (discoveredNaturalWonders.contains(tile.naturalWonder!!)) {
100
} else {
500
}
}
// Support for depreciated GrantsGoldToFirstToDiscover unique
if (tile.terrainHasUnique(UniqueType.GrantsGoldToFirstToDiscover)
&& !discoveredNaturalWonders.contains(tile.naturalWonder!!)) {
for (unique in tile.getTerrainMatchingUniques(UniqueType.GoldWhenDiscoveringNaturalWonder)) {
goldGained += 500
}
}
var naturalWonder: String? = null
if (!statsGained.isEmpty()) {
naturalWonder = tile.naturalWonder!!
}
if (!statsGained.isEmpty() && naturalWonder != null) {
civInfo.addStats(statsGained)
civInfo.addNotification("We have received [${statsGained}] for discovering [${naturalWonder}]",
Notification.NotificationCategory.General, statsGained.toString()
)
}
if (goldGained > 0) {
naturalWonder = tile.naturalWonder
}
if (goldGained > 0 && naturalWonder != null) {
civInfo.addGold(goldGained)
civInfo.addNotification("We have received [$goldGained] Gold for discovering [${tile.naturalWonder}]",
NotificationCategory.General, NotificationIcon.Gold
)
civInfo.addNotification("We have received [$goldGained] Gold for discovering [${naturalWonder}]",
Notification.NotificationCategory.General, NotificationIcon.Gold)
}
for (unique in civInfo.getTriggeredUniques(UniqueType.TriggerUponDiscoveringNaturalWonder,

View File

@ -150,8 +150,9 @@ enum class UniqueType(
/// Natural Wonders
StatsFromNaturalWonders("[stats] for every known Natural Wonder", UniqueTarget.Global),
// TODO: moddability of the numbers
@Deprecated("as of 4.10.17", ReplaceWith("[+100 Gold] for discovering a Natural Wonder (bonus enhanced to [+500 Gold] if first to discover it)"))
GoldWhenDiscoveringNaturalWonder("100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)", UniqueTarget.Global),
StatBonusWhenDiscoveringNaturalWonder("[stats] for discovering a Natural Wonder (bonus enhanced to [stats] if first to discover it)", UniqueTarget.Global),
/// Great Persons
GreatPersonPointPercentage("[relativeAmount]% Great Person generation [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
@ -532,7 +533,9 @@ enum class UniqueType(
NaturalWonderConvertNeighbors("Neighboring tiles will convert to [baseTerrain]", UniqueTarget.Terrain, flags = UniqueFlag.setOfHiddenToUsers),
// The "Except [terrainFilter]" could theoretically be implemented with a conditional
NaturalWonderConvertNeighborsExcept("Neighboring tiles except [baseTerrain] will convert to [baseTerrain]", UniqueTarget.Terrain, flags = UniqueFlag.setOfHiddenToUsers),
@Deprecated("As of 4.10.17", ReplaceWith("Grants [+500 Gold] to the first civilization to discover it"))
GrantsGoldToFirstToDiscover("Grants 500 Gold to the first civilization to discover it", UniqueTarget.Terrain),
GrantsStatsToFirstToDiscover("Grants [stats] to the first civilization to discover it", UniqueTarget.Terrain),
// General terrain
DamagesContainingUnits("Units ending their turn on this terrain take [amount] damage", UniqueTarget.Terrain),

View File

@ -550,7 +550,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Global
??? example "100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)"
??? example "[stats] for discovering a Natural Wonder (bonus enhanced to [stats] if first to discover it)"
Example: "[+1 Gold, +2 Production] for discovering a Natural Wonder (bonus enhanced to [+1 Gold, +2 Production] if first to discover it)"
Applicable to: Global
??? example "[relativeAmount]% Great Person generation [cityFilter]"
@ -1550,7 +1552,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Terrain
??? example "Grants 500 Gold to the first civilization to discover it"
??? example "Grants [stats] to the first civilization to discover it"
Example: "Grants [+1 Gold, +2 Production] to the first civilization to discover it"
Applicable to: Terrain
??? example "Units ending their turn on this terrain take [amount] damage"