mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 13:49:54 +07:00
chore: more modifier cleanups
This commit is contained in:
@ -45,7 +45,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) || hasModifier(UniqueType.ModifierHiddenFromUsers)
|
||||
|
||||
fun getModifiers(type: UniqueType) = modifiers.filter { it.type == type }
|
||||
fun getModifiers(type: UniqueType) = modifiers.asSequence().filter { it.type == type }
|
||||
fun hasModifier(type: UniqueType) = getModifiers(type).any()
|
||||
fun isModifiedByGameSpeed() = hasModifier(UniqueType.ModifiedByGameSpeed)
|
||||
fun hasTriggerConditional(): Boolean {
|
||||
|
@ -442,9 +442,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
fun isProbablySiegeUnit() = isRanged()
|
||||
&& getMatchingUniques(UniqueType.Strength, StateForConditionals.IgnoreConditionals)
|
||||
.any { it.params[0].toInt() > 0
|
||||
&& it.modifiers.any { conditional -> conditional.type == UniqueType.ConditionalVsCity }
|
||||
}
|
||||
.any { it.params[0].toInt() > 0 && it.hasModifier(UniqueType.ConditionalVsCity) }
|
||||
|
||||
fun getForceEvaluation(): Int {
|
||||
if (cachedForceEvaluation < 0) evaluateForce()
|
||||
|
@ -89,7 +89,7 @@ object Suppression {
|
||||
suppressions += sourceObject.getMatchingUniques(UniqueType.SuppressWarnings, StateForConditionals.IgnoreConditionals).map { getWildcardFilter(it) }
|
||||
// Allow suppressing from modifiers in the same Unique
|
||||
if (sourceUnique != null)
|
||||
suppressions += sourceUnique.modifiers.filter { it.type == UniqueType.SuppressWarnings }.map { getWildcardFilter(it) }
|
||||
suppressions += sourceUnique.getModifiers(UniqueType.SuppressWarnings).map { getWildcardFilter(it) }
|
||||
|
||||
for (filter in suppressions)
|
||||
if (matchesFilter(error, filter)) return true
|
||||
|
@ -343,9 +343,7 @@ object TechnologyDescriptions {
|
||||
|
||||
/** Tests whether a Unique is enabled or disabled by [techName] */
|
||||
private fun Unique.isRelatedToTech(techName: String) =
|
||||
modifiers.any {
|
||||
it.isTechConditional() && it.params[0] == techName
|
||||
}
|
||||
modifiers.any { it.isTechConditional() && it.params[0] == techName }
|
||||
|
||||
/** Used by [getAffectedImprovements] only */
|
||||
private data class ImprovementAndUnique(val improvement: TileImprovement, val unique: Unique) {
|
||||
|
Reference in New Issue
Block a user