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