Skip to content
On this page

Module: game/requirements

Interfaces

CostRequirementOptions

CostRequirementOptions: Object

An object that configures a Requirement based on a resource cost.

NameTypeDescription
costComputable<DecimalSource> | GenericFormulaThe 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) => voidPass-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.
resourceResource<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

createCostRequirement

NameTypeDescription
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) => ElementThe display for this specific requirement. Required if visibility can be Visibility.Visible.
partialDisplay?(amount?: DecimalSource) => ElementThe display for this specific requirement. This is used for displays multiple requirements condensed. Required if visibility can be Visibility.Visible.
pay?(amount?: DecimalSource) => voidPerform any effects to the game state that should happen when the requirement gets triggered.
requirementMetProcessedComputable<boolean | DecimalSource>Whether or not this requirement has been met.
requiresPayProcessedComputable<boolean>Whether or not this requirement will need to affect the game state when whatever is using this requirement gets triggered.
visibilityProcessedComputable<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
NameTypeDescription
requirementComputable<boolean>The boolean requirement to use
display?CoercableComponentHow to display this requirement to the user
Returns

Requirement

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
NameType
Textends CostRequirementOptions
Parameters
NameTypeDescription
optionsFuncOptionsFunc<T>Cost requirement options.
Returns

CostRequirement

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
NameTypeDescription
featureObjectThe feature to check the visibility of
feature.visibilityProcessedComputable<boolean | Visibility>-
Returns

Requirement

Defined in

profectus/src/game/requirements.tsx:237


displayRequirements

displayRequirements(requirements, amount?): Element

Utility function for display 1+ requirements compactly.

Parameters
NameTypeDefault valueDescription
requirementsRequirementsundefinedThe 1+ requirements to display
amountDecimalSource1The 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
NameTypeDescription
requirementsRequirementsThe 1+ requirements to check
Returns

DecimalSource

Defined in

profectus/src/game/requirements.tsx:281


payByDivision

payByDivision(this, amount?): void

NameType
thisCostRequirement
amount?DecimalSource

Defined in

profectus/src/game/requirements.tsx:351


payByReset

payByReset(overrideDefaultValue?): (this: CostRequirement) => void

NameType
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
NameTypeDefault valueDescription
requirementsRequirementsundefinedThe 1+ requirements to pay
amountDecimalSource1How 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
NameTypeDescription
requirementsRequirementsThe 1+ requirements to check
Returns

boolean

Defined in

profectus/src/game/requirements.tsx:269