Remove isNotEmpty filter because they are already not empty
This commit is contained in:
parent
2720f6fbf0
commit
cc4fcf398f
@ -23,15 +23,14 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set<Upgrad
|
|||||||
|
|
||||||
protected fun decimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
protected fun decimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal {
|
||||||
return iterator()
|
return iterator()
|
||||||
.filter { it.isNotEmpty }
|
|
||||||
.map { it.getCapability(MatteryCapability.UPGRADE).map(fn).orElse(Decimal.ZERO).moreThanZero() * it.count }
|
.map { it.getCapability(MatteryCapability.UPGRADE).map(fn).orElse(Decimal.ZERO).moreThanZero() * it.count }
|
||||||
.reduce(Decimal.ZERO, reducer)
|
.reduce(Decimal.ZERO, reducer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val speedBonus: Double
|
override val speedBonus: Double
|
||||||
get() = iterator().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.speedBonus }.orElse(0.0) * it.count }.sum()
|
get() = iterator().mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.speedBonus }.orElse(0.0) * it.count }.sum()
|
||||||
override val processingItems: Int
|
override val processingItems: Int
|
||||||
get() = iterator().filter { it.isNotEmpty }.mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b }
|
get() = iterator().mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b }
|
||||||
override val energyStorageFlat: Decimal
|
override val energyStorageFlat: Decimal
|
||||||
get() = decimals(IMatteryUpgrade::energyStorageFlat, Decimal::plus)
|
get() = decimals(IMatteryUpgrade::energyStorageFlat, Decimal::plus)
|
||||||
override val energyStorage: Decimal
|
override val energyStorage: Decimal
|
||||||
@ -43,7 +42,7 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set<Upgrad
|
|||||||
override val energyConsumed: Decimal
|
override val energyConsumed: Decimal
|
||||||
get() = decimals(IMatteryUpgrade::energyConsumed, Decimal::plus)
|
get() = decimals(IMatteryUpgrade::energyConsumed, Decimal::plus)
|
||||||
override val failureMultiplier: Double
|
override val failureMultiplier: Double
|
||||||
get() = iterator().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b }
|
get() = iterator().mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b }
|
||||||
override val energyThroughputFlat: Decimal
|
override val energyThroughputFlat: Decimal
|
||||||
get() = decimals(IMatteryUpgrade::energyThroughputFlat, Decimal::plus)
|
get() = decimals(IMatteryUpgrade::energyThroughputFlat, Decimal::plus)
|
||||||
override val energyThroughput: Decimal
|
override val energyThroughput: Decimal
|
||||||
|
Loading…
Reference in New Issue
Block a user