mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Trigger notifications can go in either direction, for better translations
This commit is contained in:
parent
87dfe2e2bf
commit
83ff2d12d9
@ -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"
|
||||
},
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -207,6 +207,10 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
||||
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<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]>"
|
||||
const val conditionalUniqueOrderString = "ConditionalsPlacement"
|
||||
const val shouldCapitalizeString = "StartWithCapitalLetter"
|
||||
const val effectBeforeCause = "EffectBeforeCause"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user