From d3faec6a6629d241a9d95f2321ad6f5436e5c130 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 17 Feb 2024 19:04:55 -0600 Subject: [PATCH 1/3] Add Nodes to the text that can disappear in projEntry --- src/data/projEntry.tsx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index e4640b6..f69ac8b 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -1,3 +1,4 @@ +import Node from "components/Node.vue"; import Spacer from "components/layout/Spacer.vue"; import { jsx } from "features/feature"; import { createResource, trackBest, trackOOMPS, trackTotal } from "features/resources/resource"; @@ -48,19 +49,35 @@ export const main = createLayer("main", function (this: BaseLayer) { links: tree.links, display: jsx(() => ( <> - {player.devSpeed === 0 ?
Game Paused
: null} + {player.devSpeed === 0 ? ( +
+ Game Paused + +
+ ) : null} {player.devSpeed != null && player.devSpeed !== 0 && player.devSpeed !== 1 ? ( -
Dev Speed: {format(player.devSpeed)}x
+
+ Dev Speed: {format(player.devSpeed)}x + +
) : null} {player.offlineTime != null && player.offlineTime !== 0 ? ( -
Offline Time: {formatTime(player.offlineTime)}
+
+ Offline Time: {formatTime(player.offlineTime)} + +
) : null}
{Decimal.lt(points.value, "1e1000") ? You have : null}

{format(points.value)}

{Decimal.lt(points.value, "1e1e6") ? points : null}
- {Decimal.gt(pointGain.value, 0) ?
({oomps.value})
: null} + {Decimal.gt(pointGain.value, 0) ? ( +
+ ({oomps.value}) + +
+ ) : null} {render(tree)} From 1f22f506dd978a352a62a50a7a95209da3a30344 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 13 Feb 2024 08:25:32 -0600 Subject: [PATCH 2/3] Add tests for tree reset propagation --- src/features/trees/tree.ts | 2 +- tests/features/tree.test.ts | 111 ++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/features/tree.test.ts diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index 8ec317f..4e43bbf 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -224,7 +224,7 @@ export interface BaseTree { id: string; /** The link objects for each of the branches of the tree. */ links: Ref; - /** Cause a reset on this node and propagate it through the tree according to {@link resetPropagation}. */ + /** Cause a reset on this node and propagate it through the tree according to {@link TreeOptions.resetPropagation}. */ reset: (node: GenericTreeNode) => void; /** A flag that is true while the reset is still propagating through the tree. */ isResetting: Ref; diff --git a/tests/features/tree.test.ts b/tests/features/tree.test.ts new file mode 100644 index 0000000..206988f --- /dev/null +++ b/tests/features/tree.test.ts @@ -0,0 +1,111 @@ +import { beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; +import { Ref, ref } from "vue"; +import "../utils"; +import { + createTree, + createTreeNode, + defaultResetPropagation, + invertedResetPropagation, + branchedResetPropagation +} from "features/trees/tree"; +import { createReset, GenericReset } from "features/reset"; + +describe("Reset propagation", () => { + let shouldReset: Ref, shouldNotReset: Ref; + let goodReset: GenericReset, badReset: GenericReset; + beforeAll(() => { + shouldReset = ref(false); + shouldNotReset = ref(false); + goodReset = createReset(() => ({ + thingsToReset: [], + onReset() { + shouldReset.value = true; + } + })); + badReset = createReset(() => ({ + thingsToReset: [], + onReset() { + shouldNotReset.value = true; + } + })); + }); + beforeEach(() => { + shouldReset.value = false; + shouldNotReset.value = false; + }); + test("No resets", () => { + expect(() => { + const a = createTreeNode(() => ({})); + const b = createTreeNode(() => ({})); + const c = createTreeNode(() => ({})); + const tree = createTree(() => ({ + nodes: [[a], [b], [c]] + })); + tree.reset(a); + }).not.toThrowError(); + }); + + test("Do not propagate resets", () => { + const a = createTreeNode(() => ({ reset: badReset })); + const b = createTreeNode(() => ({ reset: badReset })); + const c = createTreeNode(() => ({ reset: badReset })); + const tree = createTree(() => ({ + nodes: [[a], [b], [c]] + })); + tree.reset(b); + expect(shouldNotReset.value).toBe(false); + }); + + test("Default propagation", () => { + const a = createTreeNode(() => ({ reset: goodReset })); + const b = createTreeNode(() => ({})); + const c = createTreeNode(() => ({ reset: badReset })); + const tree = createTree(() => ({ + nodes: [[a], [b], [c]], + resetPropagation: defaultResetPropagation + })); + tree.reset(b); + expect(shouldReset.value).toBe(true); + expect(shouldNotReset.value).toBe(false); + }); + + test("Inverted propagation", () => { + const a = createTreeNode(() => ({ reset: badReset })); + const b = createTreeNode(() => ({})); + const c = createTreeNode(() => ({ reset: goodReset })); + const tree = createTree(() => ({ + nodes: [[a], [b], [c]], + resetPropagation: invertedResetPropagation + })); + tree.reset(b); + expect(shouldReset.value).toBe(true); + expect(shouldNotReset.value).toBe(false); + }); + + test("Branched propagation", () => { + const a = createTreeNode(() => ({ reset: badReset })); + const b = createTreeNode(() => ({})); + const c = createTreeNode(() => ({ reset: goodReset })); + const tree = createTree(() => ({ + nodes: [[a, b, c]], + resetPropagation: branchedResetPropagation, + branches: [{ startNode: b, endNode: c }] + })); + tree.reset(b); + expect(shouldReset.value).toBe(true); + expect(shouldNotReset.value).toBe(false); + }); + + test("Branched propagation not bi-directional", () => { + const a = createTreeNode(() => ({ reset: badReset })); + const b = createTreeNode(() => ({})); + const c = createTreeNode(() => ({ reset: badReset })); + const tree = createTree(() => ({ + nodes: [[a, b, c]], + resetPropagation: branchedResetPropagation, + branches: [{ startNode: c, endNode: b }] + })); + tree.reset(b); + expect(shouldNotReset.value).toBe(false); + }); +}); From b40d4bef32ee6e9947e2a4b2399951cc4ba252d1 Mon Sep 17 00:00:00 2001 From: escapee Date: Wed, 21 Feb 2024 11:13:17 -0800 Subject: [PATCH 3/3] Allow both cases in shift+hotkeys --- src/features/hotkey.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/hotkey.tsx b/src/features/hotkey.tsx index 51fafbb..80eebbd 100644 --- a/src/features/hotkey.tsx +++ b/src/features/hotkey.tsx @@ -108,7 +108,7 @@ document.onkeydown = function (e) { if (e.ctrlKey) { key = "ctrl+" + key; } - const hotkey = hotkeys[key]; + const hotkey = hotkeys[key] ?? hotkeys[key.toLowerCase()]; if (hotkey && unref(hotkey.enabled)) { e.preventDefault(); hotkey.onPress();