From 155c4a29860dd49ed37009e1ef873fc2c9b2d90f Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 23 Apr 2023 14:19:35 -0500 Subject: [PATCH] Handle running out of energy --- src/data/projEntry.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index 761b5ad..6136133 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -727,6 +727,18 @@ export const main = createLayer("main", function (this: BaseLayer) { } energy.value = Decimal.add(energy.value, Decimal.times(computedEnergyModifier.value, diff)); + + if (Decimal.lt(energy.value, 0)) { + // Uh oh, time to de-power machines! + energy.value = 0; + mine.value.state = { ...(mine.value.state as object), powered: false }; + toast.warning( +
+

Ran out of energy!

+
All machines have been turned off.
+
+ ); + } }); const energyChange = computed(() => {