diff --git a/android/assets/jsons/Civ V - Gods & Kings/Ruins.json b/android/assets/jsons/Civ V - Gods & Kings/Ruins.json index 30be4cb693..5a19dea5ea 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Ruins.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Ruins.json @@ -30,7 +30,7 @@ }, { "name": "a stash of gold", - "notification": "We have found a stash of [goldAmount] Gold in the ruins!", + "notification": "", // trigger notification only "uniques": ["Gain [50]-[100] [Gold]"], "color": "#ffeb7f" }, diff --git a/android/assets/jsons/Civ V - Vanilla/Ruins.json b/android/assets/jsons/Civ V - Vanilla/Ruins.json index 8ce2acae7d..7e00ea5343 100644 --- a/android/assets/jsons/Civ V - Vanilla/Ruins.json +++ b/android/assets/jsons/Civ V - Vanilla/Ruins.json @@ -30,7 +30,7 @@ }, { "name": "a stash of gold", - "notification": "We have found a stash of [goldAmount] Gold in the ruins!", + "notification": "", // trigger notification only "uniques": ["Gain [50]-[100] [Gold]"], "color": "#ffeb7f" }, diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 3929acc269..e4719adc68 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -906,6 +906,14 @@ A Great Person joins you! = [civ] has liberated an unknown civilization = An unknown civilization has liberated [civ] = +# Trigger notifications + + +# Since each cause can be paired with each effect we need to create the final string by adding them together. +# If your language puts the effect before the cause - like {Gained [2] [Worker] unit(s)} {due to constructing [The Pyramids]} - +# put the english word 'true' behind the '=', otherwise 'false'. +# Don't translate these words to your language, only put 'true' or 'false'. Defaults to 'true'. +EffectBeforeCause = ## Trigger effects @@ -922,6 +930,7 @@ due to adopting [policy] = due to discovering [naturalWonder] = due to entering the [eraName] = due to constructing [buildingName] = +from the ruins = # World Screen UI diff --git a/core/src/com/unciv/logic/civilization/managers/RuinsManager.kt b/core/src/com/unciv/logic/civilization/managers/RuinsManager.kt index 5e3cfc2dfd..c3637d6b93 100644 --- a/core/src/com/unciv/logic/civilization/managers/RuinsManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/RuinsManager.kt @@ -57,7 +57,7 @@ class RuinsManager : IsPartOfGameInfoSerialization { for (unique in possibleReward.uniqueObjects) { atLeastOneUniqueHadEffect = atLeastOneUniqueHadEffect - || UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo, tile = triggeringUnit.getTile(), notification = possibleReward.notification) + || UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo, tile = triggeringUnit.getTile(), notification = possibleReward.notification, triggerNotificationText = "from the ruins") || UniqueTriggerActivation.triggerUnitwideUnique(unique, triggeringUnit, notification = possibleReward.notification) } if (atLeastOneUniqueHadEffect) { diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index 0a8ddcc650..f46c1e86b9 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -2,6 +2,7 @@ package com.unciv.models.ruleset.unique import com.badlogic.gdx.math.Vector2 import com.unciv.Constants +import com.unciv.UncivGame import com.unciv.logic.city.City import com.unciv.logic.civilization.CivFlags import com.unciv.logic.civilization.Civilization @@ -56,9 +57,9 @@ object UniqueTriggerActivation { val placedUnit = civInfo.units.addUnit(unitName, chosenCity) ?: return false - val notificationText = if (notification != null) notification - else if (triggerNotificationText != null) "{Gained [1] [$unitName] unit(s)}{ }{$triggerNotificationText}" - else return true + val notificationText = getNotificationText(notification, triggerNotificationText, + "Gained [1] [$unitName] unit(s)") + ?: return true civInfo.addNotification( notificationText, @@ -82,9 +83,9 @@ object UniqueTriggerActivation { } if (tilesUnitsWerePlacedOn.isEmpty()) return true - val notificationText = if (notification != null) notification - else if (triggerNotificationText!=null) "{Gained [${tilesUnitsWerePlacedOn.size}] [$unitName] unit(s)}{ }{$triggerNotificationText}" - else return true + val notificationText = getNotificationText(notification, triggerNotificationText, + "Gained [${tilesUnitsWerePlacedOn.size}] [$unitName] unit(s)") + ?: return true civInfo.addNotification( notificationText, @@ -127,9 +128,10 @@ object UniqueTriggerActivation { if (civInfo.isSpectator()) return false civInfo.policies.freePolicies++ - val notificationText = if (notification != null) notification - else if (triggerNotificationText != null) "{You may choose a free Policy}{ }{$triggerNotificationText}" - else return true + + val notificationText = getNotificationText(notification, triggerNotificationText, + "You may choose a free Policy") + ?: return true civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Culture) @@ -140,9 +142,9 @@ object UniqueTriggerActivation { val newFreePolicies = unique.params[0].toInt() civInfo.policies.freePolicies += newFreePolicies - val notificationText = if (notification != null) notification - else if (triggerNotificationText != null) "{You may choose [$newFreePolicies] free Policies}{ }{$triggerNotificationText}" - else return true + val notificationText = getNotificationText(notification, triggerNotificationText, + "You may choose [$newFreePolicies] free Policies") + ?: return true civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Culture) @@ -151,9 +153,9 @@ object UniqueTriggerActivation { UniqueType.OneTimeEnterGoldenAge -> { civInfo.goldenAges.enterGoldenAge() - val notificationText = if (notification != null) notification - else if (triggerNotificationText != null) "{You enter a Golden Age}{ }{$triggerNotificationText}" - else return true + val notificationText = getNotificationText(notification, triggerNotificationText, + "You enter a Golden Age") + ?: return true civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Happiness) @@ -360,9 +362,9 @@ object UniqueTriggerActivation { val stats = Stats().add(stat, unique.params[0].toFloat()) civInfo.addStats(stats) - val notificationText = if (notification != null) notification - else if (triggerNotificationText != null) "{Gained [$stats]}{ }{$triggerNotificationText}" - else return true + val notificationText = getNotificationText(notification, triggerNotificationText, + "Gained [$stats]") + ?: return true civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon) return true @@ -383,13 +385,9 @@ object UniqueTriggerActivation { val stats = Stats().add(stat, finalStatAmount) civInfo.addStats(stats) - val notificationText = if (notification != null) { - if (notification.hasPlaceholderParameters()) { - notification.fillPlaceholders(finalStatAmount.toString()) - } else notification - } - else if (triggerNotificationText != null) "{Gained [$stats]}{ }{$triggerNotificationText}" - else return true + val notificationText = getNotificationText(notification, triggerNotificationText, + "Gained [$stats]") + ?: return true civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon) @@ -562,6 +560,17 @@ object UniqueTriggerActivation { return false } + fun getNotificationText(notification: String?, triggerNotificationText: String?, effectNotificationText:String):String?{ + return if (!notification.isNullOrEmpty()) notification + else if (triggerNotificationText != null) + { + if (UncivGame.Current.translations.triggerNotificationEffectBeforeCause(UncivGame.Current.settings.language)) + "{$effectNotificationText}{ }{$triggerNotificationText}" + else "{$triggerNotificationText}{ }{$effectNotificationText}" + } + else null + } + /** @return boolean whether an action was successfully performed */ fun triggerUnitwideUnique( unique: Unique, diff --git a/core/src/com/unciv/models/translations/Translations.kt b/core/src/com/unciv/models/translations/Translations.kt index 212eb36f5a..18ac446218 100644 --- a/core/src/com/unciv/models/translations/Translations.kt +++ b/core/src/com/unciv/models/translations/Translations.kt @@ -207,6 +207,10 @@ class Translations : LinkedHashMap(){ return get(shouldCapitalizeString, language, null)?.get(language)?.toBoolean() ?: true } + fun triggerNotificationEffectBeforeCause(language: String): Boolean{ + return get(effectBeforeCause, language, null)?.get(language)?.toBoolean() ?: true + } + companion object { // Whenever this string is changed, it should also be changed in the translation files! // It is mostly used as the template for translating the order of conditionals @@ -214,6 +218,7 @@ class Translations : LinkedHashMap(){ " " const val conditionalUniqueOrderString = "ConditionalsPlacement" const val shouldCapitalizeString = "StartWithCapitalLetter" + const val effectBeforeCause = "EffectBeforeCause" } }