Module: game/requirements
Interfaces
CostRequirementOptions
• CostRequirementOptions: Object
An object that configures a Requirement based on a resource cost.
Name | Type | Description |
---|---|---|
cost | Computable <DecimalSource > | GenericFormula | The amount of resource that must be met for this requirement. You can pass a formula, in which case maximizing will work out of the box (assuming its invertible and, for more accurate calculations, its integral is invertible). If you don't pass a formula then you can still support maximizing by passing a custom pay function. |
cumulativeCost? | Computable <boolean > | When calculating multiple levels to be handled at once, whether it should consider resources used for each level as spent. Setting this to false causes calculations to be faster with larger numbers and supports more math functions. See |
directSum? | Computable <number > | When calculating requirement for multiple levels, how many should be directly summed for increase accuracy. High numbers can cause lag. Defaults to 10 if cumulative cost, 0 otherwise. |
maxBulkAmount? | Computable <DecimalSource > | Upper limit on levels that can be performed at once. Defaults to 1. |
pay? | (amount? : DecimalSource ) => void | Pass-through to pay. May be required for maximizing support. See cost for restrictions on maximizing support. |
requiresPay? | Computable <boolean > | Pass-through to requiresPay. If not set to false, the default pay function will remove cost from resource. |
resource | Resource <DecimalSource > | The resource that will be checked for meeting the cost. |
visibility? | Computable <boolean | Visible | None > | Pass-through to visibility. |
Defined in
profectus/src/game/requirements.tsx:68
Requirement
• Requirement: Object
An object that can be used to describe a requirement to perform some purchase or other action.
See
Name | Type | Description |
---|---|---|
canMaximize? | ProcessedComputable <boolean > | Whether or not this requirement can have multiple levels of requirements that can be met at once. Requirement is assumed to not have multiple levels if this property not present. |
display? | (amount? : DecimalSource ) => Element | The display for this specific requirement. Required if visibility can be Visibility.Visible. |
partialDisplay? | (amount? : DecimalSource ) => Element | The display for this specific requirement. This is used for displays multiple requirements condensed. Required if visibility can be Visibility.Visible. |
pay? | (amount? : DecimalSource ) => void | Perform any effects to the game state that should happen when the requirement gets triggered. |
requirementMet | ProcessedComputable <boolean | DecimalSource > | Whether or not this requirement has been met. |
requiresPay | ProcessedComputable <boolean > | Whether or not this requirement will need to affect the game state when whatever is using this requirement gets triggered. |
visibility | ProcessedComputable <boolean | Visible | None > | Whether or not this requirement should be displayed in Vue Features. displayRequirements will respect this property. |
Defined in
profectus/src/game/requirements.tsx:30
Type Aliases
CostRequirement
Ƭ CostRequirement: Replace
<Requirement
& CostRequirementOptions
, { canMaximize
: ProcessedComputable
<boolean
> ; cost
: ProcessedComputable
<DecimalSource
> | GenericFormula
; cumulativeCost
: ProcessedComputable
<boolean
> ; requiresPay
: ProcessedComputable
<boolean
> ; visibility
: ProcessedComputable
<Visible
| None
| boolean
> }>
Defined in
profectus/src/game/requirements.tsx:105
Requirements
Ƭ Requirements: Requirement
| Requirement
[]
Utility type for accepting 1 or more Requirements.
Defined in
profectus/src/game/requirements.tsx:65
Functions
createBooleanRequirement
▸ createBooleanRequirement(requirement
, display?
): Requirement
Creates a requirement based on a true/false value
Parameters
Name | Type | Description |
---|---|---|
requirement | Computable <boolean > | The boolean requirement to use |
display? | CoercableComponent | How to display this requirement to the user |
Returns
Defined in
profectus/src/game/requirements.tsx:252
createCostRequirement
▸ createCostRequirement<T
>(optionsFunc
): CostRequirement
Lazily creates a requirement with the given options, that is based on meeting an amount of a resource.
Type parameters
Name | Type |
---|---|
T | extends CostRequirementOptions |
Parameters
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T > | Cost requirement options. |
Returns
Defined in
profectus/src/game/requirements.tsx:120
createVisibilityRequirement
▸ createVisibilityRequirement(feature
): Requirement
Utility function for creating a requirement that a specified vue feature is visible
Parameters
Name | Type | Description |
---|---|---|
feature | Object | The feature to check the visibility of |
feature.visibility | ProcessedComputable <boolean | Visibility > | - |
Returns
Defined in
profectus/src/game/requirements.tsx:237
displayRequirements
▸ displayRequirements(requirements
, amount?
): Element
Utility function for display 1+ requirements compactly.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
requirements | Requirements | undefined | The 1+ requirements to display |
amount | DecimalSource | 1 | The amount of levels earned to be displayed |
Returns
Element
Defined in
profectus/src/game/requirements.tsx:299
maxRequirementsMet
▸ maxRequirementsMet(requirements
): DecimalSource
Calculates the maximum number of levels that could be acquired with the current requirement states. True/false requirements will be counted as Infinity or 0.
Parameters
Name | Type | Description |
---|---|---|
requirements | Requirements | The 1+ requirements to check |
Returns
Defined in
profectus/src/game/requirements.tsx:281
payByDivision
▸ payByDivision(this
, amount?
): void
Name | Type |
---|---|
this | CostRequirement |
amount? | DecimalSource |
Defined in
profectus/src/game/requirements.tsx:351
payByReset
▸ payByReset(overrideDefaultValue?
): (this
: CostRequirement
) => void
Name | Type |
---|---|
overrideDefaultValue? | DecimalSource |
Defined in
profectus/src/game/requirements.tsx:363
payRequirements
▸ payRequirements(requirements
, amount?
): void
Utility function for paying the costs for 1+ requirements
Parameters
Name | Type | Default value | Description |
---|---|---|---|
requirements | Requirements | undefined | The 1+ requirements to pay |
amount | DecimalSource | 1 | How many levels to pay for |
Returns
void
Defined in
profectus/src/game/requirements.tsx:343
requirementsMet
▸ requirementsMet(requirements
): boolean
Utility for checking if 1+ requirements are all met
Parameters
Name | Type | Description |
---|---|---|
requirements | Requirements | The 1+ requirements to check |
Returns
boolean