import{_ as e,c as o,o as t,N as c}from"./chunks/framework.0799945b.js";const h=JSON.parse('{"title":"Module: game/formulas/formulas","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/game/formulas/formulas.md","lastUpdated":null}'),d={name:"api/modules/game/formulas/formulas.md"},r=c('

Module: game/formulas/formulas

Classes

default

default<T>: Object

A class that can be used for cost/goal functions. It can be evaluated similar to a cost function, but also provides extra features for supported formulas. For example, a lot of math functions can be inverted. Typically, the use of these extra features is to support cost/goal functions that have multiple levels purchased/completed at once efficiently.

See

Type parameters

NameType
Textends [FormulaSource] | FormulaSource[]
NameType
constructor<T>(options: FormulaOptions<T>) => default<T>
applySubstitutionundefined | SubstitutionFunction<T>
divide<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
divideBy<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
dividedBy<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
innermostVariableundefined | ProcessedComputable<DecimalSource>
inputsT
integralFormulaundefined | GenericFormula
internalEvaluateundefined | EvaluateFunction<T>
internalIntegrateundefined | IntegrateFunction<T>
internalIntegrateInnerundefined | IntegrateFunction<T>
internalInvertundefined | InvertFunction<T>
internalVariablesnumber
logarithm<T>(this: T, value: FormulaSource) => T<T>(this: FormulaSource, value: T) => T(this: FormulaSource, value: FormulaSource) => GenericFormula
minus<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
multiply<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
negate<T>(this: T) => T(this: GenericFormula) => GenericFormula
negated<T>(this: T) => T(this: GenericFormula) => GenericFormula
plus<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
reciprocal<T>(this: T) => T(this: FormulaSource) => GenericFormula
reciprocate<T>(this: T) => T(this: FormulaSource) => GenericFormula
sgn() => GenericFormula
subtract<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
times<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
clampMax(value: FormulaSource, other: FormulaSource) => default<[FormulaSource, FormulaSource]>
clampMin(value: FormulaSource, other: FormulaSource) => default<[FormulaSource, FormulaSource]>
divide<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
divideBy<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
dividedBy<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
logarithm<T>(value: T, base: FormulaSource) => T<T>(value: FormulaSource, base: T) => T(value: FormulaSource, base: FormulaSource) => GenericFormula
max(value: FormulaSource, other: FormulaSource) => default<[FormulaSource, FormulaSource]>
maxabs(value: FormulaSource, other: FormulaSource) => default<[FormulaSource, FormulaSource]>
min(value: FormulaSource, other: FormulaSource) => default<[FormulaSource, FormulaSource]>
minabs(value: FormulaSource, other: FormulaSource) => default<[FormulaSource, FormulaSource]>
minus<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
multiply<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
negate<T>(value: T) => T(value: FormulaSource) => GenericFormula
negated<T>(value: T) => T(value: FormulaSource) => GenericFormula
plus<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
reciprocal<T>(value: T) => T(value: FormulaSource) => GenericFormula
reciprocate<T>(value: T) => T(value: FormulaSource) => GenericFormula
sgn(value: FormulaSource) => GenericFormula
subtract<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
times<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
abs() => GenericFormula
absLog10() => GenericFormula
acos<T>(this: T) => T(this: FormulaSource) => GenericFormula
acosh<T>(this: T) => T(this: FormulaSource) => GenericFormula
add<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
asin<T>(this: T) => T(this: FormulaSource) => GenericFormula
asinh<T>(this: T) => T(this: FormulaSource) => GenericFormula
atan<T>(this: T) => T(this: FormulaSource) => GenericFormula
atanh<T>(this: T) => T(this: FormulaSource) => GenericFormula
calculateConstantOfIntegration() => default
cbrt<T>(this: T) => T(this: FormulaSource) => GenericFormula
ceil() => GenericFormula
clamp(min: FormulaSource, max: FormulaSource) => GenericFormula
clampMax(value: FormulaSource) => default<[FormulaSource, FormulaSource]>
clampMin(value: FormulaSource) => default<[FormulaSource, FormulaSource]>
conditional(condition: Computable<boolean>, formulaModifier: (value: GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }) => GenericFormula) => GenericFormula
cos<T>(this: T) => T(this: FormulaSource) => GenericFormula
cosh<T>(this: T) => T(this: FormulaSource) => GenericFormula
cube<T>(this: T) => T(this: FormulaSource) => GenericFormula
div<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
equals(other: GenericFormula) => boolean
evaluate(variable?: DecimalSource) => DecimalSource
evaluateIntegral(variable?: DecimalSource) => DecimalSource
exp<T>(this: T) => T(this: FormulaSource) => GenericFormula
factorial() => default<[FormulaSource]>
floor() => GenericFormula
gamma() => default<[FormulaSource]>
getIntegralFormula(stack?: SubstitutionStack) => GenericFormula
hasVariable() => boolean
if(condition: Computable<boolean>, formulaModifier: (value: GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }) => GenericFormula) => GenericFormula
invert(value: DecimalSource) => DecimalSource
invertIntegral(value: DecimalSource) => DecimalSource
isIntegrable() => this is IntegrableFormula
isIntegralInvertible() => this is InvertibleIntegralFormula
isInvertible() => this is InvertibleFormula
iteratedexp<T>(this: T, height?: FormulaSource, payload?: FormulaSource) => Omit<T, "integrate">(this: FormulaSource, height?: FormulaSource, payload?: FormulaSource) => GenericFormula
iteratedlog(base: FormulaSource, times: FormulaSource) => GenericFormula
lambertw<T>(this: T) => Omit<T, "integrate">(this: FormulaSource) => GenericFormula
layeradd<T>(this: T, diff: FormulaSource, base?: FormulaSource) => Omit<T, "integrate">(this: FormulaSource, diff: FormulaSource, base?: FormulaSource) => GenericFormula
layeradd10(diff: FormulaSource) => default<[FormulaSource, FormulaSource]>
ln<T>(this: T) => T(this: FormulaSource) => GenericFormula
lngamma() => default<[FormulaSource]>
log<T>(this: T, value: FormulaSource) => T<T>(this: FormulaSource, value: T) => T(this: FormulaSource, value: FormulaSource) => GenericFormula
log10<T>(this: T) => T(this: FormulaSource) => GenericFormula
log2<T>(this: T) => T(this: FormulaSource) => GenericFormula
max(value: FormulaSource) => default<[FormulaSource, FormulaSource]>
maxabs(value: FormulaSource) => default<[FormulaSource, FormulaSource]>
min(value: FormulaSource) => default<[FormulaSource, FormulaSource]>
minabs(value: FormulaSource) => default<[FormulaSource, FormulaSource]>
mul<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
neg<T>(this: T) => T(this: GenericFormula) => GenericFormula
pLog10() => GenericFormula
pentate(height: FormulaSource, payload: FormulaSource) => GenericFormula
pow<T>(this: T, value: FormulaSource) => T<T>(this: FormulaSource, value: T) => T(this: FormulaSource, value: FormulaSource) => GenericFormula
pow10<T>(this: T) => T(this: FormulaSource) => GenericFormula
pow_base<T>(this: T, value: FormulaSource) => T<T>(this: FormulaSource, value: T) => T(this: FormulaSource, value: FormulaSource) => GenericFormula
recip<T>(this: T) => T(this: FormulaSource) => GenericFormula
root<T>(this: T, value: FormulaSource) => T<T>(this: FormulaSource, value: T) => T(this: FormulaSource, value: FormulaSource) => GenericFormula
round() => GenericFormula
setupConstant(__namedParameters: { inputs: [FormulaSource] }) => InternalFormulaProperties<T>
setupFormula(options: GeneralFormulaOptions<T>) => InternalFormulaProperties<T>
setupVariable(__namedParameters: { variable: ProcessedComputable<DecimalSource> }) => InternalFormulaProperties<T>
sign() => GenericFormula
sin<T>(this: T) => T(this: FormulaSource) => GenericFormula
sinh<T>(this: T) => T(this: FormulaSource) => GenericFormula
slog<T>(this: T, base?: FormulaSource) => Omit<T, "integrate">(this: FormulaSource, base?: FormulaSource) => GenericFormula
sqr<T>(this: T) => T(this: FormulaSource) => GenericFormula
sqrt<T>(this: T) => T(this: FormulaSource) => GenericFormula
ssqrt<T>(this: T) => Omit<T, "integrate">(this: FormulaSource) => GenericFormula
step(start: Computable<DecimalSource>, formulaModifier: (value: GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }) => GenericFormula) => GenericFormula
sub<T>(this: T, value: FormulaSource) => T<T>(this: GenericFormula, value: T) => T(this: GenericFormula, value: FormulaSource) => GenericFormula
tan<T>(this: T) => T(this: FormulaSource) => GenericFormula
tanh<T>(this: T) => T(this: FormulaSource) => GenericFormula
tetrate<T>(this: T, height?: FormulaSource, payload?: FormulaSource) => Omit<T, "integrate">(this: FormulaSource, height?: FormulaSource, payload?: FormulaSource) => GenericFormula
trunc() => GenericFormula
abs(value: FormulaSource) => GenericFormula
absLog10(value: FormulaSource) => GenericFormula
acos<T>(value: T) => T(value: FormulaSource) => GenericFormula
acosh<T>(value: T) => T(value: FormulaSource) => GenericFormula
add<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
asin<T>(value: T) => T(value: FormulaSource) => GenericFormula
asinh<T>(value: T) => T(value: FormulaSource) => GenericFormula
atan<T>(value: T) => T(value: FormulaSource) => GenericFormula
atanh<T>(value: T) => T(value: FormulaSource) => GenericFormula
cbrt<T>(value: T) => T(value: FormulaSource) => GenericFormula
ceil(value: FormulaSource) => GenericFormula
clamp(value: FormulaSource, min: FormulaSource, max: FormulaSource) => GenericFormula
conditional(value: FormulaSource, condition: Computable<boolean>, formulaModifier: (value: GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }) => GenericFormula) => GenericFormula
constant(value: ProcessedComputable<DecimalSource>) => GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }
cos<T>(value: T) => T(value: FormulaSource) => GenericFormula
cosh<T>(value: T) => T(value: FormulaSource) => GenericFormula
cube<T>(value: T) => T(value: FormulaSource) => GenericFormula
div<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
exp<T>(value: T) => T(value: FormulaSource) => GenericFormula
factorial(value: FormulaSource) => default<[FormulaSource]>
floor(value: FormulaSource) => GenericFormula
gamma(value: FormulaSource) => default<[FormulaSource]>
if(value: FormulaSource, condition: Computable<boolean>, formulaModifier: (value: GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }) => GenericFormula) => GenericFormula
iteratedexp<T>(value: T, height?: FormulaSource, payload?: FormulaSource) => Omit<T, "integrate">(value: FormulaSource, height?: FormulaSource, payload?: FormulaSource) => GenericFormula
iteratedlog(value: FormulaSource, base: FormulaSource, times: FormulaSource) => GenericFormula
lambertw<T>(value: T) => Omit<T, "integrate">(value: FormulaSource) => GenericFormula
layeradd<T>(value: T, diff: FormulaSource, base?: FormulaSource) => Omit<T, "integrate">(value: FormulaSource, diff: FormulaSource, base?: FormulaSource) => GenericFormula
layeradd10(value: FormulaSource, diff: FormulaSource) => default<[FormulaSource, FormulaSource]>
ln<T>(value: T) => T(value: FormulaSource) => GenericFormula
lngamma(value: FormulaSource) => default<[FormulaSource]>
log<T>(value: T, base: FormulaSource) => T<T>(value: FormulaSource, base: T) => T(value: FormulaSource, base: FormulaSource) => GenericFormula
log10<T>(value: T) => T(value: FormulaSource) => GenericFormula
log2<T>(value: T) => T(value: FormulaSource) => GenericFormula
mul<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
neg<T>(value: T) => T(value: FormulaSource) => GenericFormula
pLog10(value: FormulaSource) => GenericFormula
pentate(value: FormulaSource, height: FormulaSource, payload: FormulaSource) => GenericFormula
pow<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
pow10<T>(value: T) => T(value: FormulaSource) => GenericFormula
pow_base<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
recip<T>(value: T) => T(value: FormulaSource) => GenericFormula
root<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
round(value: FormulaSource) => GenericFormula
sign(value: FormulaSource) => GenericFormula
sin<T>(value: T) => T(value: FormulaSource) => GenericFormula
sinh<T>(value: T) => T(value: FormulaSource) => GenericFormula
slog<T>(value: T, base?: FormulaSource) => Omit<T, "integrate">(value: FormulaSource, base?: FormulaSource) => GenericFormula
sqr<T>(value: T) => T(value: FormulaSource) => GenericFormula
sqrt<T>(value: T) => T(value: FormulaSource) => GenericFormula
ssqrt<T>(value: T) => Omit<T, "integrate">(value: FormulaSource) => GenericFormula
step(value: FormulaSource, start: Computable<DecimalSource>, formulaModifier: (value: GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }) => GenericFormula) => GenericFormula
sub<T>(value: T, other: FormulaSource) => T<T>(value: FormulaSource, other: T) => T(value: FormulaSource, other: FormulaSource) => GenericFormula
tan<T>(value: T) => T(value: FormulaSource) => GenericFormula
tanh<T>(value: T) => T(value: FormulaSource) => GenericFormula
tetrate<T>(value: T, height?: FormulaSource, payload?: FormulaSource) => Omit<T, "integrate">(value: FormulaSource, height?: FormulaSource, payload?: FormulaSource) => GenericFormula
trunc(value: FormulaSource) => GenericFormula
variable(value: ProcessedComputable<DecimalSource>) => GenericFormula & { invert: (value: DecimalSource) => DecimalSource } & { evaluateIntegral: (variable?: DecimalSource) => DecimalSource } & { invertIntegral: (value: DecimalSource) => DecimalSource }

Defined in

profectus/src/game/formulas/formulas.ts:45

Functions

calculateCost

calculateCost(formula, amountToBuy, spendResources?, summedPurchases?): DecimalSource

Utility for calculating the cost of a formula for a given amount of purchases. If spendResources is changed to false, the calculation will be much faster with higher numbers.

Parameters

NameTypeDescription
formulaInvertibleFormulaThe formula to use for calculating buy max from
amountToBuyDecimalSourceThe amount of purchases to calculate the cost for
spendResources?trueWhether or not to count spent resources on each purchase or not. If true, costs will be approximated for performance, skewing towards higher cost
summedPurchases?numberHow many purchases to manually sum for improved accuracy. If not specified, defaults to 10 when spending resources and 0 when not

Returns

DecimalSource

Defined in

profectus/src/game/formulas/formulas.ts:1433

calculateCost(formula, amountToBuy, spendResources, summedPurchases?): DecimalSource

Parameters

NameType
formulaInvertibleIntegralFormula
amountToBuyDecimalSource
spendResourcesboolean
summedPurchases?number

Returns

DecimalSource

Defined in

profectus/src/game/formulas/formulas.ts:1439

calculateCost: (formula: InvertibleFormula, amountToBuy: DecimalSource, spendResources?: true, summedPurchases?: number) => DecimalSource(formula: InvertibleIntegralFormula, amountToBuy: DecimalSource, spendResources: boolean, summedPurchases?: number) => DecimalSource

Defined in

profectus/src/game/formulas/formulas.ts:1433

profectus/src/game/formulas/formulas.ts:1439

profectus/src/game/formulas/formulas.ts:1445


calculateMaxAffordable

calculateMaxAffordable(formula, resource, spendResources?, summedPurchases?): ComputedRef<DecimalSource>

Utility for calculating the maximum amount of purchases possible with a given formula and resource. If spendResources is changed to false, the calculation will be much faster with higher numbers.

Parameters

NameTypeDescription
formulaInvertibleFormulaThe formula to use for calculating buy max from
resourceResource<DecimalSource>The resource used when purchasing (is only read from)
spendResources?trueWhether or not to count spent resources on each purchase or not. If true, costs will be approximated for performance, skewing towards fewer purchases
summedPurchases?numberHow many of the most expensive purchases should be manually summed for better accuracy. If unspecified uses 10 when spending resources and 0 when not

Returns

ComputedRef<DecimalSource>

Defined in

profectus/src/game/formulas/formulas.ts:1365

calculateMaxAffordable(formula, resource, spendResources, summedPurchases?): ComputedRef<DecimalSource>

Parameters

NameType
formulaInvertibleIntegralFormula
resourceResource<DecimalSource>
spendResourcesComputable<boolean>
summedPurchases?number

Returns

ComputedRef<DecimalSource>

Defined in

profectus/src/game/formulas/formulas.ts:1371

calculateMaxAffordable: (formula: InvertibleFormula, resource: Resource<DecimalSource>, spendResources?: true, summedPurchases?: number) => ComputedRef<DecimalSource>(formula: InvertibleIntegralFormula, resource: Resource<DecimalSource>, spendResources: Computable<boolean>, summedPurchases?: number) => ComputedRef<DecimalSource>

Defined in

profectus/src/game/formulas/formulas.ts:1365

profectus/src/game/formulas/formulas.ts:1371

profectus/src/game/formulas/formulas.ts:1377


findNonInvertible

findNonInvertible(formula): GenericFormula | null

Utility for recursively searching through a formula for the cause of non-invertibility.

Parameters

NameTypeDescription
formulaGenericFormulaThe formula to search for a non-invertible formula within

Returns

GenericFormula | null

Defined in

profectus/src/game/formulas/formulas.ts:1322

findNonInvertible: (formula: GenericFormula) => GenericFormula | null

Defined in

profectus/src/game/formulas/formulas.ts:1322


hasVariable

hasVariable(value): value is InvertibleFormula

Parameters

NameType
valueFormulaSource

Returns

value is InvertibleFormula

Defined in

profectus/src/game/formulas/formulas.ts:23

hasVariable: (value: FormulaSource) => value is InvertibleFormula

Defined in

profectus/src/game/formulas/formulas.ts:23


printFormula

printFormula(formula): string

Stringifies a formula so it's more easy to read in the console

Parameters

NameTypeDescription
formulaFormulaSourceThe formula to print

Returns

string

Defined in

profectus/src/game/formulas/formulas.ts:1340

printFormula: (formula: FormulaSource) => string

Defined in

profectus/src/game/formulas/formulas.ts:1340


unrefFormulaSource

unrefFormulaSource(value, variable?): DecimalSource

Parameters

NameType
valueFormulaSource
variable?DecimalSource

Returns

DecimalSource

Defined in

profectus/src/game/formulas/formulas.ts:27

unrefFormulaSource: (value: FormulaSource, variable?: DecimalSource) => DecimalSource

Defined in

profectus/src/game/formulas/formulas.ts:27

',106),a=[r];function l(u,s,f,i,n,m){return t(),o("div",null,a)}const y=e(d,[["render",l]]);export{h as __pageData,y as default};