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"},a=c('
• 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
Name | Type |
---|---|
T | extends [FormulaSource ] | FormulaSource [] |
Name | Type |
---|---|
constructor | <T>(options : FormulaOptions <T >) => default <T > |
applySubstitution | undefined | 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 |
innermostVariable | undefined | ProcessedComputable <DecimalSource > |
inputs | T |
integralFormula | undefined | GenericFormula |
internalEvaluate | undefined | EvaluateFunction <T > |
internalIntegrate | undefined | IntegrateFunction <T > |
internalIntegrateInner | undefined | IntegrateFunction <T > |
internalInvert | undefined | InvertFunction <T > |
internalVariables | number |
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 , elseFormulaModifier? : (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 , elseFormulaModifier? : (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 } |
profectus/src/game/formulas/formulas.ts:46
▸ 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.
Name | Type | Description |
---|---|---|
formula | InvertibleFormula | The formula to use for calculating buy max from |
amountToBuy | DecimalSource | The amount of purchases to calculate the cost for |
spendResources? | true | Whether or not to count spent resources on each purchase or not. If true, costs will be approximated for performance, skewing towards higher cost |
summedPurchases? | number | How many purchases to manually sum for improved accuracy. If not specified, defaults to 10 when spending resources and 0 when not |
▸ calculateCost(formula
, amountToBuy
, spendResources
, summedPurchases?
): DecimalSource
Name | Type |
---|---|
formula | InvertibleIntegralFormula |
amountToBuy | DecimalSource |
spendResources | boolean |
summedPurchases? | number |
profectus/src/game/formulas/formulas.ts:1455
profectus/src/game/formulas/formulas.ts:1461
profectus/src/game/formulas/formulas.ts:1467
▸ 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.
Name | Type | Description |
---|---|---|
formula | InvertibleFormula | The formula to use for calculating buy max from |
resource | Resource <DecimalSource > | The resource used when purchasing (is only read from) |
spendResources? | true | Whether or not to count spent resources on each purchase or not. If true, costs will be approximated for performance, skewing towards fewer purchases |
summedPurchases? | number | How many of the most expensive purchases should be manually summed for better accuracy. If unspecified uses 10 when spending resources and 0 when not |
ComputedRef
<DecimalSource
>
▸ calculateMaxAffordable(formula
, resource
, spendResources
, summedPurchases?
): ComputedRef
<DecimalSource
>
Name | Type |
---|---|
formula | InvertibleIntegralFormula |
resource | Resource <DecimalSource > |
spendResources | Computable <boolean > |
summedPurchases? | number |
profectus/src/game/formulas/formulas.ts:1387
profectus/src/game/formulas/formulas.ts:1393
profectus/src/game/formulas/formulas.ts:1399
▸ findNonInvertible(formula
): GenericFormula
| null
Utility for recursively searching through a formula for the cause of non-invertibility.
Name | Type | Description |
---|---|---|
formula | GenericFormula | The formula to search for a non-invertible formula within |
GenericFormula
| null
profectus/src/game/formulas/formulas.ts:1344
▸ hasVariable(value
): value is InvertibleFormula
Name | Type |
---|---|
value | FormulaSource |
profectus/src/game/formulas/formulas.ts:24
▸ printFormula(formula
): string
Stringifies a formula so it's more easy to read in the console
Name | Type | Description |
---|---|---|
formula | FormulaSource | The formula to print |
string
profectus/src/game/formulas/formulas.ts:1362
▸ unrefFormulaSource(value
, variable?
): DecimalSource
Name | Type |
---|---|
value | FormulaSource |
variable? | DecimalSource |