mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 22:30:18 +07:00
"(modified by game speed)" modifier (#11696)
* "(modified by game speed)" modifier * Added missing flags * Fixed G&K ruleset
This commit is contained in:
@ -117,7 +117,7 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
||||
(
|
||||
religionOwningCiv.getMatchingUniques(UniqueType.StatsWhenAdoptingReligionSpeed)
|
||||
+ religionOwningCiv.getMatchingUniques(UniqueType.StatsWhenAdoptingReligion)
|
||||
).map { it.stats }
|
||||
).map { it.stats.times(if (!it.isModifiedByGameSpeed()) 1f else city.civ.gameInfo.speed.modifier) }
|
||||
.reduce { acc, stats -> acc + stats }
|
||||
|
||||
for ((key, value) in statsGranted)
|
||||
|
@ -111,13 +111,13 @@ object Conditionals {
|
||||
UniqueType.ConditionalWithoutResource -> state.getResourceAmount(condition.params[0]) <= 0
|
||||
|
||||
UniqueType.ConditionalWhenAboveAmountStatResource ->
|
||||
checkResourceOrStatAmount(condition.params[1], condition.params[0].toFloat(), Float.MAX_VALUE)
|
||||
checkResourceOrStatAmount(condition.params[1], condition.params[0].toFloat(), Float.MAX_VALUE, unique?.isModifiedByGameSpeed() == true)
|
||||
{ current, lowerLimit, _ -> current > lowerLimit }
|
||||
UniqueType.ConditionalWhenBelowAmountStatResource ->
|
||||
checkResourceOrStatAmount(condition.params[1], Float.MIN_VALUE, condition.params[0].toFloat())
|
||||
checkResourceOrStatAmount(condition.params[1], Float.MIN_VALUE, condition.params[0].toFloat(), unique?.isModifiedByGameSpeed() == true)
|
||||
{ current, _, upperLimit -> current < upperLimit }
|
||||
UniqueType.ConditionalWhenBetweenStatResource ->
|
||||
checkResourceOrStatAmount(condition.params[2], condition.params[0].toFloat(), condition.params[1].toFloat())
|
||||
checkResourceOrStatAmount(condition.params[2], condition.params[0].toFloat(), condition.params[1].toFloat(), unique?.isModifiedByGameSpeed() == true)
|
||||
{ current, lowerLimit, upperLimit -> current >= lowerLimit && current <= upperLimit }
|
||||
UniqueType.ConditionalWhenAboveAmountStatResourceSpeed ->
|
||||
checkResourceOrStatAmount(condition.params[1], condition.params[0].toFloat(), Float.MAX_VALUE, true)
|
||||
|
@ -43,7 +43,7 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
|
||||
|
||||
fun hasFlag(flag: UniqueFlag) = type != null && type.flags.contains(flag)
|
||||
fun isHiddenToUsers() = hasFlag(UniqueFlag.HiddenToUsers) || conditionals.any { it.type == UniqueType.ModifierHiddenFromUsers }
|
||||
|
||||
fun isModifiedByGameSpeed() = conditionals.any { it.type == UniqueType.ModifiedByGameSpeed }
|
||||
fun hasTriggerConditional(): Boolean {
|
||||
if (conditionals.none()) return false
|
||||
return conditionals.any { conditional ->
|
||||
|
@ -5,6 +5,7 @@ import java.util.EnumSet
|
||||
enum class UniqueFlag {
|
||||
HiddenToUsers,
|
||||
NoConditionals,
|
||||
AcceptsSpeedModifier
|
||||
;
|
||||
companion object {
|
||||
val setOfHiddenToUsers: EnumSet<UniqueFlag> = EnumSet.of(HiddenToUsers)
|
||||
|
@ -603,7 +603,9 @@ object UniqueTriggerActivation {
|
||||
) return null
|
||||
|
||||
return {
|
||||
val statAmount = unique.params[0].toInt()
|
||||
var statAmount = unique.params[0].toInt()
|
||||
if (unique.isModifiedByGameSpeed()) statAmount = (statAmount * civInfo.gameInfo.speed.statCostModifiers[stat]!!).roundToInt()
|
||||
|
||||
val stats = Stats().add(stat, statAmount.toFloat())
|
||||
civInfo.addStats(stats)
|
||||
|
||||
|
@ -221,8 +221,9 @@ enum class UniqueType(
|
||||
DisablesReligion("Starting in this era disables religion", UniqueTarget.Era),
|
||||
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||
StatsWhenAdoptingReligion("[stats] when a city adopts this religion for the first time", UniqueTarget.Global, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
||||
@Deprecated("As of 4.11.18", ReplaceWith("[stats] when a city adopts this religion for the first time <(modified by game speed)>"))
|
||||
StatsWhenAdoptingReligionSpeed("[stats] when a city adopts this religion for the first time (modified by game speed)", UniqueTarget.Global),
|
||||
StatsWhenAdoptingReligion("[stats] when a city adopts this religion for the first time", UniqueTarget.Global),
|
||||
NaturalReligionSpreadStrength("[relativeAmount]% Natural religion spread [cityFilter]", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
||||
ReligionSpreadDistance("Religion naturally spreads to cities [amount] tiles away", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
MayNotGenerateGreatProphet("May not generate great prophet equivalents naturally", UniqueTarget.Global),
|
||||
@ -691,13 +692,17 @@ enum class UniqueType(
|
||||
ConditionalWithoutResource("without [resource]", UniqueTarget.Conditional),
|
||||
|
||||
// Supports also stockpileable resources (Gold, Faith, Culture, Science)
|
||||
ConditionalWhenAboveAmountStatResource("when above [amount] [stat/resource]", UniqueTarget.Conditional),
|
||||
ConditionalWhenBelowAmountStatResource("when below [amount] [stat/resource]", UniqueTarget.Conditional),
|
||||
ConditionalWhenBetweenStatResource("when between [amount] and [amount] [stat/resource]", UniqueTarget.Conditional),
|
||||
ConditionalWhenAboveAmountStatResource("when above [amount] [stat/resource]", UniqueTarget.Conditional, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
||||
ConditionalWhenBelowAmountStatResource("when below [amount] [stat/resource]", UniqueTarget.Conditional, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
||||
ConditionalWhenBetweenStatResource("when between [amount] and [amount] [stat/resource]", UniqueTarget.Conditional, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
||||
|
||||
// The game speed-adjusted versions of above
|
||||
|
||||
@Deprecated("As of 4.11.18", ReplaceWith("when above [amount] [stat/resource] <(modified by game speed)>"))
|
||||
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)>"))
|
||||
ConditionalWhenBelowAmountStatResourceSpeed("when below [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
||||
@Deprecated("As of 4.11.18", ReplaceWith("when between [amount] and [amount] [stat/resource] <(modified by game speed)>"))
|
||||
ConditionalWhenBetweenStatResourceSpeed("when between [amount] and [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
||||
|
||||
/////// city conditionals
|
||||
@ -780,7 +785,8 @@ enum class UniqueType(
|
||||
OneTimeConsumeResources("Instantly consumes [positiveAmount] [stockpiledResource]", UniqueTarget.Triggerable),
|
||||
OneTimeProvideResources("Instantly provides [positiveAmount] [stockpiledResource]", UniqueTarget.Triggerable),
|
||||
|
||||
OneTimeGainStat("Gain [amount] [stat]", 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),
|
||||
@ -866,6 +872,8 @@ enum class UniqueType(
|
||||
ModifierHiddenFromUsers("hidden from users", UniqueTarget.MetaModifier),
|
||||
ForEveryCountable("for every [countable]", UniqueTarget.MetaModifier),
|
||||
ForEveryAmountCountable("for every [amount] [countable]", UniqueTarget.MetaModifier),
|
||||
ModifiedByGameSpeed("(modified by game speed)", UniqueTarget.MetaModifier,
|
||||
docDescription = "Can only be applied to certain uniques, see details of each unique for specifics"),
|
||||
Comment("Comment [comment]", *UniqueTarget.Displayable,
|
||||
docDescription = "Allows displaying arbitrary text in a Unique listing. Only the text within the '[]' brackets will be displayed, the rest serves to allow Ruleset validation to recognize the intent."),
|
||||
|
||||
|
Reference in New Issue
Block a user