Return zero instead of throwing exception
This commit is contained in:
parent
2b9920c8ac
commit
5ee05f3a6b
@ -52,9 +52,7 @@ interface IMatteryEnergyStorage : IEnergyStorage {
|
||||
* @return energy extracted
|
||||
*/
|
||||
fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal {
|
||||
require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" }
|
||||
|
||||
if (!energyFlow.output)
|
||||
if (howMuch.isNegative || !energyFlow.output)
|
||||
return Decimal.ZERO
|
||||
|
||||
return extractEnergy(howMuch, simulate)
|
||||
@ -86,9 +84,7 @@ interface IMatteryEnergyStorage : IEnergyStorage {
|
||||
* @return energy extracted
|
||||
*/
|
||||
fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal {
|
||||
require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" }
|
||||
|
||||
if (!energyFlow.input)
|
||||
if (howMuch.isNegative || !energyFlow.input)
|
||||
return Decimal.ZERO
|
||||
|
||||
return receiveEnergy(howMuch, simulate)
|
||||
|
Loading…
Reference in New Issue
Block a user