Resolving problems

This commit is contained in:
thepaperpilot 2023-04-19 21:37:28 -05:00
parent 98f18fef43
commit 8806910f5e
11 changed files with 35 additions and 36 deletions

View file

@ -2,19 +2,19 @@ import { computed } from "@vue/reactivity";
import { isArray } from "@vue/shared";
import Select from "components/fields/Select.vue";
import AchievementComponent from "features/achievements/Achievement.vue";
import { Decorator, GenericDecorator } from "features/decorators/common";
import { GenericDecorator } from "features/decorators/common";
import {
CoercableComponent,
Component,
GatherProps,
GenericComponent,
getUniqueID,
jsx,
OptionsFunc,
Replace,
setDefault,
StyleValue,
Visibility
Visibility,
getUniqueID,
jsx,
setDefault
} from "features/feature";
import { globalBus } from "game/events";
import "game/notifications";
@ -22,10 +22,10 @@ import type { Persistent } from "game/persistence";
import { persistent } from "game/persistence";
import player from "game/player";
import {
Requirements,
createBooleanRequirement,
createVisibilityRequirement,
displayRequirements,
Requirements,
requirementsMet
} from "game/requirements";
import settings, { registerSettingField } from "game/settings";

View file

@ -1,5 +1,5 @@
import BarComponent from "features/bars/Bar.vue";
import { Decorator, GenericDecorator } from "features/decorators/common";
import { GenericDecorator } from "features/decorators/common";
import type {
CoercableComponent,
GenericComponent,
@ -7,7 +7,7 @@ import type {
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature";
import { Component, GatherProps, Visibility, getUniqueID, setDefault } from "features/feature";
import type { DecimalSource } from "util/bignum";
import { Direction } from "util/common";
import type {

View file

@ -1,7 +1,7 @@
import { isArray } from "@vue/shared";
import Toggle from "components/fields/Toggle.vue";
import ChallengeComponent from "features/challenges/Challenge.vue";
import { Decorator, GenericDecorator } from "features/decorators/common";
import { GenericDecorator } from "features/decorators/common";
import type {
CoercableComponent,
GenericComponent,
@ -12,17 +12,17 @@ import type {
import {
Component,
GatherProps,
Visibility,
getUniqueID,
isVisible,
jsx,
setDefault,
Visibility
setDefault
} from "features/feature";
import type { GenericReset } from "features/reset";
import { globalBus } from "game/events";
import type { Persistent } from "game/persistence";
import { persistent } from "game/persistence";
import { maxRequirementsMet, Requirements } from "game/requirements";
import { Requirements, maxRequirementsMet } from "game/requirements";
import settings, { registerSettingField } from "game/settings";
import type { DecimalSource } from "util/bignum";
import Decimal from "util/bignum";

View file

@ -1,5 +1,5 @@
import ClickableComponent from "features/clickables/Clickable.vue";
import { Decorator, GenericDecorator } from "features/decorators/common";
import { GenericDecorator } from "features/decorators/common";
import type {
CoercableComponent,
GenericComponent,
@ -7,7 +7,7 @@ import type {
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature";
import { Component, GatherProps, Visibility, getUniqueID, setDefault } from "features/feature";
import type { BaseLayer } from "game/layers";
import type { Unsubscribe } from "nanoevents";
import type {

View file

@ -28,7 +28,7 @@ export type Decorator<
export type GenericDecorator = Decorator<unknown>;
export interface EffectFeatureOptions {
effect: Computable<any>;
effect: Computable<unknown>;
}
export type EffectFeature<T extends EffectFeatureOptions> = Replace<
@ -38,7 +38,7 @@ export type EffectFeature<T extends EffectFeatureOptions> = Replace<
export type GenericEffectFeature = Replace<
EffectFeature<EffectFeatureOptions>,
{ effect: ProcessedComputable<any> }
{ effect: ProcessedComputable<unknown> }
>;
/**

View file

@ -14,7 +14,7 @@ import { globalBus } from "game/events";
import "lib/pixi";
import { processedPropType } from "util/vue";
import type { PropType } from "vue";
import { defineComponent, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, unref } from "vue";
import { defineComponent, nextTick, onBeforeUnmount, onMounted, shallowRef, unref } from "vue";
// TODO get typing support on the Particles component
export default defineComponent({

View file

@ -7,14 +7,14 @@ import type {
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature";
import { Component, GatherProps, Visibility, getUniqueID, jsx, setDefault } from "features/feature";
import { DefaultValue, Persistent, persistent } from "game/persistence";
import {
Requirements,
createVisibilityRequirement,
displayRequirements,
maxRequirementsMet,
payRequirements,
Requirements,
requirementsMet
} from "game/requirements";
import type { DecimalSource } from "util/bignum";
@ -30,7 +30,7 @@ import { createLazyProxy } from "util/proxies";
import { coerceComponent, isCoercableComponent } from "util/vue";
import type { Ref } from "vue";
import { computed, unref } from "vue";
import { Decorator, GenericDecorator } from "./decorators/common";
import { GenericDecorator } from "./decorators/common";
/** A symbol used to identify {@link Repeatable} features. */
export const RepeatableType = Symbol("Repeatable");

View file

@ -1,5 +1,5 @@
import { isArray } from "@vue/shared";
import { Decorator, GenericDecorator } from "features/decorators/common";
import { GenericDecorator } from "features/decorators/common";
import type {
CoercableComponent,
GenericComponent,
@ -9,22 +9,20 @@ import type {
} from "features/feature";
import {
Component,
findFeatures,
GatherProps,
Visibility,
findFeatures,
getUniqueID,
setDefault,
Visibility
setDefault
} from "features/feature";
import { createResource } from "features/resources/resource";
import UpgradeComponent from "features/upgrades/Upgrade.vue";
import type { GenericLayer } from "game/layers";
import type { Persistent } from "game/persistence";
import { persistent } from "game/persistence";
import {
createCostRequirement,
Requirements,
createVisibilityRequirement,
payRequirements,
Requirements,
requirementsMet
} from "game/requirements";
import { isFunction } from "util/common";

View file

@ -267,6 +267,7 @@ export function displayRequirements(requirements: Requirements, amount: DecimalS
<div>
Costs:{" "}
{joinJSX(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
withCosts.map(r => r.partialDisplay!(amount)),
<>, </>
)}
@ -276,6 +277,7 @@ export function displayRequirements(requirements: Requirements, amount: DecimalS
<div>
Requires:{" "}
{joinJSX(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
withoutCosts.map(r => r.partialDisplay!(amount)),
<>, </>
)}

View file

@ -8,7 +8,7 @@ import { createResource, Resource } from "features/resources/resource";
import { GenericFormula } from "game/formulas/types";
import { createLayer, GenericLayer } from "game/layers";
import Decimal from "util/bignum";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { ref, unref } from "vue";
import "../utils";
@ -472,15 +472,15 @@ describe("Passive generation", () => {
setupPassiveGeneration(layer, conversion);
layer.emit("preUpdate", 1);
expect(gainResource.value).compare_tolerance(2);
})
});
test("Rate is 100", () => {
setupPassiveGeneration(layer, conversion, () => 100);
layer.emit("preUpdate", 1);
expect(gainResource.value).compare_tolerance(101);
})
});
test("Obeys cap", () => {
setupPassiveGeneration(layer, conversion, 100, () => 100);
layer.emit("preUpdate", 1);
expect(gainResource.value).compare_tolerance(100);
})
});
});

View file

@ -2,11 +2,10 @@ import { createResource, Resource } from "features/resources/resource";
import Formula, {
calculateCost,
calculateMaxAffordable,
printFormula,
unrefFormulaSource
} from "game/formulas/formulas";
import type { GenericFormula, InvertibleFormula } from "game/formulas/types";
import Decimal, { DecimalSource, format } from "util/bignum";
import Decimal, { DecimalSource } from "util/bignum";
import { beforeAll, describe, expect, test } from "vitest";
import { ref } from "vue";
import "../utils";
@ -151,7 +150,7 @@ describe("Formula Equality Checking", () => {
describe("Formula aliases", () => {
function testAliases<T extends FormulaFunctions>(
aliases: T[],
args: Parameters<typeof Formula[T]>
args: Parameters<(typeof Formula)[T]>
) {
describe(aliases[0], () => {
let formula: GenericFormula;
@ -239,7 +238,7 @@ describe("Creating Formulas", () => {
function checkFormula<T extends FormulaFunctions>(
functionName: T,
args: Readonly<Parameters<typeof Formula[T]>>
args: Readonly<Parameters<(typeof Formula)[T]>>
) {
let formula: GenericFormula;
beforeAll(() => {
@ -261,7 +260,7 @@ describe("Creating Formulas", () => {
// It's a lot of tests, but I'd rather be exhaustive
function testFormulaCall<T extends FormulaFunctions>(
functionName: T,
args: Readonly<Parameters<typeof Formula[T]>>
args: Readonly<Parameters<(typeof Formula)[T]>>
) {
if ((functionName === "slog" || functionName === "layeradd") && args[0] === -1) {
// These cases in particular take a long time, so skip them