Skip to content

Commit

Permalink
'gain control over tiles' trigger leaves your tiles alone (#12052)
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 authored Aug 1, 2024
1 parent 053f5b9 commit 32bb7c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,33 +635,6 @@ object UniqueTriggerActivation {
}
}

UniqueType.OneTimeGainStatSpeed -> {
val stat = Stat.safeValueOf(unique.params[1]) ?: return null

if (stat !in Stat.statsWithCivWideField
|| unique.params[0].toIntOrNull() == null
) return null

return {
val statAmount = (unique.params[0].toInt() * (civInfo.gameInfo.speed.statCostModifiers[stat]!!)).roundToInt()
val stats = Stats().add(stat, statAmount.toFloat())
civInfo.addStats(stats)

val filledNotification = if (notification != null && notification.hasPlaceholderParameters())
notification.fillPlaceholders(statAmount.tr())
else notification

val notificationText = getNotificationText(
filledNotification, triggerNotificationText,
"Gained [${stats.toStringForNotifications()}]"
)

if (notificationText != null)
civInfo.addNotification(notificationText, LocationAction(tile?.position), NotificationCategory.General, stat.notificationIcon)
true
}
}

UniqueType.OneTimeGainStatRange -> {
val stat = Stat.safeValueOf(unique.params[2]) ?: return null

Expand Down Expand Up @@ -1056,7 +1029,9 @@ object UniqueTriggerActivation {
val radius = unique.params[1].toInt()
if (radius < 0) return null
val tilesToTakeOver = tile.getTilesInDistance(radius)
.filter { !it.isCityCenter() && it.matchesFilter(tileFilter) }.toList()
.filter {
!it.isCityCenter() && it.matchesFilter(tileFilter) && it.getOwner() != civInfo
}.toList()
if (tilesToTakeOver.none()) return null

/** Lower is better */
Expand Down
4 changes: 2 additions & 2 deletions core/src/com/unciv/models/ruleset/unique/UniqueType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,6 @@ enum class UniqueType(
OneTimeProvideResources("Instantly provides [positiveAmount] [stockpiledResource]", UniqueTarget.Triggerable),

OneTimeGainStat("Gain [amount] [stat]", UniqueTarget.Triggerable, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
@Deprecated("As of 4.11.18", ReplaceWith("Gain [amount] [stat] <(modified by game speed)>"))
OneTimeGainStatSpeed("Gain [amount] [stat] (modified by game speed)", UniqueTarget.Triggerable),
OneTimeGainStatRange("Gain [amount]-[amount] [stat]", UniqueTarget.Triggerable),
OneTimeGainPantheon("Gain enough Faith for a Pantheon", UniqueTarget.Triggerable),
OneTimeGainProphet("Gain enough Faith for [amount]% of a Great Prophet", UniqueTarget.Triggerable),
Expand Down Expand Up @@ -942,6 +940,8 @@ enum class UniqueType(
ProvidesGoldWheneverGreatPersonExpended("Provides a sum of gold each time you spend a Great Person", UniqueTarget.Global),
@Deprecated("As of 4.11.19", ReplaceWith("Gain [amount] [stat] <upon expending a [Great Person] unit> <(modified by game speed)>"), DeprecationLevel.ERROR)
ProvidesStatsWheneverGreatPersonExpended("[stats] whenever a Great Person is expended", UniqueTarget.Global),
@Deprecated("As of 4.11.18", ReplaceWith("Gain [amount] [stat] <(modified by game speed)>"), DeprecationLevel.ERROR)
OneTimeGainStatSpeed("Gain [amount] [stat] (modified by game speed)", UniqueTarget.Triggerable),
@Deprecated("As of 4.11.18", ReplaceWith("when above [amount] [stat/resource] <(modified by game speed)>"), DeprecationLevel.ERROR)
ConditionalWhenAboveAmountStatResourceSpeed("when above [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
@Deprecated("As of 4.11.18", ReplaceWith("when below [amount] [stat/resource] <(modified by game speed)>"), DeprecationLevel.ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,16 @@ object UnitActionsFromUniques {
unit.civ.goldenAges.calculateGoldenAgeLength(
unique.params[0].toInt()).tr())
}
UniqueType.OneTimeGainStatSpeed -> {
val stat = unique.params[1]
val modifier = unit.civ.gameInfo.speed.statCostModifiers[Stat.safeValueOf(stat)]
?: unit.civ.gameInfo.speed.modifier
UniqueType.OneTimeGainStat.placeholderText.fillPlaceholders(
(unique.params[0].toInt() * modifier).toInt().tr(), stat
)
UniqueType.OneTimeGainStat -> {
if (unique.conditionals.any { it.type == UniqueType.ModifiedByGameSpeed }) {
val stat = unique.params[1]
val modifier = unit.civ.gameInfo.speed.statCostModifiers[Stat.safeValueOf(stat)]
?: unit.civ.gameInfo.speed.modifier
UniqueType.OneTimeGainStat.placeholderText.fillPlaceholders(
(unique.params[0].toInt() * modifier).toInt().tr(), stat
)
}
else unique.text.removeConditionals()
}
UniqueType.OneTimeGainStatRange -> {
val stat = unique.params[2]
Expand Down

0 comments on commit 32bb7c8

Please sign in to comment.