From 07fcccd0e42b4f72754360309731b14c5be4c909 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 8 Oct 2022 15:57:09 -0500 Subject: [PATCH 001/253] Add hotkey to default layer --- src/data/layers/prestige.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/data/layers/prestige.tsx b/src/data/layers/prestige.tsx index 8216af1..4490ded 100644 --- a/src/data/layers/prestige.tsx +++ b/src/data/layers/prestige.tsx @@ -5,6 +5,7 @@ import { main } from "data/projEntry"; import { createCumulativeConversion, createPolynomialScaling } from "features/conversion"; import { jsx } from "features/feature"; +import { createHotkey } from "features/hotkey"; import { createReset } from "features/reset"; import MainDisplay from "features/resources/MainDisplay.vue"; import { createResource } from "features/resources/resource"; @@ -48,6 +49,12 @@ const layer = createLayer(id, function (this: BaseLayer) { treeNode })); + const hotkey = createHotkey(() => ({ + description: "Reset for prestige points", + key: "p", + onPress: resetButton.onClick + })); + return { name, color, @@ -58,7 +65,8 @@ const layer = createLayer(id, function (this: BaseLayer) { {render(resetButton)} )), - treeNode + treeNode, + hotkey }; }); From 73d6fd7566aeacf741e4312a4f0ae1e0a7c5aaf0 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 14 Oct 2022 07:44:12 -0500 Subject: [PATCH 002/253] Fix a couple type issues --- src/util/computed.ts | 2 +- src/util/proxies.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/computed.ts b/src/util/computed.ts index 7ee0930..59db8ab 100644 --- a/src/util/computed.ts +++ b/src/util/computed.ts @@ -38,7 +38,7 @@ export function processComputable>( // @ts-ignore obj[key] = computed(computable.bind(obj)); } else if (isFunction(computable)) { - obj[key] = computable.bind(obj); + obj[key] = computable.bind(obj) as T[S]; // eslint-disable-next-line @typescript-eslint/no-explicit-any (obj[key] as any)[DoNotCache] = true; } diff --git a/src/util/proxies.ts b/src/util/proxies.ts index 065a314..a41b8d1 100644 --- a/src/util/proxies.ts +++ b/src/util/proxies.ts @@ -17,7 +17,7 @@ export type ProxiedWithState = NonNullable extends Record( +export function createLazyProxy( objectFunc: (baseObject: S) => T & S, baseObject: S = {} as S ): T { From 5bea1bf9b4412ea4044a099e1be164cd126d56b5 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Mon, 26 Sep 2022 18:41:10 -0500 Subject: [PATCH 003/253] Fix isFunction typing --- src/features/boards/board.ts | 4 ++-- src/util/common.ts | 7 ++++--- tests/util/common.test.ts | 20 +++++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/features/boards/board.ts b/src/features/boards/board.ts index 4c2cef5..4743370 100644 --- a/src/features/boards/board.ts +++ b/src/features/boards/board.ts @@ -10,7 +10,7 @@ import { } from "features/feature"; import { globalBus } from "game/events"; import type { Persistent, State } from "game/persistence"; -import { persistent, PersistentState } from "game/persistence"; +import { persistent } from "game/persistence"; import type { Unsubscribe } from "nanoevents"; import { isFunction } from "util/common"; import type { @@ -336,7 +336,7 @@ export function createBoard( } export function getNodeProperty(property: NodeComputable, node: BoardNode): T { - return isFunction(property) ? property(node) : unref(property); + return isFunction>(property) ? property(node) : unref(property); } export function getUniqueNodeID(board: GenericBoard): number { diff --git a/src/util/common.ts b/src/util/common.ts index b2ac8f1..d7560dd 100644 --- a/src/util/common.ts +++ b/src/util/common.ts @@ -12,9 +12,10 @@ export function camelToTitle(camel: string): string { return title; } -// eslint-disable-next-line @typescript-eslint/ban-types -export function isFunction(func: unknown): func is Function { - return typeof func === "function"; +export function isFunction, R>( + functionOrValue: ((...args: S) => T) | R +): functionOrValue is (...args: S) => T { + return typeof functionOrValue === "function"; } export enum Direction { diff --git a/tests/util/common.test.ts b/tests/util/common.test.ts index abd1d00..619810f 100644 --- a/tests/util/common.test.ts +++ b/tests/util/common.test.ts @@ -13,13 +13,15 @@ describe("isFunction", () => { test("Given function returns true", () => expect(isFunction(vi.fn())).toBe(true)); // Go through all primitives and basic types - test("Given a string returns false", () => expect(isFunction("test")).toBe(false)); - test("Given a number returns false", () => expect(isFunction(10)).toBe(false)); - test("Given a bigint returns false", () => expect(isFunction(BigInt(10))).toBe(false)); - test("Given a boolean returns false", () => expect(isFunction(true)).toBe(false)); - test("Given undefined returns false", () => expect(isFunction(undefined)).toBe(false)); - test("Given a symbol returns false", () => expect(isFunction(Symbol())).toBe(false)); - test("Given null returns false", () => expect(isFunction(null)).toBe(false)); - test("Given object returns false", () => expect(isFunction({})).toBe(false)); - test("Given array returns false", () => expect(isFunction([])).toBe(false)); + test("Given a non-function returns false", () => { + expect(isFunction("test")).toBe(false); + expect(isFunction(10)).toBe(false); + expect(isFunction(BigInt(10))).toBe(false); + expect(isFunction(true)).toBe(false); + expect(isFunction(undefined)).toBe(false); + expect(isFunction(Symbol())).toBe(false); + expect(isFunction(null)).toBe(false); + expect(isFunction({})).toBe(false); + expect(isFunction([])).toBe(false); + }); }); From a451d4ad949c4f63f2eeaf19a0a1e618102255dd Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Mon, 5 Sep 2022 12:34:38 -0500 Subject: [PATCH 004/253] Add submitOnBlur property to text fields --- src/components/fields/Text.vue | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/fields/Text.vue b/src/components/fields/Text.vue index e7f3ab5..99d1e0c 100644 --- a/src/components/fields/Text.vue +++ b/src/components/fields/Text.vue @@ -9,7 +9,7 @@ v-model="value" :placeholder="placeholder" :maxHeight="maxHeight" - @blur="submit" + @blur="blur" ref="field" /> @@ -28,26 +28,25 @@ diff --git a/src/features/hotkey.tsx b/src/features/hotkey.tsx index bfb958f..b716f9a 100644 --- a/src/features/hotkey.tsx +++ b/src/features/hotkey.tsx @@ -13,6 +13,7 @@ import type { import { processComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { shallowReactive, unref } from "vue"; +import HotkeyVue from "components/Hotkey.vue"; export const hotkeys: Record = shallowReactive({}); export const HotkeyType = Symbol("Hotkey"); @@ -102,8 +103,8 @@ registerInfoComponent(

Hotkeys

{keys.map(hotkey => ( -
- {hotkey?.key}: {hotkey?.description} +
+ {hotkey?.description}
))}
From d02b7294a1528280add3847adcc2ffc107db171f Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Mon, 19 Dec 2022 07:29:28 -0600 Subject: [PATCH 032/253] hotkey tweaks --- src/features/hotkey.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/hotkey.tsx b/src/features/hotkey.tsx index b716f9a..e4cd165 100644 --- a/src/features/hotkey.tsx +++ b/src/features/hotkey.tsx @@ -13,7 +13,7 @@ import type { import { processComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { shallowReactive, unref } from "vue"; -import HotkeyVue from "components/Hotkey.vue"; +import Hotkey from "components/Hotkey.vue"; export const hotkeys: Record = shallowReactive({}); export const HotkeyType = Symbol("Hotkey"); @@ -103,8 +103,8 @@ registerInfoComponent(

Hotkeys

{keys.map(hotkey => ( -
- {hotkey?.description} +
+ {hotkey?.description}
))}
From 81e774bbd4ccdb43b8e841c72733d1229eacebd9 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Mon, 19 Dec 2022 07:41:49 -0600 Subject: [PATCH 033/253] Make hotkeys 2-column --- src/features/hotkey.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/features/hotkey.tsx b/src/features/hotkey.tsx index e4cd165..e79b65b 100644 --- a/src/features/hotkey.tsx +++ b/src/features/hotkey.tsx @@ -102,11 +102,13 @@ registerInfoComponent(

Hotkeys

- {keys.map(hotkey => ( -
- {hotkey?.description} -
- ))} +
+ {keys.map(hotkey => ( +
+ {hotkey?.description} +
+ ))} +
); }) From 9b49aedccb84a7ed9a1e0ac04589c3d284c7d2e5 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 20 Dec 2022 21:26:25 -0600 Subject: [PATCH 034/253] Add eslint rule for strict boolean expressions and fix linting issues --- .eslintrc.js | 12 ++++++++-- src/App.vue | 2 +- src/components/Info.vue | 2 +- src/components/Modal.vue | 4 ++-- src/components/NaNScreen.vue | 8 +++---- src/components/Options.vue | 2 +- src/components/Save.vue | 6 ++--- src/components/SavesManager.vue | 2 +- src/components/fields/Slider.vue | 2 +- src/components/fields/Text.vue | 2 +- src/components/fields/Toggle.vue | 2 +- src/components/math/Fraction.vue | 1 + src/components/math/Sqrt.vue | 6 +++-- src/data/common.tsx | 6 ++--- src/data/projEntry.tsx | 4 ++-- src/features/achievements/achievement.tsx | 2 +- src/features/bars/bar.ts | 8 ++++++- src/features/boards/Board.vue | 2 +- src/features/boards/BoardNode.vue | 8 +++---- src/features/buyable.tsx | 28 ++++++++++++++--------- src/features/challenges/Challenge.vue | 8 +++---- src/features/challenges/challenge.tsx | 16 +++++++++---- src/features/clickables/Clickable.vue | 2 +- src/features/clickables/clickable.ts | 15 ++++++++---- src/features/conversion.ts | 17 ++++++++------ src/features/feature.ts | 4 ++-- src/features/milestones/Milestone.vue | 4 ++-- src/features/milestones/milestone.tsx | 15 +++++++++--- src/features/reset.ts | 2 +- src/features/trees/tree.ts | 4 ++-- src/features/upgrades/Upgrade.vue | 4 ++-- src/features/upgrades/upgrade.ts | 7 ++++-- src/game/modifiers.tsx | 6 ++--- src/game/persistence.ts | 6 ++--- src/util/proxies.ts | 2 +- src/util/save.ts | 9 ++++++-- src/util/vue.tsx | 5 +++- 37 files changed, 147 insertions(+), 88 deletions(-) create mode 100644 src/components/math/Fraction.vue diff --git a/.eslintrc.js b/.eslintrc.js index 2a1d0bc..a881f38 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,8 @@ module.exports = { "@vue/eslint-config-prettier" ], parserOptions: { - ecmaVersion: 2020 + ecmaVersion: 2020, + project: "tsconfig.json" }, ignorePatterns: ["src/lib"], rules: { @@ -19,7 +20,14 @@ module.exports = { "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", "vue/script-setup-uses-vars": "warn", "vue/no-mutating-props": "off", - "vue/multi-word-component-names": "off" + "vue/multi-word-component-names": "off", + "@typescript-eslint/strict-boolean-expressions": [ + "error", + { + allowNullableObject: true, + allowNullableBoolean: true + } + ] }, globals: { defineProps: "readonly", diff --git a/src/App.vue b/src/App.vue index 05fa7fd..6535b0a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,7 +31,7 @@ const theme = computed(() => themes[settings.theme].variables as CSSProperties); const showTPS = toRef(settings, "showTPS"); const gameComponent = computed(() => { - return coerceComponent(jsx(() => <>{gameComponents.map(render)})); + return coerceComponent(jsx(() => (<>{gameComponents.map(render)}))); }); diff --git a/src/components/Info.vue b/src/components/Info.vue index 1da5db1..24a15e8 100644 --- a/src/components/Info.vue +++ b/src/components/Info.vue @@ -80,7 +80,7 @@ const isOpen = ref(false); const timePlayed = computed(() => formatTime(player.timePlayed)); const infoComponent = computed(() => { - return coerceComponent(jsx(() => <>{infoComponents.map(render)})); + return coerceComponent(jsx(() => (<>{infoComponents.map(render)}))); }); defineExpose({ diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 7a3ee19..9fd5f06 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -40,7 +40,7 @@ diff --git a/src/components/common/modifiers.css b/src/components/common/modifiers.css index 6842e0c..dc9e66d 100644 --- a/src/components/common/modifiers.css +++ b/src/components/common/modifiers.css @@ -8,10 +8,13 @@ } .modifier-amount { - flex-basis: 100px; flex-shrink: 0; text-align: right; } +:not(:first-of-type, :last-of-type) > .modifier-amount::after { + content: var(--unit); + opacity: 0; +} .modifier-description { flex-grow: 1; diff --git a/src/components/fields/Select.vue b/src/components/fields/Select.vue index f08c40f..72a31b2 100644 --- a/src/components/fields/Select.vue +++ b/src/components/fields/Select.vue @@ -87,6 +87,10 @@ function onUpdate(value: SelectOption) { background-color: var(--bought); } +.vue-input input { + font-size: inherit; +} + .vue-input input::placeholder { color: var(--link); } diff --git a/src/components/fields/Toggle.vue b/src/components/fields/Toggle.vue index 564a2ca..4017033 100644 --- a/src/components/fields/Toggle.vue +++ b/src/components/fields/Toggle.vue @@ -43,14 +43,16 @@ input { span { width: 100%; + padding-right: 41px; position: relative; } /* track */ input + span::before { content: ""; - float: right; - margin: 5px 0 5px 10px; + position: absolute; + top: calc(50% - 7px); + right: 0px; border-radius: 7px; width: 36px; height: 14px; @@ -64,7 +66,7 @@ input + span::before { input + span::after { content: ""; position: absolute; - top: 2px; + top: calc(50% - 10px); right: 16px; border-radius: 50%; width: 20px; diff --git a/src/data/common.tsx b/src/data/common.tsx index b190f0a..9f1436f 100644 --- a/src/data/common.tsx +++ b/src/data/common.tsx @@ -13,6 +13,7 @@ import type { Modifier } from "game/modifiers"; import type { Persistent } from "game/persistence"; import { DefaultValue, persistent } from "game/persistence"; import player from "game/player"; +import settings from "game/settings"; import type { DecimalSource } from "util/bignum"; import Decimal, { format, formatSmall, formatTime } from "util/bignum"; import type { WithRequired } from "util/common"; @@ -335,7 +336,12 @@ export function createCollapsibleModifierSections( return ( <> {hasPreviousSection ?
: null} -
+
{header}
{modifiers} diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 3063b33..ef4c77d 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -313,7 +313,12 @@ globalBus.on("loadSettings", settings => { registerSettingField( jsx(() => ( ( + + Hide maxed challenges + Hide challenges that have been fully completed. + + ))} onUpdate:modelValue={value => (settings.hideChallenges = value)} modelValue={settings.hideChallenges} /> diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index 7dfe7f1..6ea736b 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -221,7 +221,12 @@ const msDisplayOptions = Object.values(MilestoneDisplay).map(option => ({ registerSettingField( jsx(() => (