mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
Trigger notifications can go in either direction, for better translations
This commit is contained in:
@ -30,7 +30,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "a stash of gold",
|
"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]"],
|
"uniques": ["Gain [50]-[100] [Gold]"],
|
||||||
"color": "#ffeb7f"
|
"color": "#ffeb7f"
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "a stash of gold",
|
"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]"],
|
"uniques": ["Gain [50]-[100] [Gold]"],
|
||||||
"color": "#ffeb7f"
|
"color": "#ffeb7f"
|
||||||
},
|
},
|
||||||
|
@ -906,6 +906,14 @@ A Great Person joins you! =
|
|||||||
[civ] has liberated an unknown civilization =
|
[civ] has liberated an unknown civilization =
|
||||||
An unknown civilization has liberated [civ] =
|
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
|
## Trigger effects
|
||||||
|
|
||||||
@ -922,6 +930,7 @@ due to adopting [policy] =
|
|||||||
due to discovering [naturalWonder] =
|
due to discovering [naturalWonder] =
|
||||||
due to entering the [eraName] =
|
due to entering the [eraName] =
|
||||||
due to constructing [buildingName] =
|
due to constructing [buildingName] =
|
||||||
|
from the ruins =
|
||||||
|
|
||||||
# World Screen UI
|
# World Screen UI
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class RuinsManager : IsPartOfGameInfoSerialization {
|
|||||||
for (unique in possibleReward.uniqueObjects) {
|
for (unique in possibleReward.uniqueObjects) {
|
||||||
atLeastOneUniqueHadEffect =
|
atLeastOneUniqueHadEffect =
|
||||||
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)
|
|| UniqueTriggerActivation.triggerUnitwideUnique(unique, triggeringUnit, notification = possibleReward.notification)
|
||||||
}
|
}
|
||||||
if (atLeastOneUniqueHadEffect) {
|
if (atLeastOneUniqueHadEffect) {
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.models.ruleset.unique
|
|||||||
|
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.City
|
import com.unciv.logic.city.City
|
||||||
import com.unciv.logic.civilization.CivFlags
|
import com.unciv.logic.civilization.CivFlags
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
@ -56,9 +57,9 @@ object UniqueTriggerActivation {
|
|||||||
|
|
||||||
val placedUnit = civInfo.units.addUnit(unitName, chosenCity) ?: return false
|
val placedUnit = civInfo.units.addUnit(unitName, chosenCity) ?: return false
|
||||||
|
|
||||||
val notificationText = if (notification != null) notification
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
else if (triggerNotificationText != null) "{Gained [1] [$unitName] unit(s)}{ }{$triggerNotificationText}"
|
"Gained [1] [$unitName] unit(s)")
|
||||||
else return true
|
?: return true
|
||||||
|
|
||||||
civInfo.addNotification(
|
civInfo.addNotification(
|
||||||
notificationText,
|
notificationText,
|
||||||
@ -82,9 +83,9 @@ object UniqueTriggerActivation {
|
|||||||
}
|
}
|
||||||
if (tilesUnitsWerePlacedOn.isEmpty()) return true
|
if (tilesUnitsWerePlacedOn.isEmpty()) return true
|
||||||
|
|
||||||
val notificationText = if (notification != null) notification
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
else if (triggerNotificationText!=null) "{Gained [${tilesUnitsWerePlacedOn.size}] [$unitName] unit(s)}{ }{$triggerNotificationText}"
|
"Gained [${tilesUnitsWerePlacedOn.size}] [$unitName] unit(s)")
|
||||||
else return true
|
?: return true
|
||||||
|
|
||||||
civInfo.addNotification(
|
civInfo.addNotification(
|
||||||
notificationText,
|
notificationText,
|
||||||
@ -127,9 +128,10 @@ object UniqueTriggerActivation {
|
|||||||
if (civInfo.isSpectator()) return false
|
if (civInfo.isSpectator()) return false
|
||||||
civInfo.policies.freePolicies++
|
civInfo.policies.freePolicies++
|
||||||
|
|
||||||
val notificationText = if (notification != null) notification
|
|
||||||
else if (triggerNotificationText != null) "{You may choose a free Policy}{ }{$triggerNotificationText}"
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
else return true
|
"You may choose a free Policy")
|
||||||
|
?: return true
|
||||||
|
|
||||||
civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Culture)
|
civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Culture)
|
||||||
|
|
||||||
@ -140,9 +142,9 @@ object UniqueTriggerActivation {
|
|||||||
val newFreePolicies = unique.params[0].toInt()
|
val newFreePolicies = unique.params[0].toInt()
|
||||||
civInfo.policies.freePolicies += newFreePolicies
|
civInfo.policies.freePolicies += newFreePolicies
|
||||||
|
|
||||||
val notificationText = if (notification != null) notification
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
else if (triggerNotificationText != null) "{You may choose [$newFreePolicies] free Policies}{ }{$triggerNotificationText}"
|
"You may choose [$newFreePolicies] free Policies")
|
||||||
else return true
|
?: return true
|
||||||
|
|
||||||
civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Culture)
|
civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Culture)
|
||||||
|
|
||||||
@ -151,9 +153,9 @@ object UniqueTriggerActivation {
|
|||||||
UniqueType.OneTimeEnterGoldenAge -> {
|
UniqueType.OneTimeEnterGoldenAge -> {
|
||||||
civInfo.goldenAges.enterGoldenAge()
|
civInfo.goldenAges.enterGoldenAge()
|
||||||
|
|
||||||
val notificationText = if (notification != null) notification
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
else if (triggerNotificationText != null) "{You enter a Golden Age}{ }{$triggerNotificationText}"
|
"You enter a Golden Age")
|
||||||
else return true
|
?: return true
|
||||||
|
|
||||||
civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Happiness)
|
civInfo.addNotification(notificationText, NotificationCategory.General, NotificationIcon.Happiness)
|
||||||
|
|
||||||
@ -360,9 +362,9 @@ object UniqueTriggerActivation {
|
|||||||
val stats = Stats().add(stat, unique.params[0].toFloat())
|
val stats = Stats().add(stat, unique.params[0].toFloat())
|
||||||
civInfo.addStats(stats)
|
civInfo.addStats(stats)
|
||||||
|
|
||||||
val notificationText = if (notification != null) notification
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
else if (triggerNotificationText != null) "{Gained [$stats]}{ }{$triggerNotificationText}"
|
"Gained [$stats]")
|
||||||
else return true
|
?: return true
|
||||||
|
|
||||||
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
||||||
return true
|
return true
|
||||||
@ -383,13 +385,9 @@ object UniqueTriggerActivation {
|
|||||||
val stats = Stats().add(stat, finalStatAmount)
|
val stats = Stats().add(stat, finalStatAmount)
|
||||||
civInfo.addStats(stats)
|
civInfo.addStats(stats)
|
||||||
|
|
||||||
val notificationText = if (notification != null) {
|
val notificationText = getNotificationText(notification, triggerNotificationText,
|
||||||
if (notification.hasPlaceholderParameters()) {
|
"Gained [$stats]")
|
||||||
notification.fillPlaceholders(finalStatAmount.toString())
|
?: return true
|
||||||
} else notification
|
|
||||||
}
|
|
||||||
else if (triggerNotificationText != null) "{Gained [$stats]}{ }{$triggerNotificationText}"
|
|
||||||
else return true
|
|
||||||
|
|
||||||
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
||||||
|
|
||||||
@ -562,6 +560,17 @@ object UniqueTriggerActivation {
|
|||||||
return false
|
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 */
|
/** @return boolean whether an action was successfully performed */
|
||||||
fun triggerUnitwideUnique(
|
fun triggerUnitwideUnique(
|
||||||
unique: Unique,
|
unique: Unique,
|
||||||
|
@ -207,6 +207,10 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
return get(shouldCapitalizeString, language, null)?.get(language)?.toBoolean() ?: true
|
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 {
|
companion object {
|
||||||
// Whenever this string is changed, it should also be changed in the translation files!
|
// 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
|
// It is mostly used as the template for translating the order of conditionals
|
||||||
@ -214,6 +218,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
"<with a garrison> <for [mapUnitFilter] units> <above [amount] HP> <below [amount] HP> <vs cities> <vs [mapUnitFilter] units> <when fighting in [tileFilter] tiles> <when attacking> <when defending> <if this city has at least [amount] specialists> <when at war> <when not at war> <while the empire is happy> <during a Golden Age> <during the [era]> <starting from the [era]> <before the [era]> <with [techOrPolicy]> <without [techOrPolicy]>"
|
"<with a garrison> <for [mapUnitFilter] units> <above [amount] HP> <below [amount] HP> <vs cities> <vs [mapUnitFilter] units> <when fighting in [tileFilter] tiles> <when attacking> <when defending> <if this city has at least [amount] specialists> <when at war> <when not at war> <while the empire is happy> <during a Golden Age> <during the [era]> <starting from the [era]> <before the [era]> <with [techOrPolicy]> <without [techOrPolicy]>"
|
||||||
const val conditionalUniqueOrderString = "ConditionalsPlacement"
|
const val conditionalUniqueOrderString = "ConditionalsPlacement"
|
||||||
const val shouldCapitalizeString = "StartWithCapitalLetter"
|
const val shouldCapitalizeString = "StartWithCapitalLetter"
|
||||||
|
const val effectBeforeCause = "EffectBeforeCause"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user