From 4aa75896e1bfba82db2cf1dae0b7f5d7d089842b Mon Sep 17 00:00:00 2001 From: Oskar Niesen Date: Sat, 4 May 2024 13:04:17 -0500 Subject: [PATCH] Add missing espionage uniques (#11559) * Added "New spies start with [1] level(s)" unique * Added England extra spy unique * Fixed SpyStartingLevel target * Added addspy notification --- android/assets/jsons/Civ V - Gods & Kings/Buildings.json | 6 ++++-- android/assets/jsons/Civ V - Gods & Kings/Nations.json | 2 +- .../unciv/logic/civilization/managers/EspionageManager.kt | 5 ++++- core/src/com/unciv/models/Spy.kt | 6 ++++-- .../unciv/models/ruleset/unique/UniqueTriggerActivation.kt | 3 ++- core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 1 + 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/android/assets/jsons/Civ V - Gods & Kings/Buildings.json b/android/assets/jsons/Civ V - Gods & Kings/Buildings.json index 752f826b41..9e5fb185e5 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Buildings.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Buildings.json @@ -986,8 +986,10 @@ "cost": 120, "culture": 1, "isNationalWonder": true, - "uniques": ["Hidden when espionage is disabled", "Gain an extra spy", "Promotes all spies", "[-15]% enemy spy effectiveness [in this city]", - "Only available ", "Cost increases by [30] per owned city"], + "uniques": ["Hidden when espionage is disabled", "Gain an extra spy", "Promotes all spies", + "[-15]% enemy spy effectiveness [in this city]", "New spies start with [1] level(s)", + "Only available ", + "Cost increases by [30] per owned city"], "requiredTech": "Radio" }, { diff --git a/android/assets/jsons/Civ V - Gods & Kings/Nations.json b/android/assets/jsons/Civ V - Gods & Kings/Nations.json index 4bd5b3f60d..b61d674ac9 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Nations.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Nations.json @@ -154,7 +154,7 @@ "innerColor": [255, 255, 255], "favoredReligion": "Christianity", "uniqueName": "Sun Never Sets", - "uniques": ["[+2] Movement "], + "uniques": ["[+2] Movement ", "Gain an extra spy "], "cities": ["London","York","Nottingham","Hastings","Canterbury","Coventry","Warwick","Newcastle","Oxford","Liverpool", "Dover","Brighton","Norwich","Leeds","Reading","Birmingham","Richmond","Exeter","Cambridge","Gloucester", "Manchester","Bristol","Leicester","Carlisle","Ipswich","Portsmouth","Berwick","Bath","Mumbles","Southampton", diff --git a/core/src/com/unciv/logic/civilization/managers/EspionageManager.kt b/core/src/com/unciv/logic/civilization/managers/EspionageManager.kt index 9536adf157..4f64017c6f 100644 --- a/core/src/com/unciv/logic/civilization/managers/EspionageManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/EspionageManager.kt @@ -5,6 +5,7 @@ import com.unciv.logic.city.City import com.unciv.logic.civilization.Civilization import com.unciv.logic.map.tile.Tile import com.unciv.models.Spy +import com.unciv.models.ruleset.unique.UniqueType class EspionageManager : IsPartOfGameInfoSerialization { @@ -50,7 +51,7 @@ class EspionageManager : IsPartOfGameInfoSerialization { fun addSpy(): Spy { val spyName = getSpyName() - val newSpy = Spy(spyName) + val newSpy = Spy(spyName, getStartingSpyRank()) newSpy.setTransients(civInfo) spyList.add(newSpy) return newSpy @@ -77,6 +78,8 @@ class EspionageManager : IsPartOfGameInfoSerialization { return spyList.filter { it.getLocation() == city }.toMutableList() } + fun getStartingSpyRank(): Int = 1 + civInfo.getMatchingUniques(UniqueType.SpyStartingLevel).sumOf { it.params[0].toInt() } + /** * Returns a list of all cities with our spies in them. * The list needs to be stable accross calls on the same turn. diff --git a/core/src/com/unciv/models/Spy.kt b/core/src/com/unciv/models/Spy.kt index 54cc198d5f..c98ee6648b 100644 --- a/core/src/com/unciv/models/Spy.kt +++ b/core/src/com/unciv/models/Spy.kt @@ -44,12 +44,13 @@ class Spy() : IsPartOfGameInfoSerialization { @Transient private lateinit var espionageManager: EspionageManager - constructor(name: String) : this() { + constructor(name: String, rank:Int) : this() { this.name = name + this.rank = rank } fun clone(): Spy { - val toReturn = Spy(name) + val toReturn = Spy(name, rank) toReturn.location = location toReturn.action = action toReturn.turnsRemainingForAction = turnsRemainingForAction @@ -126,6 +127,7 @@ class Spy() : IsPartOfGameInfoSerialization { val oldSpyName = name name = espionageManager.getSpyName() action = SpyAction.None + rank = espionageManager.getStartingSpyRank() civInfo.addNotification("We have recruited a new spy name [$name] after [$oldSpyName] was killed.", NotificationCategory.Espionage, NotificationIcon.Spy) } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index 8304201359..7c5ff85f11 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -840,7 +840,8 @@ object UniqueTriggerActivation { if (!civInfo.gameInfo.isEspionageEnabled()) return null return { - civInfo.espionageManager.addSpy() + val spyName = civInfo.espionageManager.addSpy().name + civInfo.addNotification("We have recruited [${spyName}] as a spy!", NotificationCategory.Espionage, NotificationIcon.Spy) true } } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 90e2764483..5a124d4e58 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -230,6 +230,7 @@ enum class UniqueType( /// Espionage SpyEffectiveness("[relativeAmount]% spy effectiveness [cityFilter]", UniqueTarget.Global, UniqueTarget.Global), EnemySpyEffectiveness("[relativeAmount]% enemy spy effectiveness [cityFilter]", UniqueTarget.Global, UniqueTarget.Global), + SpyStartingLevel("New spies start with [amount] level(s)", UniqueTarget.Global), /// Things you get at the start of the game StartingTech("Starting tech", UniqueTarget.Tech),