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