From 98f18fef43df6d77231b0eba0a1c65e9dec01731 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Wed, 19 Apr 2023 20:39:25 -0500 Subject: [PATCH] Ran prettier --- src/features/achievements/achievement.tsx | 10 +++- src/features/action.tsx | 9 +++- src/features/bars/bar.ts | 10 +++- src/features/challenges/challenge.tsx | 10 +++- src/features/clickables/clickable.ts | 10 +++- src/features/decorators/bonusDecorator.ts | 63 +++++++++++++++-------- src/features/decorators/common.ts | 40 +++++++++----- src/features/feature.ts | 2 +- src/features/repeatable.tsx | 18 ++++--- src/features/trees/tree.ts | 10 +++- src/features/upgrades/upgrade.ts | 12 +++-- 11 files changed, 139 insertions(+), 55 deletions(-) diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index eb7ad60..f55d6ea 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -142,7 +142,10 @@ export function createAchievement( ...decorators: GenericDecorator[] ): Achievement { const earned = persistent(false, false); - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const achievement = optionsFunc?.call(feature, feature) ?? @@ -232,7 +235,10 @@ export function createAchievement( decorator.postConstruct?.(achievement); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(achievement)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(achievement)), + {} + ); achievement[GatherProps] = function (this: GenericAchievement) { const { visibility, diff --git a/src/features/action.tsx b/src/features/action.tsx index 1dc9498..a58a762 100644 --- a/src/features/action.tsx +++ b/src/features/action.tsx @@ -107,7 +107,10 @@ export function createAction( ...decorators: GenericDecorator[] ): Action { const progress = persistent(0); - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const action = optionsFunc?.call(feature, feature) ?? @@ -241,7 +244,9 @@ export function createAction( decorator.postConstruct?.(action); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(action))); + const decoratedProps = decorators.reduce((current, next) => + Object.assign(current, next.getGatheredProps?.(action)) + ); action[GatherProps] = function (this: GenericAction) { const { display, diff --git a/src/features/bars/bar.ts b/src/features/bars/bar.ts index e2be951..100a3c3 100644 --- a/src/features/bars/bar.ts +++ b/src/features/bars/bar.ts @@ -105,7 +105,10 @@ export function createBar( optionsFunc: OptionsFunc, ...decorators: GenericDecorator[] ): Bar { - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const bar = optionsFunc.call(feature, feature); bar.id = getUniqueID("bar-"); @@ -137,7 +140,10 @@ export function createBar( decorator.postConstruct?.(bar); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(bar)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(bar)), + {} + ); bar[GatherProps] = function (this: GenericBar) { const { progress, diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index ad6ca6a..16ed080 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -154,7 +154,10 @@ export function createChallenge( ): Challenge { const completions = persistent(0); const active = persistent(false, false); - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const challenge = optionsFunc.call(feature, feature); @@ -271,7 +274,10 @@ export function createChallenge( decorator.postConstruct?.(challenge); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(challenge)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(challenge)), + {} + ); challenge[GatherProps] = function (this: GenericChallenge) { const { active, diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index 4e3dfcf..170e7b7 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -99,7 +99,10 @@ export function createClickable( optionsFunc?: OptionsFunc, ...decorators: GenericDecorator[] ): Clickable { - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const clickable = optionsFunc?.call(feature, feature) ?? @@ -144,7 +147,10 @@ export function createClickable( decorator.postConstruct?.(clickable); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(clickable)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(clickable)), + {} + ); clickable[GatherProps] = function (this: GenericClickable) { const { display, diff --git a/src/features/decorators/bonusDecorator.ts b/src/features/decorators/bonusDecorator.ts index b1c38cf..ac02c07 100644 --- a/src/features/decorators/bonusDecorator.ts +++ b/src/features/decorators/bonusDecorator.ts @@ -1,6 +1,11 @@ import { Replace } from "features/feature"; import Decimal, { DecimalSource } from "util/bignum"; -import { Computable, GetComputableType, ProcessedComputable, processComputable } from "util/computed"; +import { + Computable, + GetComputableType, + ProcessedComputable, + processComputable +} from "util/computed"; import { Ref, computed, unref } from "vue"; import { Decorator } from "./common"; @@ -25,10 +30,12 @@ export interface BaseBonusCompletionsFeature { } export type BonusAmountFeature = Replace< - T, { bonusAmount: GetComputableType; } + T, + { bonusAmount: GetComputableType } >; export type BonusCompletionsFeature = Replace< - T, { bonusAmount: GetComputableType; } + T, + { bonusAmount: GetComputableType } >; export type GenericBonusAmountFeature = Replace< @@ -47,9 +54,9 @@ export type GenericBonusCompletionsFeature = Replace< >; /** - * Allows the addition of "bonus levels" to the decorated feature, with an accompanying "total amount". - * To function properly, the `createFeature()` function must have its generic type extended by {@linkcode BonusAmountFeatureOptions}. - * Additionally, the base feature must have an `amount` property. + * Allows the addition of "bonus levels" to the decorated feature, with an accompanying "total amount". + * To function properly, the `createFeature()` function must have its generic type extended by {@linkcode BonusAmountFeatureOptions}. + * Additionally, the base feature must have an `amount` property. * To allow access to the decorated values outside the `createFeature()` function, the output type must be extended by {@linkcode GenericBonusAmountFeature}. * @example ```ts * createRepeatable(() => ({ @@ -57,26 +64,34 @@ export type GenericBonusCompletionsFeature = Replace< * ... * }), bonusAmountDecorator) as GenericRepeatable & GenericBonusAmountFeature */ -export const bonusAmountDecorator: Decorator = { +export const bonusAmountDecorator: Decorator< + BonusAmountFeatureOptions, + BaseBonusAmountFeature, + GenericBonusAmountFeature +> = { preConstruct(feature) { if (feature.amount === undefined) { - console.error(`Decorated feature ${feature.id} does not contain the required 'amount' property"`); + console.error( + `Decorated feature ${feature.id} does not contain the required 'amount' property"` + ); } }, postConstruct(feature) { processComputable(feature, "bonusAmount"); if (feature.totalAmount === undefined) { - feature.totalAmount = computed(() => Decimal.add( - unref(feature.amount ?? 0), - unref(feature.bonusAmount as ProcessedComputable) - )); + feature.totalAmount = computed(() => + Decimal.add( + unref(feature.amount ?? 0), + unref(feature.bonusAmount as ProcessedComputable) + ) + ); } } -} +}; /** - * Allows the addition of "bonus levels" to the decorated feature, with an accompanying "total amount". - * To function properly, the `createFeature()` function must have its generic type extended by {@linkcode BonusCompletionFeatureOptions}. + * Allows the addition of "bonus levels" to the decorated feature, with an accompanying "total amount". + * To function properly, the `createFeature()` function must have its generic type extended by {@linkcode BonusCompletionFeatureOptions}. * To allow access to the decorated values outside the `createFeature()` function, the output type must be extended by {@linkcode GenericBonusCompletionFeature}. * @example ```ts * createChallenge(() => ({ @@ -84,14 +99,20 @@ export const bonusAmountDecorator: Decorator = { +export const bonusCompletionsDecorator: Decorator< + BonusCompletionsFeatureOptions, + BaseBonusCompletionsFeature, + GenericBonusCompletionsFeature +> = { postConstruct(feature) { processComputable(feature, "bonusCompletions"); if (feature.totalCompletions === undefined) { - feature.totalCompletions = computed(() => Decimal.add( - unref(feature.completions ?? 0), - unref(feature.bonusCompletions as ProcessedComputable) - )); + feature.totalCompletions = computed(() => + Decimal.add( + unref(feature.completions ?? 0), + unref(feature.bonusCompletions as ProcessedComputable) + ) + ); } } -} +}; diff --git a/src/features/decorators/common.ts b/src/features/decorators/common.ts index fb084db..899f29e 100644 --- a/src/features/decorators/common.ts +++ b/src/features/decorators/common.ts @@ -1,13 +1,29 @@ import { Replace, OptionsObject } from "../feature"; -import { Computable, GetComputableType, processComputable, ProcessedComputable } from "util/computed"; +import { + Computable, + GetComputableType, + processComputable, + ProcessedComputable +} from "util/computed"; import { Persistent, State } from "game/persistence"; -export type Decorator = { +export type Decorator< + FeatureOptions, + BaseFeature = object, + GenericFeature = BaseFeature, + S extends State = State +> = { getPersistentData?(): Record>; - preConstruct?(feature: OptionsObject): void; - postConstruct?(feature: OptionsObject): void; - getGatheredProps?(feature: OptionsObject): Partial> -} + preConstruct?( + feature: OptionsObject + ): void; + postConstruct?( + feature: OptionsObject + ): void; + getGatheredProps?( + feature: OptionsObject + ): Partial>; +}; export type GenericDecorator = Decorator; @@ -16,17 +32,18 @@ export interface EffectFeatureOptions { } export type EffectFeature = Replace< - T, { effect: GetComputableType; } + T, + { effect: GetComputableType } >; export type GenericEffectFeature = Replace< EffectFeature, - { effect: ProcessedComputable; } + { effect: ProcessedComputable } >; /** - * Allows the usage of an `effect` field in the decorated feature. - * To function properly, the `createFeature()` function must have its generic type extended by {@linkcode EffectFeatureOptions}. + * Allows the usage of an `effect` field in the decorated feature. + * To function properly, the `createFeature()` function must have its generic type extended by {@linkcode EffectFeatureOptions}. * To allow access to the decorated values outside the `createFeature()` function, the output type must be extended by {@linkcode GenericEffectFeature}. * @example ```ts * createRepeatable(() => ({ @@ -39,5 +56,4 @@ export const effectDecorator: Decorator = S & Omit; * with "this" bound to what the type will eventually be processed into. * Intended for making lazily evaluated objects. */ -export type OptionsFunc = (obj: R) => OptionsObject; +export type OptionsFunc = (obj: R) => OptionsObject; export type OptionsObject = T & Partial & ThisType; diff --git a/src/features/repeatable.tsx b/src/features/repeatable.tsx index bc486e4..b15fe0f 100644 --- a/src/features/repeatable.tsx +++ b/src/features/repeatable.tsx @@ -134,7 +134,10 @@ export function createRepeatable( ...decorators: GenericDecorator[] ): Repeatable { const amount = persistent(0); - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy, Repeatable>(feature => { const repeatable = optionsFunc.call(feature, feature); @@ -233,10 +236,10 @@ export function createRepeatable(

joinJSX( - <>Amount: {formatWhole(genericRepeatable.amount.value)}, - {unref(genericRepeatable.limit) !== Decimal.dInf ? ( - <> / {formatWhole(unref(genericRepeatable.limit))} - ) : undefined} + <>Amount: {formatWhole(genericRepeatable.amount.value)}, + {unref(genericRepeatable.limit) !== Decimal.dInf ? ( + <> / {formatWhole(unref(genericRepeatable.limit))} + ) : undefined} )
)} @@ -274,7 +277,10 @@ export function createRepeatable( decorator.postConstruct?.(repeatable); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(repeatable)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(repeatable)), + {} + ); repeatable[GatherProps] = function (this: GenericRepeatable) { const { display, visibility, style, classes, onClick, canClick, small, mark, id } = this; diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index b773ff9..da77f60 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -105,7 +105,10 @@ export function createTreeNode( optionsFunc?: OptionsFunc, ...decorators: GenericDecorator[] ): TreeNode { - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const treeNode = optionsFunc?.call(feature, feature) ?? @@ -152,7 +155,10 @@ export function createTreeNode( }; } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(treeNode)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(treeNode)), + {} + ); treeNode[GatherProps] = function (this: GenericTreeNode) { const { display, diff --git a/src/features/upgrades/upgrade.ts b/src/features/upgrades/upgrade.ts index b8aa90f..094c641 100644 --- a/src/features/upgrades/upgrade.ts +++ b/src/features/upgrades/upgrade.ts @@ -21,7 +21,7 @@ import type { GenericLayer } from "game/layers"; import type { Persistent } from "game/persistence"; import { persistent } from "game/persistence"; import { -createCostRequirement, + createCostRequirement, createVisibilityRequirement, payRequirements, Requirements, @@ -122,7 +122,10 @@ export function createUpgrade( ...decorators: GenericDecorator[] ): Upgrade { const bought = persistent(false, false); - const decoratedData = decorators.reduce((current, next) => Object.assign(current, next.getPersistentData?.()), {}); + const decoratedData = decorators.reduce( + (current, next) => Object.assign(current, next.getPersistentData?.()), + {} + ); return createLazyProxy(feature => { const upgrade = optionsFunc.call(feature, feature); upgrade.id = getUniqueID("upgrade-"); @@ -165,7 +168,10 @@ export function createUpgrade( decorator.preConstruct?.(upgrade); } - const decoratedProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(upgrade)), {}); + const decoratedProps = decorators.reduce( + (current, next) => Object.assign(current, next.getGatheredProps?.(upgrade)), + {} + ); upgrade[GatherProps] = function (this: GenericUpgrade) { const { display,