Module: features/challenges/challenge
Interfaces
BaseChallenge
• BaseChallenge: Object
The properties that are added onto a processed ChallengeOptions to create a Challenge.
Name | Type | Description |
---|---|---|
[Component] | GenericComponent | The Vue component used to render this feature. |
[GatherProps] | () => Record <string , unknown > | A function to gather the props the vue component requires for this feature. |
active | Persistent <boolean > | Whether or not this challenge is currently active. |
canComplete | Ref <DecimalSource > | The current amount of times this challenge can be completed. |
complete | (remainInChallenge? : boolean ) => void | A function to complete this challenge. |
completed | Ref <boolean > | Whether or not this challenge has been completed. |
completions | Persistent <DecimalSource > | The current number of times this challenge has been completed. |
id | string | An auto-generated ID for identifying features that appear in the DOM. Will not persist between refreshes or updates. |
maxed | Ref <boolean > | Whether or not this challenge's completion count is at its limit. |
toggle | VoidFunction | A function to enter or leave the challenge. |
type | typeof ChallengeType | A symbol that helps identify features of the same type. |
Defined in
profectus/src/features/challenges/challenge.tsx:90
ChallengeOptions
• ChallengeOptions: Object
An object that configures a Challenge.
Name | Type | Description |
---|---|---|
canStart? | Computable <boolean > | Whether this challenge can be started. |
classes? | Computable <Record <string , boolean >> | Dictionary of CSS classes to apply to this feature. |
completionLimit? | Computable <DecimalSource > | The maximum number of times the challenge can be completed. |
display? | Computable <CoercableComponent | { description : CoercableComponent ; effectDisplay? : CoercableComponent ; goal? : CoercableComponent ; reward? : CoercableComponent ; title? : CoercableComponent }> | The display to use for this challenge. |
mark? | Computable <string | boolean > | Shows a marker on the corner of the feature. |
onComplete? | VoidFunction | A function that is called when the challenge is completed. |
onEnter? | VoidFunction | A function that is called when the challenge is entered. |
onExit? | VoidFunction | A function that is called when the challenge is exited. |
requirements | Requirements | The requirement(s) to complete this challenge. |
reset? | GenericReset | The reset function for this challenge. |
style? | Computable <StyleValue > | CSS to apply to this feature. |
visibility? | Computable <boolean | Visibility > | Whether this challenge should be visible. |
Defined in
profectus/src/features/challenges/challenge.tsx:46
Type Aliases
Challenge
Ƭ Challenge<T
>: Replace
<T
& BaseChallenge
, { canStart
: GetComputableTypeWithDefault
<T
["canStart"
], true
> ; classes
: GetComputableType
<T
["classes"
]> ; completionLimit
: GetComputableTypeWithDefault
<T
["completionLimit"
], 1
> ; display
: GetComputableType
<T
["display"
]> ; mark
: GetComputableTypeWithDefault
<T
["mark"
], Ref
<boolean
>> ; requirements
: GetComputableType
<T
["requirements"
]> ; style
: GetComputableType
<T
["style"
]> ; visibility
: GetComputableTypeWithDefault
<T
["visibility"
], Visible
> }>
An object that represents a feature that can be entered and exited, and have one or more completions with scaling requirements.
Type parameters
Name | Type |
---|---|
T | extends ChallengeOptions |
Defined in
profectus/src/features/challenges/challenge.tsx:119
GenericChallenge
Ƭ GenericChallenge: Replace
<Challenge
<ChallengeOptions
>, { canStart
: ProcessedComputable
<boolean
> ; completionLimit
: ProcessedComputable
<DecimalSource
> ; mark
: ProcessedComputable
<boolean
> ; visibility
: ProcessedComputable
<Visibility
| boolean
> }>
A type that matches any valid Challenge object.
Defined in
profectus/src/features/challenges/challenge.tsx:134
Variables
ChallengeType
• Const
ChallengeType: typeof ChallengeType
A symbol used to identify Challenge features.
Defined in
profectus/src/features/challenges/challenge.tsx:41
Functions
createActiveChallenge
▸ createActiveChallenge(challenges
): Ref
<GenericChallenge
| null
>
Utility for taking an array of challenges where only one may be active at a time, and giving a ref to the one currently active (or null if none are active)
Parameters
Name | Type | Description |
---|---|---|
challenges | GenericChallenge [] | The list of challenges that are mutually exclusive |
Returns
Ref
<GenericChallenge
| null
>
Defined in
profectus/src/features/challenges/challenge.tsx:338
createChallenge
▸ createChallenge<T
>(optionsFunc
, ...decorators
): Challenge
<T
>
Lazily creates a challenge with the given options.
Type parameters
Name | Type |
---|---|
T | extends ChallengeOptions |
Parameters
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T , BaseChallenge , GenericChallenge > | Challenge options. |
...decorators | GenericDecorator [] | - |
Returns
Challenge
<T
>
Defined in
profectus/src/features/challenges/challenge.tsx:148
isAnyChallengeActive
▸ isAnyChallengeActive(challenges
): Ref
<boolean
>
Utility for reporting if any challenge in a list is currently active. Intended for preventing entering a challenge if another is already active.
Parameters
Name | Type | Description |
---|---|---|
challenges | GenericChallenge [] | Ref <null | GenericChallenge > | List of challenges that are mutually exclusive |
Returns
Ref
<boolean
>
Defined in
profectus/src/features/challenges/challenge.tsx:348
setupAutoComplete
▸ setupAutoComplete(challenge
, autoActive?
, exitOnComplete?
): WatchStopHandle
This will automatically complete a challenge when it's requirements are met.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
challenge | GenericChallenge | undefined | The challenge to auto-complete |
autoActive | Computable <boolean > | true | Whether or not auto-completing should currently occur |
exitOnComplete | boolean | true | Whether or not to exit the challenge after auto-completion |
Returns
WatchStopHandle
Defined in
profectus/src/features/challenges/challenge.tsx:318
Components
Challenge Component
Props
Name | Type |
---|---|
active * | processedPropType<boolean>(Boolean) |
maxed * | processedPropType<boolean>(Boolean) |
canComplete * | processedPropType<boolean>(Boolean) |
display | processedPropType<UnwrapRef<GenericChallenge["display"]>>( |
requirements | processedPropType<Requirements>(Object, Array) |
visibility * | processedPropType<Visibility | boolean>(Number, Boolean) |
style | processedPropType<StyleValue>(String, Object, Array) |
classes | processedPropType<Record<string, boolean>>(Object) |
completed * | processedPropType<boolean>(Boolean) |
canStart * | processedPropType<boolean>(Boolean) |
mark | processedPropType<boolean | string>(Boolean, String) |
id * | string |
toggle * | VoidFunction |