mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-02 12:24:15 +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> =
|
||||
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()
|
||||
.filter { it.type == uniqueType && it.conditionalsApply(stateForConditionals) }
|
||||
)
|
||||
if (checkCivInfoUniques)
|
||||
yieldAll(civInfo.getMatchingUniques(uniqueType, stateForConditionals))
|
||||
}
|
||||
|
||||
fun hasUnique(unique: String): Boolean {
|
||||
@ -306,13 +312,11 @@ class MapUnit {
|
||||
if (isEmbarked()) 2
|
||||
else baseUnit.movement
|
||||
|
||||
movement += (getMatchingUniques(UniqueType.Movement, StateForConditionals(civInfo = civInfo, unit = this)) +
|
||||
civInfo.getMatchingUniques(UniqueType.Movement, StateForConditionals(civInfo = civInfo, unit = this)))
|
||||
movement += getMatchingUniques(UniqueType.Movement, checkCivInfoUniques = true)
|
||||
.sumOf { it.params[0].toInt() }
|
||||
|
||||
// Deprecated since 3.17.5
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.MovementUnits)
|
||||
+ getMatchingUniques(UniqueType.MovementUnits))
|
||||
for (unique in getMatchingUniques(UniqueType.MovementUnits, checkCivInfoUniques = true))
|
||||
if (matchesFilter(unique.params[1]))
|
||||
movement += unique.params[0].toInt()
|
||||
|
||||
@ -346,9 +350,7 @@ class MapUnit {
|
||||
return 1
|
||||
}
|
||||
|
||||
visibilityRange += (getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this))
|
||||
+ civInfo.getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this))
|
||||
).sumOf { it.params[0].toInt() }
|
||||
visibilityRange += getMatchingUniques(UniqueType.Sight, checkCivInfoUniques = true).sumOf { it.params[0].toInt() }
|
||||
|
||||
// Deprecated since 3.17.5
|
||||
for (unique in getMatchingUniques(UniqueType.SightUnits))
|
||||
@ -1112,15 +1114,14 @@ class MapUnit {
|
||||
|
||||
fun getPressureAddedFromSpread(): Int {
|
||||
var pressureAdded = baseUnit.religiousStrength.toFloat()
|
||||
|
||||
|
||||
// Deprecated since 3.17.5
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.SpreadReligionStrengthUnits))
|
||||
if (matchesFilter(unique.params[0]))
|
||||
pressureAdded *= unique.params[0].toPercent()
|
||||
//
|
||||
|
||||
for (unique in getMatchingUniques(UniqueType.SpreadReligionStrength, StateForConditionals(civInfo = civInfo, unit = this))
|
||||
+ civInfo.getMatchingUniques(UniqueType.SpreadReligionStrength, StateForConditionals(civInfo = civInfo, unit = this)))
|
||||
|
||||
for (unique in getMatchingUniques(UniqueType.SpreadReligionStrength, checkCivInfoUniques = true))
|
||||
pressureAdded *= unique.params[0].toPercent()
|
||||
|
||||
return pressureAdded.toInt()
|
||||
|
Loading…
Reference in New Issue
Block a user