From c8efdea99945e48ef22e0067626b4fb70539355b Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 14 May 2023 12:07:08 -0500 Subject: [PATCH] Add displays for influence cost multipliers --- src/data/nodeTypes.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/data/nodeTypes.tsx b/src/data/nodeTypes.tsx index fde2f31..32e33d7 100644 --- a/src/data/nodeTypes.tsx +++ b/src/data/nodeTypes.tsx @@ -53,6 +53,7 @@ import { } from "./data"; import { GenericPlane, createPlane } from "./planes"; import { main } from "./projEntry"; +import { exponentialFormat } from "util/bignum"; export const mine = { shape: Shape.Diamond, @@ -461,12 +462,19 @@ export const portalGenerator = { }; } else if (draggingNode?.type === "influence") { const influence = (draggingNode.state as unknown as InfluenceState).type; - const { influences } = node.state as unknown as PortalGeneratorState; - if (influences.includes(influence)) { + const selectedInfluences = (node.state as unknown as PortalGeneratorState).influences; + if (selectedInfluences.includes(influence)) { return { text: "Disconnect", color: "var(--accent2)" }; } + const cost = influences[influence].cost; + let costDisplay; + if (Decimal.lt(cost, 1e3)) { + costDisplay = formatWhole(cost); + } else { + costDisplay = exponentialFormat(cost, 0); + } return { - text: "Add influence", + text: `Add influence (${costDisplay}x cost)`, color: "var(--accent2)" }; } else if (draggingNode?.type === "portal") { @@ -650,6 +658,13 @@ export const influence = { : Shape.Circle, size: 50, title: node => influences[(node.state as unknown as InfluenceState).type].display, + subtitle: node => { + const cost = influences[(node.state as unknown as InfluenceState).type].cost; + if (Decimal.lt(cost, 1e3)) { + return `${formatWhole(cost)}x cost`; + } + return `${exponentialFormat(cost, 0)}x cost`; + }, label: node => { if (node === main.board.selectedNode.value) { const state = node.state as unknown as InfluenceState;