Preview energy [production] changes

This commit is contained in:
thepaperpilot 2023-04-22 19:54:37 -05:00
parent ceb8ebc7ec
commit 91e3e7dad1

View file

@ -11,14 +11,13 @@ import {
getUniqueNodeID getUniqueNodeID
} from "features/boards/board"; } from "features/boards/board";
import { jsx } from "features/feature"; import { jsx } from "features/feature";
import { createResource, displayResource } from "features/resources/resource"; import { createResource } from "features/resources/resource";
import { createTabFamily } from "features/tabs/tabFamily"; import { createTabFamily } from "features/tabs/tabFamily";
import Formula, { calculateCost } from "game/formulas/formulas"; import Formula, { calculateCost } from "game/formulas/formulas";
import type { BaseLayer, GenericLayer } from "game/layers"; import type { BaseLayer, GenericLayer } from "game/layers";
import { createLayer } from "game/layers"; import { createLayer } from "game/layers";
import { createMultiplicativeModifier, createSequentialModifier } from "game/modifiers"; import { createMultiplicativeModifier, createSequentialModifier } from "game/modifiers";
import { Persistent, persistent } from "game/persistence"; import { Persistent, State, persistent } from "game/persistence";
import { State } from "game/persistence";
import type { Player } from "game/player"; import type { Player } from "game/player";
import player from "game/player"; import player from "game/player";
import settings from "game/settings"; import settings from "game/settings";
@ -28,7 +27,7 @@ import { camelToTitle } from "util/common";
import { render } from "util/vue"; import { render } from "util/vue";
import { ComputedRef, computed, nextTick, reactive, ref, watch } from "vue"; import { ComputedRef, computed, nextTick, reactive, ref, watch } from "vue";
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
import { createCollapsibleModifierSections } from "./common"; import { createCollapsibleModifierSections, createFormulaPreview } from "./common";
import "./main.css"; import "./main.css";
const toast = useToast(); const toast = useToast();
@ -368,6 +367,26 @@ export const main = createLayer("main", function (this: BaseLayer) {
energy.value = Decimal.add(energy.value, Decimal.times(computedEnergyModifier.value, diff)); energy.value = Decimal.add(energy.value, Decimal.times(computedEnergyModifier.value, diff));
}); });
const energyChange = computed(() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (board.selectedAction.value === board.types.brokenFactory.actions![0]) {
return -1000;
}
return 0;
});
const energyPreview = createFormulaPreview(
Formula.variable(0).add(energy),
() => Decimal.neq(energyChange.value, 0),
energyChange
);
const energyProductionChange = computed(() => 0);
const energyProductionPreview = createFormulaPreview(
Formula.variable(0).add(computedEnergyModifier),
() => Decimal.neq(energyProductionChange.value, 0),
energyProductionChange
);
return { return {
name: "World", name: "World",
board, board,
@ -379,14 +398,15 @@ export const main = createLayer("main", function (this: BaseLayer) {
<StickyVue class="nav-container"> <StickyVue class="nav-container">
<span class="nav-segment"> <span class="nav-segment">
<h2 style="color: white; text-shadow: 0px 0px 10px white;"> <h2 style="color: white; text-shadow: 0px 0px 10px white;">
{displayResource(energy)} {render(energyPreview)}
</h2>{" "} </h2>{" "}
energy energy
</span> </span>
<span class="nav-segment"> <span class="nav-segment">
( (
<h3 style="color: white; text-shadow: 0px 0px 10px white;"> <h3 style="color: white; text-shadow: 0px 0px 10px white;">
+{format(computedEnergyModifier.value)} {Decimal.gt(computedEnergyModifier.value, 0) ? "+" : ""}
{render(energyProductionPreview)}
</h3> </h3>
/s) /s)
</span> </span>