mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-24 09:21:45 +00:00
Fix remaining typing issues with formula typing change
This commit is contained in:
parent
6363062ce6
commit
7a81157bcc
3 changed files with 15 additions and 41 deletions
|
@ -2,11 +2,7 @@ import type { OptionsFunc, Replace } from "features/feature";
|
|||
import { setDefault } from "features/feature";
|
||||
import type { Resource } from "features/resources/resource";
|
||||
import Formula from "game/formulas/formulas";
|
||||
import {
|
||||
IntegrableFormula,
|
||||
InvertibleFormula,
|
||||
InvertibleIntegralFormula
|
||||
} from "game/formulas/types";
|
||||
import { InvertibleFormula, InvertibleIntegralFormula } from "game/formulas/types";
|
||||
import type { BaseLayer } from "game/layers";
|
||||
import type { DecimalSource } from "util/bignum";
|
||||
import Decimal from "util/bignum";
|
||||
|
@ -23,9 +19,7 @@ export interface ConversionOptions {
|
|||
* The formula used to determine how much {@link gainResource} should be earned by this converting.
|
||||
* The passed value will be a Formula representing the {@link baseResource} variable.
|
||||
*/
|
||||
formula: (
|
||||
variable: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => InvertibleFormula;
|
||||
formula: (variable: InvertibleIntegralFormula) => InvertibleFormula;
|
||||
/**
|
||||
* How much of the output resource the conversion can currently convert for.
|
||||
* Typically this will be set for you in a conversion constructor.
|
||||
|
|
|
@ -201,9 +201,7 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
|||
* Creates a formula that evaluates to a constant value.
|
||||
* @param value The constant value for this formula.
|
||||
*/
|
||||
public static constant(
|
||||
value: ProcessedComputable<DecimalSource>
|
||||
): InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula {
|
||||
public static constant(value: ProcessedComputable<DecimalSource>): InvertibleIntegralFormula {
|
||||
return new Formula({ inputs: [value] });
|
||||
}
|
||||
|
||||
|
@ -211,9 +209,7 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
|||
* Creates a formula that is marked as the variable for an outer formula. Typically used for inverting and integrating.
|
||||
* @param value The variable for this formula.
|
||||
*/
|
||||
public static variable(
|
||||
value: ProcessedComputable<DecimalSource>
|
||||
): InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula {
|
||||
public static variable(value: ProcessedComputable<DecimalSource>): InvertibleIntegralFormula {
|
||||
return new Formula({ variable: value });
|
||||
}
|
||||
|
||||
|
@ -228,9 +224,7 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
|||
public static step(
|
||||
value: FormulaSource,
|
||||
start: Computable<DecimalSource>,
|
||||
formulaModifier: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula
|
||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
|
||||
) {
|
||||
const lhsRef = ref<DecimalSource>(0);
|
||||
const formula = formulaModifier(Formula.variable(lhsRef));
|
||||
|
@ -271,12 +265,8 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
|||
public static if(
|
||||
value: FormulaSource,
|
||||
condition: Computable<boolean>,
|
||||
formulaModifier: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula,
|
||||
elseFormulaModifier?: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula
|
||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula,
|
||||
elseFormulaModifier?: (value: InvertibleIntegralFormula) => GenericFormula
|
||||
) {
|
||||
const lhsRef = ref<DecimalSource>(0);
|
||||
const variable = Formula.variable(lhsRef);
|
||||
|
@ -319,12 +309,8 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
|||
public static conditional(
|
||||
value: FormulaSource,
|
||||
condition: Computable<boolean>,
|
||||
formulaModifier: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula,
|
||||
elseFormulaModifier?: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula
|
||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula,
|
||||
elseFormulaModifier?: (value: InvertibleIntegralFormula) => GenericFormula
|
||||
) {
|
||||
return Formula.if(value, condition, formulaModifier, elseFormulaModifier);
|
||||
}
|
||||
|
@ -872,26 +858,20 @@ export abstract class InternalFormula<T extends [FormulaSource] | FormulaSource[
|
|||
|
||||
public step(
|
||||
start: Computable<DecimalSource>,
|
||||
formulaModifier: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula
|
||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
|
||||
) {
|
||||
return Formula.step(this, start, formulaModifier);
|
||||
}
|
||||
|
||||
public if(
|
||||
condition: Computable<boolean>,
|
||||
formulaModifier: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula
|
||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
|
||||
) {
|
||||
return Formula.if(this, condition, formulaModifier);
|
||||
}
|
||||
public conditional(
|
||||
condition: Computable<boolean>,
|
||||
formulaModifier: (
|
||||
value: InvertibleFormula & IntegrableFormula & InvertibleIntegralFormula
|
||||
) => GenericFormula
|
||||
formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula
|
||||
) {
|
||||
return Formula.if(this, condition, formulaModifier);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
setupPassiveGeneration
|
||||
} from "features/conversion";
|
||||
import { createResource, Resource } from "features/resources/resource";
|
||||
import { GenericFormula } from "game/formulas/types";
|
||||
import { InvertibleIntegralFormula } from "game/formulas/types";
|
||||
import { createLayer, GenericLayer } from "game/layers";
|
||||
import Decimal from "util/bignum";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
||||
|
@ -15,7 +15,7 @@ import "../utils";
|
|||
describe("Creating conversion", () => {
|
||||
let baseResource: Resource;
|
||||
let gainResource: Resource;
|
||||
let formula: (x: GenericFormula) => GenericFormula;
|
||||
let formula: (x: InvertibleIntegralFormula) => InvertibleIntegralFormula;
|
||||
beforeEach(() => {
|
||||
baseResource = createResource(ref(40));
|
||||
gainResource = createResource(ref(1));
|
||||
|
@ -449,7 +449,7 @@ describe("Creating conversion", () => {
|
|||
describe("Passive generation", () => {
|
||||
let baseResource: Resource;
|
||||
let gainResource: Resource;
|
||||
let formula: (x: GenericFormula) => GenericFormula;
|
||||
let formula: (x: InvertibleIntegralFormula) => InvertibleIntegralFormula;
|
||||
let conversion: GenericConversion;
|
||||
let layer: GenericLayer;
|
||||
beforeEach(() => {
|
||||
|
|
Loading…
Reference in a new issue