From 11b1bc9abe0c85526a0e6cc5da697ee75c7a6ebb Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 5 Mar 2022 23:09:06 -0600 Subject: [PATCH 01/23] Version Bump --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1125eaf..fae5783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.3] - 2022-03-05 +### Changed +- **BREAKING** Removed "@" path alias, and used baseUrl instead +- **BREAKING** Renamed createExponentialScaling to createPolynomialScaling and removed coefficient parameter +- Changed options passed into createLayerTreeNode; now allows overriding display +- App component is no longer cloned before being passed to `createApp` +- Changed TS version from ^4.5.4 to ~4.5.5 +### Fixed +- Document title is set as soon as possible now + ## [0.1.1] - 2022-03-02 ### Added - Configuration for Glitch projects diff --git a/package.json b/package.json index a86092d..10f5c70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "profectus", - "version": "0.1.1", + "version": "0.1.2", "private": true, "scripts": { "start": "vue-cli-service serve", From 176bc409d7352ef12c05e859627b46fd2aba46ad Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 8 Mar 2022 00:24:47 -0600 Subject: [PATCH 02/23] Added typedoc config --- tsconfig.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index e1c9ec5..5106f23 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -35,5 +35,15 @@ ], "exclude": [ "node_modules" - ] + ], + "typedocOptions": { + "entryPoints": ["src"], + "entryPointStrategy": "expand", + "cleanOutputDir": true, + "name": "Profectus", + "includeVersion": true, + "categorizeByGroup": false, + "readme": "none", + "out": "../api" + } } From a76182c0bde57041bb15a4fd82cafbd124e102d9 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 8 Mar 2022 00:25:08 -0600 Subject: [PATCH 03/23] Hide things from documentation that don't apply --- src/data/layers/prestige.tsx | 4 ++++ src/data/projEntry.tsx | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/data/layers/prestige.tsx b/src/data/layers/prestige.tsx index 3b8ca55..69ad85f 100644 --- a/src/data/layers/prestige.tsx +++ b/src/data/layers/prestige.tsx @@ -1,3 +1,7 @@ +/** + * @module + * @hidden + */ import { main } from "data/projEntry"; import { createCumulativeConversion, createPolynomialScaling } from "features/conversion"; import { jsx } from "features/feature"; diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index 3cdf7b8..c9a00b9 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -11,6 +11,9 @@ import { render } from "util/vue"; import { computed, toRaw } from "vue"; import prestige from "./layers/prestige"; +/** + * @hidden + */ export const main = createLayer(() => { const points = createResource(10); const best = trackBest(points); From a12fae5faeda61d90b9dbdc91c65e0115851968d Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 8 Mar 2022 01:13:53 -0600 Subject: [PATCH 04/23] Added stub declaration files for libs that don't provide one --- src/lib/vue-panzoom.d.ts | 1 + src/lib/vue-textarea-autosize.d.ts | 1 + 2 files changed, 2 insertions(+) create mode 100644 src/lib/vue-panzoom.d.ts create mode 100644 src/lib/vue-textarea-autosize.d.ts diff --git a/src/lib/vue-panzoom.d.ts b/src/lib/vue-panzoom.d.ts new file mode 100644 index 0000000..ec2db3e --- /dev/null +++ b/src/lib/vue-panzoom.d.ts @@ -0,0 +1 @@ +declare module 'vue-panzoom'; diff --git a/src/lib/vue-textarea-autosize.d.ts b/src/lib/vue-textarea-autosize.d.ts new file mode 100644 index 0000000..95c04d9 --- /dev/null +++ b/src/lib/vue-textarea-autosize.d.ts @@ -0,0 +1 @@ +declare module 'vue-textarea-autosize'; From 7524ed3164bffef8f7322ce000cdb98762aea8ad Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 8 Mar 2022 19:40:51 -0600 Subject: [PATCH 05/23] Export more types --- src/data/common.tsx | 2 +- src/data/themes.ts | 2 +- src/features/achievements/achievement.tsx | 2 +- src/features/bars/bar.ts | 2 +- src/features/boards/board.ts | 2 +- src/features/buyable.tsx | 4 ++-- src/features/challenges/challenge.tsx | 2 +- src/features/clickables/clickable.ts | 2 +- src/features/conversion.ts | 2 +- src/features/hotkey.ts | 2 +- src/features/infoboxes/infobox.ts | 2 +- src/features/milestones/milestone.tsx | 2 +- src/features/reset.ts | 2 +- src/features/tabs/tab.ts | 2 +- src/features/tabs/tabFamily.ts | 4 ++-- src/features/trees/tree.ts | 2 +- src/features/upgrades/upgrade.ts | 2 +- src/util/computed.ts | 4 ++-- src/util/vue.tsx | 2 +- 19 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/data/common.tsx b/src/data/common.tsx index 9ab32f5..81f0e94 100644 --- a/src/data/common.tsx +++ b/src/data/common.tsx @@ -35,7 +35,7 @@ export interface ResetButtonOptions extends ClickableOptions { canClick?: Computable; } -type ResetButton = Replace< +export type ResetButton = Replace< Clickable, { resetDescription: GetComputableTypeWithDefault>; diff --git a/src/data/themes.ts b/src/data/themes.ts index cf7e4c5..37b563f 100644 --- a/src/data/themes.ts +++ b/src/data/themes.ts @@ -1,4 +1,4 @@ -interface ThemeVars { +export interface ThemeVars { "--foreground": string; "--background": string; "--feature-foreground": string; diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index cdfb855..c79d1ad 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -39,7 +39,7 @@ export interface AchievementOptions { onComplete?: VoidFunction; } -interface BaseAchievement extends Persistent { +export interface BaseAchievement extends Persistent { id: string; earned: Ref; complete: VoidFunction; diff --git a/src/features/bars/bar.ts b/src/features/bars/bar.ts index 27a208e..36c3084 100644 --- a/src/features/bars/bar.ts +++ b/src/features/bars/bar.ts @@ -45,7 +45,7 @@ export interface BarOptions { mark?: Computable; } -interface BaseBar { +export interface BaseBar { id: string; type: typeof BarType; [Component]: typeof BarComponent; diff --git a/src/features/boards/board.ts b/src/features/boards/board.ts index 60c53ea..3afcc87 100644 --- a/src/features/boards/board.ts +++ b/src/features/boards/board.ts @@ -167,7 +167,7 @@ export interface BoardOptions { types: Record; } -interface BaseBoard extends Persistent { +export interface BaseBoard extends Persistent { id: string; links: Ref; nodes: Ref; diff --git a/src/features/buyable.tsx b/src/features/buyable.tsx index 8f05e05..1ab8a83 100644 --- a/src/features/buyable.tsx +++ b/src/features/buyable.tsx @@ -26,7 +26,7 @@ import { export const BuyableType = Symbol("Buyable"); -type BuyableDisplay = +export type BuyableDisplay = | CoercableComponent | { title?: CoercableComponent; @@ -48,7 +48,7 @@ export interface BuyableOptions { onPurchase?: (cost: DecimalSource) => void; } -interface BaseBuyable extends Persistent { +export interface BaseBuyable extends Persistent { id: string; amount: Ref; maxed: Ref; diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 50350f0..6f760ee 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -55,7 +55,7 @@ export interface ChallengeOptions { onEnter?: VoidFunction; } -interface BaseChallenge { +export interface BaseChallenge { id: string; completions: PersistentRef; completed: Ref; diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index 4106847..7747150 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -39,7 +39,7 @@ export interface ClickableOptions { onHold?: VoidFunction; } -interface BaseClickable { +export interface BaseClickable { id: string; type: typeof ClickableType; [Component]: typeof ClickableComponent; diff --git a/src/features/conversion.ts b/src/features/conversion.ts index cfa7ee5..ef0d0e7 100644 --- a/src/features/conversion.ts +++ b/src/features/conversion.ts @@ -23,7 +23,7 @@ export interface ConversionOptions { modifyGainAmount?: (gain: DecimalSource) => DecimalSource; } -interface BaseConversion { +export interface BaseConversion { convert: VoidFunction; } diff --git a/src/features/hotkey.ts b/src/features/hotkey.ts index 3206400..99b074f 100644 --- a/src/features/hotkey.ts +++ b/src/features/hotkey.ts @@ -22,7 +22,7 @@ export interface HotkeyOptions { onPress: VoidFunction; } -interface BaseHotkey { +export interface BaseHotkey { type: typeof HotkeyType; } diff --git a/src/features/infoboxes/infobox.ts b/src/features/infoboxes/infobox.ts index 6037e66..2d6b97c 100644 --- a/src/features/infoboxes/infobox.ts +++ b/src/features/infoboxes/infobox.ts @@ -33,7 +33,7 @@ export interface InfoboxOptions { display: Computable; } -interface BaseInfobox extends Persistent { +export interface BaseInfobox extends Persistent { id: string; collapsed: Ref; type: typeof InfoboxType; diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index a6c78c1..359b192 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -56,7 +56,7 @@ export interface MilestoneOptions { onComplete?: VoidFunction; } -interface BaseMilestone extends Persistent { +export interface BaseMilestone extends Persistent { id: string; earned: Ref; type: typeof MilestoneType; diff --git a/src/features/reset.ts b/src/features/reset.ts index 08b19b3..bdf86cb 100644 --- a/src/features/reset.ts +++ b/src/features/reset.ts @@ -21,7 +21,7 @@ export interface ResetOptions { onReset?: VoidFunction; } -interface BaseReset { +export interface BaseReset { id: string; reset: VoidFunction; type: typeof ResetType; diff --git a/src/features/tabs/tab.ts b/src/features/tabs/tab.ts index b46063d..a5ffe38 100644 --- a/src/features/tabs/tab.ts +++ b/src/features/tabs/tab.ts @@ -18,7 +18,7 @@ export interface TabOptions { display: Computable; } -interface BaseTab { +export interface BaseTab { id: string; type: typeof TabType; [Component]: typeof TabComponent; diff --git a/src/features/tabs/tabFamily.ts b/src/features/tabs/tabFamily.ts index 73390d7..321396c 100644 --- a/src/features/tabs/tabFamily.ts +++ b/src/features/tabs/tabFamily.ts @@ -34,7 +34,7 @@ export interface TabButtonOptions { glowColor?: Computable; } -interface BaseTabButton { +export interface BaseTabButton { type: typeof TabButtonType; [Component]: typeof TabButtonComponent; } @@ -65,7 +65,7 @@ export interface TabFamilyOptions { style?: Computable; } -interface BaseTabFamily extends Persistent { +export interface BaseTabFamily extends Persistent { id: string; activeTab: Ref; selected: Ref; diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index 748673e..1a3743b 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -137,7 +137,7 @@ export interface TreeOptions { onReset?: (node: GenericTreeNode) => void; } -interface BaseTree { +export interface BaseTree { id: string; links: Ref; reset: (node: GenericTreeNode) => void; diff --git a/src/features/upgrades/upgrade.ts b/src/features/upgrades/upgrade.ts index e406c3c..096ca2c 100644 --- a/src/features/upgrades/upgrade.ts +++ b/src/features/upgrades/upgrade.ts @@ -46,7 +46,7 @@ export interface UpgradeOptions { onPurchase?: VoidFunction; } -interface BaseUpgrade extends Persistent { +export interface BaseUpgrade extends Persistent { id: string; bought: Ref; canPurchase: Ref; diff --git a/src/util/computed.ts b/src/util/computed.ts index 3643d8f..3becd66 100644 --- a/src/util/computed.ts +++ b/src/util/computed.ts @@ -15,9 +15,9 @@ export type GetComputableType = T extends { [DoNotCache]: true } export type GetComputableTypeWithDefault = undefined extends T ? S : GetComputableType>; -type UnwrapComputableType = T extends Ref ? S : T extends () => infer S ? S : T; +export type UnwrapComputableType = T extends Ref ? S : T extends () => infer S ? S : T; -type ComputableKeysOf = Pick< +export type ComputableKeysOf = Pick< T, { [K in keyof T]: T[K] extends Computable ? K : never; diff --git a/src/util/vue.tsx b/src/util/vue.tsx index 5fdd1c1..6bd8866 100644 --- a/src/util/vue.tsx +++ b/src/util/vue.tsx @@ -154,7 +154,7 @@ export function setRefValue(ref: Ref>, value: T) { } } -type PropTypes = +export type PropTypes = | typeof Boolean | typeof String | typeof Number From d680e468b2241bddf323fa0aa6276b2c4e1b4d58 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 00:48:15 -0600 Subject: [PATCH 06/23] Minor change for documentation generation --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 5106f23..1afb257 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -44,6 +44,6 @@ "includeVersion": true, "categorizeByGroup": false, "readme": "none", - "out": "../api" + "out": "../docs/api" } } From 1fac1edb4609b2f673dfd99d80b582524ed1786f Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 08:54:05 -0600 Subject: [PATCH 07/23] Use watchEffect instead of event listener for completing achievements --- src/features/achievements/achievement.tsx | 55 ++++++--------- src/features/milestones/milestone.tsx | 82 ++++++++++------------- 2 files changed, 53 insertions(+), 84 deletions(-) diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index c79d1ad..ee1ea1d 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -2,7 +2,6 @@ import AchievementComponent from "features/achievements/Achievement.vue"; import { CoercableComponent, Component, - findFeatures, GatherProps, getUniqueID, Replace, @@ -10,7 +9,6 @@ import { StyleValue, Visibility } from "features/feature"; -import { globalBus } from "game/events"; import "game/notifications"; import { Persistent, makePersistent, PersistentState } from "game/persistence"; import { @@ -22,15 +20,16 @@ import { } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { coerceComponent } from "util/vue"; -import { Unsubscribe } from "nanoevents"; -import { Ref, unref } from "vue"; +import { Ref, unref, watchEffect } from "vue"; import { useToast } from "vue-toastification"; +const toast = useToast(); + export const AchievementType = Symbol("Achievement"); export interface AchievementOptions { visibility?: Computable; - shouldEarn?: Computable; + shouldEarn?: () => boolean; display?: Computable; mark?: Computable; image?: Computable; @@ -52,7 +51,6 @@ export type Achievement = Replace< T & BaseAchievement, { visibility: GetComputableTypeWithDefault; - shouldEarn: GetComputableType; display: GetComputableType; mark: GetComputableType; image: GetComputableType; @@ -85,7 +83,6 @@ export function createAchievement( processComputable(achievement as T, "visibility"); setDefault(achievement, "visibility", Visibility.Visible); - processComputable(achievement as T, "shouldEarn"); processComputable(achievement as T, "display"); processComputable(achievement as T, "mark"); processComputable(achievement as T, "image"); @@ -97,29 +94,18 @@ export function createAchievement( return { visibility, display, earned, image, style, classes, mark, id }; }; - return achievement as unknown as Achievement; - }); -} - -const toast = useToast(); - -const listeners: Record = {}; -globalBus.on("addLayer", layer => { - const achievements: GenericAchievement[] = ( - findFeatures(layer, AchievementType) as GenericAchievement[] - ).filter(ach => ach.shouldEarn != null); - if (achievements.length) { - listeners[layer.id] = layer.on("postUpdate", () => { - achievements.forEach(achievement => { + if (achievement.shouldEarn) { + const genericAchievement = achievement as GenericAchievement; + watchEffect(() => { if ( - unref(achievement.visibility) === Visibility.Visible && - !unref(achievement.earned) && - unref(achievement.shouldEarn) + !genericAchievement.earned.value && + unref(genericAchievement.visibility) === Visibility.Visible && + genericAchievement.shouldEarn?.() ) { - achievement[PersistentState].value = true; - achievement.onComplete?.(); - if (achievement.display) { - const Display = coerceComponent(unref(achievement.display)); + genericAchievement.earned.value = true; + genericAchievement.onComplete?.(); + if (genericAchievement.display) { + const Display = coerceComponent(unref(genericAchievement.display)); toast.info(

Achievement earned!

@@ -133,11 +119,8 @@ globalBus.on("addLayer", layer => { } } }); - }); - } -}); -globalBus.on("removeLayer", layer => { - // unsubscribe from postUpdate - listeners[layer.id]?.(); - listeners[layer.id] = undefined; -}); + } + + return achievement as unknown as Achievement; + }); +} diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index 359b192..c22693c 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -2,7 +2,6 @@ import Select from "components/fields/Select.vue"; import { CoercableComponent, Component, - findFeatures, GatherProps, getUniqueID, jsx, @@ -26,10 +25,11 @@ import { } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { coerceComponent, isCoercableComponent } from "util/vue"; -import { Unsubscribe } from "nanoevents"; -import { computed, Ref, unref } from "vue"; +import { computed, Ref, unref, watchEffect } from "vue"; import { useToast } from "vue-toastification"; +const toast = useToast(); + export const MilestoneType = Symbol("Milestone"); export enum MilestoneDisplay { @@ -42,7 +42,7 @@ export enum MilestoneDisplay { export interface MilestoneOptions { visibility?: Computable; - shouldEarn: Computable; + shouldEarn?: () => boolean; style?: Computable; classes?: Computable>; display?: Computable< @@ -68,7 +68,6 @@ export type Milestone = Replace< T & BaseMilestone, { visibility: GetComputableTypeWithDefault; - shouldEarn: GetComputableType; style: GetComputableType; classes: GetComputableType; display: GetComputableType; @@ -124,7 +123,6 @@ export function createMilestone( } }); - processComputable(milestone as T, "shouldEarn"); processComputable(milestone as T, "style"); processComputable(milestone as T, "classes"); processComputable(milestone as T, "display"); @@ -134,52 +132,40 @@ export function createMilestone( return { visibility, display, style, classes, earned, id }; }; + if (milestone.shouldEarn) { + const genericMilestone = milestone as GenericMilestone; + watchEffect(() => { + if ( + !genericMilestone.earned.value && + unref(genericMilestone.visibility) === Visibility.Visible && + genericMilestone.shouldEarn?.() + ) { + genericMilestone.earned.value = true; + genericMilestone.onComplete?.(); + if (genericMilestone.display) { + const display = unref(genericMilestone.display); + const Display = coerceComponent( + isCoercableComponent(display) ? display : display.requirement + ); + toast( + <> +

Milestone earned!

+
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} + {/* @ts-ignore */} + +
+ + ); + } + } + }); + } + return milestone as unknown as Milestone; }); } -const toast = useToast(); - -const listeners: Record = {}; -globalBus.on("addLayer", layer => { - const milestones: GenericMilestone[] = ( - findFeatures(layer, MilestoneType) as GenericMilestone[] - ).filter(milestone => milestone.shouldEarn != null); - listeners[layer.id] = layer.on("postUpdate", () => { - milestones.forEach(milestone => { - if ( - unref(milestone.visibility) === Visibility.Visible && - !milestone.earned.value && - unref(milestone.shouldEarn) - ) { - milestone[PersistentState].value = true; - milestone.onComplete?.(); - if (milestone.display) { - const display = unref(milestone.display); - const Display = coerceComponent( - isCoercableComponent(display) ? display : display.requirement - ); - toast( - <> -

Milestone earned!

-
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} - {/* @ts-ignore */} - -
- - ); - } - } - }); - }); -}); -globalBus.on("removeLayer", layer => { - // unsubscribe from postUpdate - listeners[layer.id]?.(); - listeners[layer.id] = undefined; -}); - declare module "game/settings" { interface Settings { msDisplay: MilestoneDisplay; From d8edac1c9af2944804ea395cad9c6c8664dcf7f9 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 08:54:36 -0600 Subject: [PATCH 08/23] Add manual complete function for milestones --- src/features/milestones/milestone.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/features/milestones/milestone.tsx b/src/features/milestones/milestone.tsx index c22693c..9056ab2 100644 --- a/src/features/milestones/milestone.tsx +++ b/src/features/milestones/milestone.tsx @@ -59,6 +59,7 @@ export interface MilestoneOptions { export interface BaseMilestone extends Persistent { id: string; earned: Ref; + complete: VoidFunction; type: typeof MilestoneType; [Component]: typeof MilestoneComponent; [GatherProps]: () => Record; @@ -92,6 +93,10 @@ export function createMilestone( milestone[Component] = MilestoneComponent; milestone.earned = milestone[PersistentState]; + milestone.complete = function () { + milestone[PersistentState].value = true; + }; + processComputable(milestone as T, "visibility"); setDefault(milestone, "visibility", Visibility.Visible); const visibility = milestone.visibility as ProcessedComputable; From e5da55d26a3a801601a4c8fc80bd86129ea4c9fa Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 09:16:19 -0600 Subject: [PATCH 09/23] Made buyables default to infinite purchase limit --- src/features/buyable.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/features/buyable.tsx b/src/features/buyable.tsx index 1ab8a83..cf49443 100644 --- a/src/features/buyable.tsx +++ b/src/features/buyable.tsx @@ -68,7 +68,7 @@ export type Buyable = Replace< cost: GetComputableType; resource: GetComputableType; canPurchase: GetComputableTypeWithDefault>; - purchaseLimit: GetComputableTypeWithDefault; + purchaseLimit: GetComputableTypeWithDefault; classes: GetComputableType; style: GetComputableType; mark: GetComputableType; @@ -172,6 +172,16 @@ export function createBuyable( const Title = coerceComponent(currDisplay.title || "", "h3"); const Description = coerceComponent(currDisplay.description); const EffectDisplay = coerceComponent(currDisplay.effectDisplay || ""); + const amountDisplay = + unref(genericBuyable.purchaseLimit) === Decimal.dInf ? ( + <>Amount: {formatWhole(genericBuyable.amount.value)} + ) : ( + <> + Amount: {formatWhole(genericBuyable.amount.value)} /{" "} + {formatWhole(unref(genericBuyable.purchaseLimit))} + + ); + return ( {currDisplay.title ? ( @@ -182,8 +192,7 @@ export function createBuyable(

- Amount: {formatWhole(genericBuyable.amount.value)} /{" "} - {formatWhole(unref(genericBuyable.purchaseLimit))} + {amountDisplay}
{currDisplay.effectDisplay ? (
@@ -209,7 +218,7 @@ export function createBuyable( processComputable(buyable as T, "cost"); processComputable(buyable as T, "resource"); processComputable(buyable as T, "purchaseLimit"); - setDefault(buyable, "purchaseLimit", 1); + setDefault(buyable, "purchaseLimit", Decimal.dInf); processComputable(buyable as T, "style"); processComputable(buyable as T, "mark"); processComputable(buyable as T, "small"); From bb2c61e425cefcc81c233ab4058676e2321a2950 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 09:22:16 -0600 Subject: [PATCH 10/23] Removed setupAutoReset --- src/features/reset.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/features/reset.ts b/src/features/reset.ts index bdf86cb..9576e4e 100644 --- a/src/features/reset.ts +++ b/src/features/reset.ts @@ -12,7 +12,7 @@ import Decimal from "lib/break_eternity"; import { Computable, GetComputableType, processComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { Unsubscribe } from "nanoevents"; -import { computed, isRef, unref } from "vue"; +import { isRef, unref } from "vue"; export const ResetType = Symbol("Reset"); @@ -69,19 +69,6 @@ export function createReset( }); } -export function setupAutoReset( - layer: GenericLayer, - reset: GenericReset, - autoActive: Computable = true -): Unsubscribe { - const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive; - return layer.on("update", () => { - if (unref(isActive)) { - reset.reset(); - } - }); -} - const listeners: Record = {}; export function trackResetTime(layer: GenericLayer, reset: GenericReset): PersistentRef { const resetTime = persistent(new Decimal(0)); From 1f48622314beb0e0d8011c948520db44e5b8ae18 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 09:59:45 -0600 Subject: [PATCH 11/23] Cache decimals used for trackOOMPS --- src/features/resources/resource.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/features/resources/resource.ts b/src/features/resources/resource.ts index 61e0dff..8f44c31 100644 --- a/src/features/resources/resource.ts +++ b/src/features/resources/resource.ts @@ -42,6 +42,8 @@ export function trackTotal(resource: Resource): Ref { return total; } +const tetra8 = new Decimal("10^^8"); +const e100 = new Decimal("1e100"); export function trackOOMPS( resource: Resource, pointGain?: ComputedRef @@ -52,7 +54,7 @@ export function trackOOMPS( globalBus.on("update", diff => { oompsMag.value = 0; - if (Decimal.lte(resource.value, 1e100)) { + if (Decimal.lte(resource.value, e100)) { lastPoints.value = resource.value; return; } @@ -61,7 +63,7 @@ export function trackOOMPS( let prev = lastPoints.value; lastPoints.value = curr; if (Decimal.gt(curr, prev)) { - if (Decimal.gte(curr, "10^^8")) { + if (Decimal.gte(curr, tetra8)) { curr = Decimal.slog(curr, 1e10); prev = Decimal.slog(prev, 1e10); oomps.value = curr.sub(prev).div(diff); From 9c45653b8bd6f995d7089333bf6b37ebd9678894 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 10:02:28 -0600 Subject: [PATCH 12/23] Add setupAutoClick --- src/features/clickables/clickable.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index 7747150..dfd4b08 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -9,6 +9,8 @@ import { StyleValue, Visibility } from "features/feature"; +import { GenericLayer } from "game/layers"; +import { Unsubscribe } from "nanoevents"; import { Computable, GetComputableType, @@ -17,7 +19,7 @@ import { ProcessedComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; -import { unref } from "vue"; +import { computed, unref } from "vue"; export const ClickableType = Symbol("Clickable"); @@ -131,3 +133,16 @@ export function createClickable( return clickable as unknown as Clickable; }); } + +export function setupAutoClick( + layer: GenericLayer, + clickable: GenericClickable, + autoActive: Computable = true +): Unsubscribe { + const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive; + return layer.on("update", () => { + if (unref(isActive) && unref(clickable.canClick)) { + clickable.onClick?.(); + } + }); +} From 14b1420b5563b0d9dd84754f9a0661dad5fa94ad Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 12:48:44 -0600 Subject: [PATCH 13/23] Add complete function to challenge --- src/features/challenges/challenge.tsx | 35 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 6f760ee..16e97d1 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -25,7 +25,7 @@ import { ProcessedComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; -import { computed, Ref, unref } from "vue"; +import { computed, Ref, unref, watch, WatchStopHandle } from "vue"; export const ChallengeType = Symbol("ChallengeType"); @@ -62,6 +62,7 @@ export interface BaseChallenge { maxed: Ref; active: PersistentRef; toggle: VoidFunction; + complete: (remainInChallenge?: boolean) => void; type: typeof ChallengeType; [Component]: typeof ChallengeComponent; [GatherProps]: () => Record; @@ -87,7 +88,7 @@ export type GenericChallenge = Replace< { visibility: ProcessedComputable; canStart: ProcessedComputable; - canComplete: ProcessedComputable; + canComplete: ProcessedComputable; completionLimit: ProcessedComputable; mark: ProcessedComputable; } @@ -134,11 +135,7 @@ export function createChallenge( challenge.toggle = function () { const genericChallenge = challenge as GenericChallenge; if (genericChallenge.active.value) { - if ( - genericChallenge.canComplete && - unref(genericChallenge.canComplete) && - !genericChallenge.maxed.value - ) { + if (unref(genericChallenge.canComplete) && !genericChallenge.maxed.value) { let completions: boolean | DecimalSource = unref(genericChallenge.canComplete); if (typeof completions === "boolean") { completions = 1; @@ -158,6 +155,30 @@ export function createChallenge( genericChallenge.onEnter?.(); } }; + challenge.complete = function (remainInChallenge?: boolean) { + const genericChallenge = challenge as GenericChallenge; + let completions: boolean | DecimalSource = unref(genericChallenge.canComplete); + if ( + genericChallenge.active.value && + completions !== false && + (completions === true || Decimal.neq(0, completions)) && + !genericChallenge.maxed.value + ) { + if (typeof completions === "boolean") { + completions = 1; + } + genericChallenge.completions.value = Decimal.min( + Decimal.add(genericChallenge.completions.value, completions), + unref(genericChallenge.completionLimit) + ); + genericChallenge.onComplete?.(); + if (remainInChallenge !== true) { + genericChallenge.active.value = false; + genericChallenge.onExit?.(); + genericChallenge.reset?.reset(); + } + } + }; processComputable(challenge as T, "visibility"); setDefault(challenge, "visibility", Visibility.Visible); const visibility = challenge.visibility as ProcessedComputable; From b33de01a96616622d7e3f246b25297ccbe7b0c32 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 12:48:53 -0600 Subject: [PATCH 14/23] Added setupAutoComplete --- src/features/challenges/challenge.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 16e97d1..56c31ea 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -272,6 +272,19 @@ export function createChallenge( }); } +export function setupAutoComplete( + challenge: GenericChallenge, + autoActive: Computable = true, + exitOnComplete = true +): WatchStopHandle { + const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive; + return watch([challenge.canComplete, isActive], ([canComplete, isActive]) => { + if (canComplete && isActive) { + challenge.complete(!exitOnComplete); + } + }); +} + declare module "game/settings" { interface Settings { hideChallenges: boolean; From e56f34c13ce3fe44f0679a03c8027445e7f64742 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 14:02:41 -0600 Subject: [PATCH 15/23] Converted variables that track time to numbers --- src/data/layers/prestige.tsx | 2 +- src/data/projEntry.tsx | 3 +-- src/features/bars/bar.ts | 2 +- src/features/boards/board.ts | 5 ++--- src/features/conversion.ts | 2 +- src/features/reset.ts | 4 ++-- src/features/trees/tree.ts | 3 +-- src/features/upgrades/Upgrade.vue | 2 +- src/game/events.ts | 34 +++++++++++++++++++------------ src/game/layers.tsx | 7 +++---- src/game/player.ts | 10 ++++----- src/main.ts | 2 +- src/util/save.ts | 12 ++++------- 13 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/data/layers/prestige.tsx b/src/data/layers/prestige.tsx index 69ad85f..0dfdaff 100644 --- a/src/data/layers/prestige.tsx +++ b/src/data/layers/prestige.tsx @@ -9,7 +9,7 @@ import { createReset } from "features/reset"; import MainDisplay from "features/resources/MainDisplay.vue"; import { createResource } from "features/resources/resource"; import { createLayer } from "game/layers"; -import { DecimalSource } from "lib/break_eternity"; +import { DecimalSource } from "util/bignum"; import { render } from "util/vue"; import { createLayerTreeNode, createResetButton } from "../common"; diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index c9a00b9..c004a87 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -5,8 +5,7 @@ import { branchedResetPropagation, createTree, GenericTree } from "features/tree import { globalBus } from "game/events"; import { createLayer, GenericLayer } from "game/layers"; import player, { PlayerData } from "game/player"; -import { DecimalSource } from "lib/break_eternity"; -import Decimal, { format, formatTime } from "util/bignum"; +import Decimal, { DecimalSource, format, formatTime } from "util/bignum"; import { render } from "util/vue"; import { computed, toRaw } from "vue"; import prestige from "./layers/prestige"; diff --git a/src/features/bars/bar.ts b/src/features/bars/bar.ts index 36c3084..6bdb3e6 100644 --- a/src/features/bars/bar.ts +++ b/src/features/bars/bar.ts @@ -9,7 +9,7 @@ import { StyleValue, Visibility } from "features/feature"; -import { DecimalSource } from "lib/break_eternity"; +import { DecimalSource } from "util/bignum"; import { Computable, GetComputableType, diff --git a/src/features/boards/board.ts b/src/features/boards/board.ts index 3afcc87..8435b45 100644 --- a/src/features/boards/board.ts +++ b/src/features/boards/board.ts @@ -11,7 +11,6 @@ import { } from "features/feature"; import { globalBus } from "game/events"; import { State, Persistent, makePersistent, PersistentState } from "game/persistence"; -import Decimal, { DecimalSource } from "lib/break_eternity"; import { isFunction } from "util/common"; import { Computable, @@ -85,7 +84,7 @@ export interface NodeTypeOptions { actionDistance?: NodeComputable; onClick?: (node: BoardNode) => void; onDrop?: (node: BoardNode, otherNode: BoardNode) => void; - update?: (node: BoardNode, diff: DecimalSource) => void; + update?: (node: BoardNode, diff: number) => void; } export interface BaseNodeType { @@ -348,7 +347,7 @@ export function getUniqueNodeID(board: GenericBoard): number { const listeners: Record = {}; globalBus.on("addLayer", layer => { const boards: GenericBoard[] = findFeatures(layer, BoardType) as GenericBoard[]; - listeners[layer.id] = layer.on("postUpdate", (diff: Decimal) => { + listeners[layer.id] = layer.on("postUpdate", diff => { boards.forEach(board => { Object.values(board.types).forEach(type => type.nodes.value.forEach(node => type.update?.(node, diff)) diff --git a/src/features/conversion.ts b/src/features/conversion.ts index ef0d0e7..ebe8914 100644 --- a/src/features/conversion.ts +++ b/src/features/conversion.ts @@ -206,7 +206,7 @@ export function setupPassiveGeneration( conversion: GenericConversion, rate: ProcessedComputable = 1 ): void { - layer.on("preUpdate", (diff: Decimal) => { + layer.on("preUpdate", diff => { const currRate = isRef(rate) ? rate.value : rate; if (Decimal.neq(currRate, 0)) { conversion.gainResource.value = Decimal.add( diff --git a/src/features/reset.ts b/src/features/reset.ts index 9576e4e..082c7ca 100644 --- a/src/features/reset.ts +++ b/src/features/reset.ts @@ -8,7 +8,7 @@ import { PersistentRef, PersistentState } from "game/persistence"; -import Decimal from "lib/break_eternity"; +import Decimal from "util/bignum"; import { Computable, GetComputableType, processComputable } from "util/computed"; import { createLazyProxy } from "util/proxies"; import { Unsubscribe } from "nanoevents"; @@ -72,7 +72,7 @@ export function createReset( const listeners: Record = {}; export function trackResetTime(layer: GenericLayer, reset: GenericReset): PersistentRef { const resetTime = persistent(new Decimal(0)); - listeners[layer.id] = layer.on("preUpdate", (diff: Decimal) => { + listeners[layer.id] = layer.on("preUpdate", diff => { resetTime.value = Decimal.add(resetTime.value, diff); }); globalBus.on("reset", currentReset => { diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index 1a3743b..cc3f69d 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -14,8 +14,7 @@ import { displayResource, Resource } from "features/resources/resource"; import { Tooltip } from "features/tooltip"; import TreeComponent from "features/trees/Tree.vue"; import { persistent } from "game/persistence"; -import { DecimalSource, format } from "util/bignum"; -import Decimal, { formatWhole } from "util/break_eternity"; +import Decimal, { DecimalSource, format, formatWhole } from "util/bignum"; import { Computable, convertComputable, diff --git a/src/features/upgrades/Upgrade.vue b/src/features/upgrades/Upgrade.vue index acfdd38..f7dde0f 100644 --- a/src/features/upgrades/Upgrade.vue +++ b/src/features/upgrades/Upgrade.vue @@ -31,7 +31,7 @@ import MarkNode from "components/MarkNode.vue"; import { jsx, StyleValue, Visibility } from "features/feature"; import { displayResource, Resource } from "features/resources/resource"; import { GenericUpgrade } from "features/upgrades/upgrade"; -import { DecimalSource } from "lib/break_eternity"; +import { DecimalSource } from "util/bignum"; import { coerceComponent, isCoercableComponent, processedPropType, unwrapRef } from "util/vue"; import { Component, diff --git a/src/game/events.ts b/src/game/events.ts index 1b3fa1b..2a3c40e 100644 --- a/src/game/events.ts +++ b/src/game/events.ts @@ -1,5 +1,5 @@ import projInfo from "data/projInfo.json"; -import Decimal, { DecimalSource } from "util/bignum"; +import Decimal from "util/bignum"; import { createNanoEvents } from "nanoevents"; import { App, Ref } from "vue"; import { GenericLayer } from "./layers"; @@ -10,7 +10,7 @@ import state from "./state"; export interface GlobalEvents { addLayer: (layer: GenericLayer, saveData: Record) => void; removeLayer: (layer: GenericLayer) => void; - update: (diff: Decimal, trueDiff: number) => void; + update: (diff: number, trueDiff: number) => void; loadSettings: (settings: Partial) => void; setupVue: (vue: App) => void; } @@ -25,7 +25,7 @@ let hasWon: null | Ref = null; function update() { const now = Date.now(); - let diff: DecimalSource = (now - player.time) / 1e3; + let diff = (now - player.time) / 1e3; player.time = now; const trueDiff = diff; @@ -43,7 +43,7 @@ function update() { return; } - diff = new Decimal(diff).max(0); + diff = Math.max(diff, 0); if (player.devSpeed === 0) { return; @@ -52,14 +52,14 @@ function update() { // Add offline time if any if (player.offlineTime != undefined) { if (Decimal.gt(player.offlineTime, projInfo.offlineLimit * 3600)) { - player.offlineTime = new Decimal(projInfo.offlineLimit * 3600); + player.offlineTime = projInfo.offlineLimit * 3600; } if (Decimal.gt(player.offlineTime, 0) && player.devSpeed !== 0) { - const offlineDiff = Decimal.div(player.offlineTime, 10).max(diff); - player.offlineTime = Decimal.sub(player.offlineTime, offlineDiff); - diff = diff.add(offlineDiff); + const offlineDiff = Math.max(player.offlineTime / 10, diff); + player.offlineTime = player.offlineTime - offlineDiff; + diff += offlineDiff; } else if (player.devSpeed === 0) { - player.offlineTime = Decimal.add(player.offlineTime, diff); + player.offlineTime += diff; } if (!player.offlineProd || Decimal.lt(player.offlineTime, 0)) { player.offlineTime = null; @@ -67,18 +67,26 @@ function update() { } // Cap at max tick length - diff = Decimal.min(diff, projInfo.maxTickLength); + diff = Math.min(diff, projInfo.maxTickLength); // Apply dev speed if (player.devSpeed != undefined) { - diff = diff.times(player.devSpeed); + diff *= player.devSpeed; + } + + if (!Number.isFinite(diff)) { + diff = 1e308; } // Update - if (diff.eq(0)) { + if (Decimal.eq(diff, 0)) { return; } - player.timePlayed = Decimal.add(player.timePlayed, diff); + + player.timePlayed += diff; + if (!Number.isFinite(player.timePlayed)) { + player.timePlayed = 1e308; + } globalBus.emit("update", diff, trueDiff); if (settings.unthrottled) { diff --git a/src/game/layers.tsx b/src/game/layers.tsx index 57a4ba8..0698c0a 100644 --- a/src/game/layers.tsx +++ b/src/game/layers.tsx @@ -8,7 +8,6 @@ import { StyleValue } from "features/feature"; import { Link } from "features/links"; -import Decimal from "util/bignum"; import { Computable, GetComputableType, @@ -25,11 +24,11 @@ import player from "./player"; export interface LayerEvents { // Generation - preUpdate: (diff: Decimal) => void; + preUpdate: (diff: number) => void; // Actions (e.g. automation) - update: (diff: Decimal) => void; + update: (diff: number) => void; // Effects (e.g. milestones) - postUpdate: (diff: Decimal) => void; + postUpdate: (diff: number) => void; } export const layers: Record | undefined> = {}; diff --git a/src/game/player.ts b/src/game/player.ts index 13e67e2..7431c84 100644 --- a/src/game/player.ts +++ b/src/game/player.ts @@ -1,4 +1,4 @@ -import Decimal, { DecimalSource } from "util/bignum"; +import Decimal from "util/bignum"; import { isPlainObject } from "util/common"; import { ProxiedWithState, ProxyPath, ProxyState } from "util/proxies"; import { reactive, unref } from "vue"; @@ -6,14 +6,14 @@ import transientState from "./state"; export interface PlayerData { id: string; - devSpeed: DecimalSource | null; + devSpeed: number | null; name: string; tabs: Array; time: number; autosave: boolean; offlineProd: boolean; - offlineTime: DecimalSource | null; - timePlayed: DecimalSource; + offlineTime: number | null; + timePlayed: number; keepGoing: boolean; modID: string; modVersion: string; @@ -31,7 +31,7 @@ const state = reactive({ autosave: true, offlineProd: true, offlineTime: null, - timePlayed: new Decimal(0), + timePlayed: 0, keepGoing: false, modID: "", modVersion: "", diff --git a/src/main.ts b/src/main.ts index 5e8c305..5850628 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,7 +5,7 @@ import { GenericLayer } from "./game/layers"; import { PlayerData } from "./game/player"; import { Settings } from "./game/settings"; import { Transient } from "./game/state"; -import Decimal, { DecimalSource } from "./lib/break_eternity"; +import Decimal, { DecimalSource } from "./util/bignum"; import { load } from "./util/save"; document.title = projInfo.title; diff --git a/src/util/save.ts b/src/util/save.ts index 0e7c33d..ea1305c 100644 --- a/src/util/save.ts +++ b/src/util/save.ts @@ -1,7 +1,6 @@ import projInfo from "data/projInfo.json"; import player, { Player, PlayerData, stringifySave } from "game/player"; import settings, { loadSettings } from "game/settings"; -import Decimal from "./bignum"; import { ProxyState } from "./proxies"; export function setupInitialStore(player: Partial = {}): Player { @@ -13,8 +12,8 @@ export function setupInitialStore(player: Partial = {}): Player { time: Date.now(), autosave: true, offlineProd: true, - offlineTime: new Decimal(0), - timePlayed: new Decimal(0), + offlineTime: 0, + timePlayed: 0, keepGoing: false, modID: projInfo.id, modVersion: projInfo.versionNumber, @@ -85,11 +84,8 @@ export async function loadSave(playerObj: Partial): Promise { playerObj = setupInitialStore(playerObj); if (playerObj.offlineProd && playerObj.time) { - if (playerObj.offlineTime == undefined) playerObj.offlineTime = new Decimal(0); - playerObj.offlineTime = Decimal.add( - playerObj.offlineTime, - (Date.now() - playerObj.time) / 1000 - ); + if (playerObj.offlineTime == undefined) playerObj.offlineTime = 0; + playerObj.offlineTime += (Date.now() - playerObj.time) / 1000; } playerObj.time = Date.now(); if (playerObj.modVersion !== projInfo.versionNumber) { From ada566b53aa1265c59a2f45556c0e10405c90fcb Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 15:41:13 -0600 Subject: [PATCH 16/23] Added isAnyChallengeActive --- src/features/challenges/challenge.tsx | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index 56c31ea..0f47abf 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -1,3 +1,4 @@ +import { isArray } from "@vue/shared"; import Toggle from "components/fields/Toggle.vue"; import ChallengeComponent from "features/challenges/Challenge.vue"; import { @@ -94,12 +95,6 @@ export type GenericChallenge = Replace< } >; -export function createActiveChallenge( - challenges: GenericChallenge[] -): Ref { - return computed(() => challenges.find(challenge => challenge.active.value)); -} - export function createChallenge( optionsFunc: () => T & ThisType> ): Challenge { @@ -149,7 +144,11 @@ export function createChallenge( genericChallenge.active.value = false; genericChallenge.onExit?.(); genericChallenge.reset?.reset(); - } else if (unref(genericChallenge.canStart)) { + } else if ( + unref(genericChallenge.canStart) && + unref(genericChallenge.visibility) === Visibility.Visible && + !genericChallenge.maxed.value + ) { genericChallenge.reset?.reset(); genericChallenge.active.value = true; genericChallenge.onEnter?.(); @@ -188,16 +187,6 @@ export function createChallenge( } return unref(visibility); }); - if (challenge.canStart == null) { - challenge.canStart = computed( - () => - unref((challenge as GenericChallenge).visibility) === Visibility.Visible && - Decimal.lt( - (challenge as GenericChallenge).completions.value, - unref((challenge as GenericChallenge).completionLimit) - ) - ); - } if (challenge.canComplete == null) { challenge.canComplete = computed(() => { const genericChallenge = challenge as GenericChallenge; @@ -285,6 +274,21 @@ export function setupAutoComplete( }); } +export function createActiveChallenge( + challenges: GenericChallenge[] +): Ref { + return computed(() => challenges.find(challenge => challenge.active.value)); +} + +export function isAnyChallengeActive( + challenges: GenericChallenge[] | Ref +): Ref { + if (isArray(challenges)) { + challenges = createActiveChallenge(challenges); + } + return computed(() => (challenges as Ref).value != null); +} + declare module "game/settings" { interface Settings { hideChallenges: boolean; From 1cf72b433751e6179a670fb4698a275dbd6d2864 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 16:38:49 -0600 Subject: [PATCH 17/23] Added hotkeys to info modal --- src/components/Info.vue | 10 +++++++++- src/features/{hotkey.ts => hotkey.tsx} | 27 +++++++++++++++++++++++--- src/game/settings.ts | 11 +++++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) rename src/features/{hotkey.ts => hotkey.tsx} (76%) diff --git a/src/components/Info.vue b/src/components/Info.vue index 5573421..21ac2f9 100644 --- a/src/components/Info.vue +++ b/src/components/Info.vue @@ -44,17 +44,21 @@

Time Played: {{ timePlayed }}
+
-