import{_ as e,c as t,o as l,N as a}from"./chunks/framework.0799945b.js";const u=JSON.parse('{"title":"Module: features/challenges/challenge","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/features/challenge.md","lastUpdated":null}'),o={name:"api/modules/features/challenge.md"},d=a('
• 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. |
profectus/src/features/challenges/challenge.tsx:92
• 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. |
maximize? | Computable <boolean > | Whether or not completing this challenge should grant multiple completions if requirements met. Requires requirements to be a requirement or array of requirements with Requirement.canMaximize true. |
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. |
profectus/src/features/challenges/challenge.tsx:46
Ƭ 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
>> ; maximize
: GetComputableType
<T
["maximize"
]> ; 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.
Name | Type |
---|---|
T | extends ChallengeOptions |
profectus/src/features/challenges/challenge.tsx:121
Ƭ 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.
profectus/src/features/challenges/challenge.tsx:137
• Const
ChallengeType: typeof ChallengeType
A symbol used to identify Challenge features.
profectus/src/features/challenges/challenge.tsx:41
▸ 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)
Name | Type | Description |
---|---|---|
challenges | GenericChallenge [] | The list of challenges that are mutually exclusive |
Ref
<GenericChallenge
| null
>
profectus/src/features/challenges/challenge.tsx:345
▸ createChallenge<T
>(optionsFunc
, ...decorators
): Challenge
<T
>
Lazily creates a challenge with the given options.
Name | Type |
---|---|
T | extends ChallengeOptions |
Name | Type | Description |
---|---|---|
optionsFunc | OptionsFunc <T , BaseChallenge , GenericChallenge > | Challenge options. |
...decorators | GenericDecorator [] | - |
Challenge
<T
>
profectus/src/features/challenges/challenge.tsx:151
▸ 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.
Name | Type | Description |
---|---|---|
challenges | GenericChallenge [] | Ref <null | GenericChallenge > | List of challenges that are mutually exclusive |
Ref
<boolean
>
profectus/src/features/challenges/challenge.tsx:355
▸ setupAutoComplete(challenge
, autoActive?
, exitOnComplete?
): WatchStopHandle
This will automatically complete a challenge when it's requirements are met.
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 |
WatchStopHandle
profectus/src/features/challenges/challenge.tsx:325
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 |