Shortcut to "isEmpty" in UpgradeContainer to account for most common case
This commit is contained in:
parent
b4fc02b14e
commit
ec68b7ee9c
@ -21,12 +21,18 @@ class UpgradeContainer(
|
||||
get() = setOf()
|
||||
|
||||
private fun positiveDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||
if (isEmpty)
|
||||
return Decimal.ZERO
|
||||
|
||||
return iterator()
|
||||
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO).moreThanZero() * it.count }
|
||||
.reduce(Decimal.ZERO, reducer)
|
||||
}
|
||||
|
||||
private fun anyDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||
if (isEmpty)
|
||||
return Decimal.ZERO
|
||||
|
||||
return iterator()
|
||||
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO) * it.count }
|
||||
.reduce(Decimal.ZERO, reducer)
|
||||
|
Loading…
Reference in New Issue
Block a user