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()
|
get() = setOf()
|
||||||
|
|
||||||
private fun positiveDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
private fun positiveDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||||
|
if (isEmpty)
|
||||||
|
return Decimal.ZERO
|
||||||
|
|
||||||
return iterator()
|
return iterator()
|
||||||
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO).moreThanZero() * it.count }
|
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO).moreThanZero() * it.count }
|
||||||
.reduce(Decimal.ZERO, reducer)
|
.reduce(Decimal.ZERO, reducer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun anyDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
private fun anyDecimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||||
|
if (isEmpty)
|
||||||
|
return Decimal.ZERO
|
||||||
|
|
||||||
return iterator()
|
return iterator()
|
||||||
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO) * it.count }
|
.map { (it.getCapability(MatteryCapability.UPGRADE)?.let(fn) ?: Decimal.ZERO) * it.count }
|
||||||
.reduce(Decimal.ZERO, reducer)
|
.reduce(Decimal.ZERO, reducer)
|
||||||
|
Loading…
Reference in New Issue
Block a user