Module: game/modifiers
Interfaces
AdditiveModifierOptions
• AdditiveModifierOptions: Object
An object that configures an additive modifier via createAdditiveModifier.
Name | Type | Description |
---|---|---|
addend | Computable <DecimalSource > | The amount to add to the input value. |
description? | Computable <CoercableComponent > | Description of what this modifier is doing. |
enabled? | Computable <boolean > | A computable that will be processed and passed directly into the returned modifier. |
smallerIsBetter? | boolean | Determines if numbers larger or smaller than 0 should be displayed as red. |
Defined in
profectus/src/game/modifiers.tsx:53
ExponentialModifierOptions
• ExponentialModifierOptions: Object
An object that configures an exponential modifier via createExponentialModifier.
Name | Type | Description |
---|---|---|
description? | Computable <CoercableComponent > | Description of what this modifier is doing. |
enabled? | Computable <boolean > | A computable that will be processed and passed directly into the returned modifier. |
exponent | Computable <DecimalSource > | The amount to raise the input value to the power of. |
smallerIsBetter? | boolean | Determines if numbers larger or smaller than 1 should be displayed as red. |
supportLowNumbers? | boolean | Add 1 before calculating, then remove it afterwards. This prevents low numbers from becoming lower. |
Defined in
profectus/src/game/modifiers.tsx:182
Modifier
• Modifier: Object
An object that can be used to apply or unapply some modification to a number. Being reversible requires the operation being invertible, but some features may rely on that. Descriptions can be optionally included for displaying them to the player. The built-in modifier creators are designed to display the modifiers using createModifierSection.
Name | Type | Description |
---|---|---|
apply | (gain : DecimalSource ) => DecimalSource | Applies some operation on the input and returns the result. |
description? | ProcessedComputable <CoercableComponent > | A description of this modifier. See createModifierSection. |
enabled? | ProcessedComputable <boolean > | Whether or not this modifier should be considered enabled. Typically for use with modifiers passed into createSequentialModifier. |
getFormula? | (gain : FormulaSource ) => GenericFormula | Get a formula for this modifier. Required by some features. |
invert? | (gain : DecimalSource ) => DecimalSource | Reverses the operation applied by the apply property. Required by some features. |
Defined in
profectus/src/game/modifiers.tsx:22
ModifierSectionOptions
• ModifierSectionOptions: Object
An object that configures a modifier section via createModifierSection.
Name | Type | Description |
---|---|---|
base? | DecimalSource | The base value that'll be passed into the modifier. Defaults to 1. |
baseText? | CoercableComponent | The label to use for the base value. Defaults to "Base". |
modifier | WithRequired <Modifier , "description" > | The modifier to render. |
smallerIsBetter? | boolean | Determines if numbers larger or smaller than the base should be displayed as red. |
subtitle? | string | Smaller text that appears in the header after the title. |
title | string | The header for the section. |
unit? | string | The unit of the value being modified, if any. |
Defined in
profectus/src/game/modifiers.tsx:324
MultiplicativeModifierOptions
• MultiplicativeModifierOptions: Object
An object that configures an multiplicative modifier via createMultiplicativeModifier.
Name | Type | Description |
---|---|---|
description? | Computable <CoercableComponent > | Description of what this modifier is doing. |
enabled? | Computable <boolean > | A computable that will be processed and passed directly into the returned modifier. |
multiplier | Computable <DecimalSource > | The amount to multiply the input value by. |
smallerIsBetter? | boolean | Determines if numbers larger or smaller than 1 should be displayed as red. |
Defined in
profectus/src/game/modifiers.tsx:118
Type Aliases
ModifierFromOptionalParams
Ƭ ModifierFromOptionalParams<T
, S
>: undefined
extends T
? undefined
extends S
? Omit
<WithRequired
<Modifier
, "invert"
| "getFormula"
>, "description"
| "enabled"
> : Omit
<WithRequired
<Modifier
, "invert"
| "enabled"
| "getFormula"
>, "description"
> : undefined
extends S
? Omit
<WithRequired
<Modifier
, "invert"
| "description"
| "getFormula"
>, "enabled"
> : WithRequired
<Modifier
, "invert"
| "enabled"
| "description"
| "getFormula"
>
Utility type used to narrow down a modifier type that will have a description and/or enabled property based on optional parameters, T and S (respectively).
Type parameters
Name |
---|
T |
S |
Defined in
profectus/src/game/modifiers.tsx:44
Functions
createAdditiveModifier
▸ createAdditiveModifier<T
>(optionsFunc
): ModifierFromOptionalParams
<T
["description"
], T
["enabled"
]>
Create a modifier that adds some value to the input value.
Type parameters
Name | Type |
---|---|
T | extends AdditiveModifierOptions |
Parameters
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T > | Additive modifier options. |
Returns
ModifierFromOptionalParams
<T
["description"
], T
["enabled"
]>
Defined in
profectus/src/game/modifiers.tsx:68
createExponentialModifier
▸ createExponentialModifier<T
>(optionsFunc
): ModifierFromOptionalParams
<T
["description"
], T
["enabled"
]>
Create a modifier that raises the input value to the power of some value.
Type parameters
Name | Type |
---|---|
T | extends ExponentialModifierOptions |
Parameters
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T > | Exponential modifier options. |
Returns
ModifierFromOptionalParams
<T
["description"
], T
["enabled"
]>
Defined in
profectus/src/game/modifiers.tsx:199
createModifierSection
▸ createModifierSection(options
): Element
Create a JSX element that displays a modifier. Intended to be used with the output from createSequentialModifier.
Parameters
Name | Type | Description |
---|---|---|
options | ModifierSectionOptions | Modifier section options. |
Returns
Element
Defined in
profectus/src/game/modifiers.tsx:346
createMultiplicativeModifier
▸ createMultiplicativeModifier<T
>(optionsFunc
): ModifierFromOptionalParams
<T
["description"
], T
["enabled"
]>
Create a modifier that multiplies the input value by some value.
Type parameters
Name | Type |
---|---|
T | extends MultiplicativeModifierOptions |
Parameters
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T > | Multiplicative modifier options. |
Returns
ModifierFromOptionalParams
<T
["description"
], T
["enabled"
]>
Defined in
profectus/src/game/modifiers.tsx:133
createSequentialModifier
▸ createSequentialModifier<T
, S
>(modifiersFunc
): S
Takes an array of modifiers and applies and reverses them in order. Modifiers that are not enabled will not be applied nor reversed. Also joins their descriptions together.
See
Type parameters
Name | Type |
---|---|
T | extends Modifier [] |
S | T extends WithRequired <Modifier , "invert" >[] ? WithRequired <Modifier , "description" | "invert" > : Omit <WithRequired <Modifier , "description" >, "invert" > |
Parameters
Name | Type | Description |
---|---|---|
modifiersFunc | () => T | The modifiers to perform sequentially. |
Returns
S