mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-11 02:20:19 +07:00
Added overload to MapUnit.getMatchingUniques to get uniques from civ as well - see #5494
This commit is contained in:
parent
d89211c6bb
commit
1a1194236b
@ -207,10 +207,16 @@ class MapUnit {
|
|||||||
fun getMatchingUniques(placeholderText: String): Sequence<Unique> =
|
fun getMatchingUniques(placeholderText: String): Sequence<Unique> =
|
||||||
tempUniques.asSequence().filter { it.placeholderText == placeholderText }
|
tempUniques.asSequence().filter { it.placeholderText == placeholderText }
|
||||||
|
|
||||||
fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals? = null) = sequence {
|
fun getMatchingUniques(
|
||||||
|
uniqueType: UniqueType,
|
||||||
|
stateForConditionals: StateForConditionals = StateForConditionals(civInfo, unit=this),
|
||||||
|
checkCivInfoUniques:Boolean = false
|
||||||
|
) = sequence {
|
||||||
yieldAll(tempUniques.asSequence()
|
yieldAll(tempUniques.asSequence()
|
||||||
.filter { it.type == uniqueType && it.conditionalsApply(stateForConditionals) }
|
.filter { it.type == uniqueType && it.conditionalsApply(stateForConditionals) }
|
||||||
)
|
)
|
||||||
|
if (checkCivInfoUniques)
|
||||||
|
yieldAll(civInfo.getMatchingUniques(uniqueType, stateForConditionals))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasUnique(unique: String): Boolean {
|
fun hasUnique(unique: String): Boolean {
|
||||||
@ -306,13 +312,11 @@ class MapUnit {
|
|||||||
if (isEmbarked()) 2
|
if (isEmbarked()) 2
|
||||||
else baseUnit.movement
|
else baseUnit.movement
|
||||||
|
|
||||||
movement += (getMatchingUniques(UniqueType.Movement, StateForConditionals(civInfo = civInfo, unit = this)) +
|
movement += getMatchingUniques(UniqueType.Movement, checkCivInfoUniques = true)
|
||||||
civInfo.getMatchingUniques(UniqueType.Movement, StateForConditionals(civInfo = civInfo, unit = this)))
|
|
||||||
.sumOf { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
|
|
||||||
// Deprecated since 3.17.5
|
// Deprecated since 3.17.5
|
||||||
for (unique in civInfo.getMatchingUniques(UniqueType.MovementUnits)
|
for (unique in getMatchingUniques(UniqueType.MovementUnits, checkCivInfoUniques = true))
|
||||||
+ getMatchingUniques(UniqueType.MovementUnits))
|
|
||||||
if (matchesFilter(unique.params[1]))
|
if (matchesFilter(unique.params[1]))
|
||||||
movement += unique.params[0].toInt()
|
movement += unique.params[0].toInt()
|
||||||
|
|
||||||
@ -346,9 +350,7 @@ class MapUnit {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
visibilityRange += (getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this))
|
visibilityRange += getMatchingUniques(UniqueType.Sight, checkCivInfoUniques = true).sumOf { it.params[0].toInt() }
|
||||||
+ civInfo.getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this))
|
|
||||||
).sumOf { it.params[0].toInt() }
|
|
||||||
|
|
||||||
// Deprecated since 3.17.5
|
// Deprecated since 3.17.5
|
||||||
for (unique in getMatchingUniques(UniqueType.SightUnits))
|
for (unique in getMatchingUniques(UniqueType.SightUnits))
|
||||||
@ -1119,8 +1121,7 @@ class MapUnit {
|
|||||||
pressureAdded *= unique.params[0].toPercent()
|
pressureAdded *= unique.params[0].toPercent()
|
||||||
//
|
//
|
||||||
|
|
||||||
for (unique in getMatchingUniques(UniqueType.SpreadReligionStrength, StateForConditionals(civInfo = civInfo, unit = this))
|
for (unique in getMatchingUniques(UniqueType.SpreadReligionStrength, checkCivInfoUniques = true))
|
||||||
+ civInfo.getMatchingUniques(UniqueType.SpreadReligionStrength, StateForConditionals(civInfo = civInfo, unit = this)))
|
|
||||||
pressureAdded *= unique.params[0].toPercent()
|
pressureAdded *= unique.params[0].toPercent()
|
||||||
|
|
||||||
return pressureAdded.toInt()
|
return pressureAdded.toInt()
|
||||||
|
Loading…
Reference in New Issue
Block a user