mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Notifications for stat gain unique
This commit is contained in:
parent
587b1f40f1
commit
87dfe2e2bf
@ -910,6 +910,7 @@ An unknown civilization has liberated [civ] =
|
||||
## Trigger effects
|
||||
|
||||
Gained [amount] [unitName] unit(s) =
|
||||
Gained [stats] =
|
||||
You may choose a free Policy =
|
||||
You may choose [amount] free Policies =
|
||||
You enter a Golden Age =
|
||||
|
@ -48,6 +48,7 @@ import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unique.getMatchingUniques
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.extensions.toPercent
|
||||
import com.unciv.ui.victoryscreen.RankingType
|
||||
@ -694,6 +695,10 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
}
|
||||
|
||||
fun addStats(stats: Stats){
|
||||
for ((stat, amount) in stats) addStat(stat, amount.toInt())
|
||||
}
|
||||
|
||||
fun addStat(stat: Stat, amount: Int) {
|
||||
when (stat) {
|
||||
Stat.Culture -> { policies.addCulture(amount)
|
||||
|
@ -15,6 +15,7 @@ import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.ruleset.BeliefType
|
||||
import com.unciv.models.ruleset.Victory
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.fillPlaceholders
|
||||
import com.unciv.models.translations.hasPlaceholderParameters
|
||||
import com.unciv.ui.utils.MayaCalendar
|
||||
@ -356,9 +357,14 @@ object UniqueTriggerActivation {
|
||||
|| unique.params[0].toIntOrNull() == null
|
||||
) return false
|
||||
|
||||
civInfo.addStat(stat, unique.params[0].toInt())
|
||||
if (notification != null)
|
||||
civInfo.addNotification(notification, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
||||
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
|
||||
|
||||
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
||||
return true
|
||||
}
|
||||
UniqueType.OneTimeGainStatRange -> {
|
||||
@ -369,23 +375,23 @@ object UniqueTriggerActivation {
|
||||
|| unique.params[1].toIntOrNull() == null
|
||||
) return false
|
||||
|
||||
val foundStatAmount =
|
||||
val finalStatAmount =
|
||||
(tileBasedRandom.nextInt(unique.params[0].toInt(), unique.params[1].toInt()) *
|
||||
civInfo.gameInfo.speed.statCostModifiers[stat]!!
|
||||
).toInt()
|
||||
).toFloat()
|
||||
|
||||
civInfo.addStat(
|
||||
Stat.valueOf(unique.params[2]),
|
||||
foundStatAmount
|
||||
)
|
||||
val stats = Stats().add(stat, finalStatAmount)
|
||||
civInfo.addStats(stats)
|
||||
|
||||
if (notification != null) {
|
||||
val notificationText =
|
||||
if (notification.hasPlaceholderParameters()) {
|
||||
notification.fillPlaceholders(foundStatAmount.toString())
|
||||
} else notification
|
||||
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
||||
val notificationText = if (notification != null) {
|
||||
if (notification.hasPlaceholderParameters()) {
|
||||
notification.fillPlaceholders(finalStatAmount.toString())
|
||||
} else notification
|
||||
}
|
||||
else if (triggerNotificationText != null) "{Gained [$stats]}{ }{$triggerNotificationText}"
|
||||
else return true
|
||||
|
||||
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
|
||||
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user