Skip to content
On this page

Module: features/challenges/challenge

Interfaces

BaseChallenge

BaseChallenge: Object

The properties that are added onto a processed ChallengeOptions to create a Challenge.

NameTypeDescription
[Component]GenericComponentThe Vue component used to render this feature.
[GatherProps]() => Record<string, unknown>A function to gather the props the vue component requires for this feature.
activePersistent<boolean>Whether or not this challenge is currently active.
canCompleteRef<DecimalSource>The current amount of times this challenge can be completed.
complete(remainInChallenge?: boolean) => voidA function to complete this challenge.
completedRef<boolean>Whether or not this challenge has been completed.
completionsPersistent<DecimalSource>The current number of times this challenge has been completed.
idstringAn auto-generated ID for identifying features that appear in the DOM. Will not persist between refreshes or updates.
maxedRef<boolean>Whether or not this challenge's completion count is at its limit.
toggleVoidFunctionA function to enter or leave the challenge.
typetypeof ChallengeTypeA 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.

NameTypeDescription
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?VoidFunctionA function that is called when the challenge is completed.
onEnter?VoidFunctionA function that is called when the challenge is entered.
onExit?VoidFunctionA function that is called when the challenge is exited.
requirementsRequirementsThe requirement(s) to complete this challenge.
reset?GenericResetThe 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

NameType
Textends 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
NameTypeDescription
challengesGenericChallenge[]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
NameType
Textends ChallengeOptions
Parameters
NameTypeDescription
optionsFuncOptionsFunc<T, BaseChallenge, GenericChallenge>Challenge options.
...decoratorsGenericDecorator[]-
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
NameTypeDescription
challengesGenericChallenge[] | 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
NameTypeDefault valueDescription
challengeGenericChallengeundefinedThe challenge to auto-complete
autoActiveComputable<boolean>trueWhether or not auto-completing should currently occur
exitOnCompletebooleantrueWhether or not to exit the challenge after auto-completion
Returns

WatchStopHandle

Defined in

profectus/src/features/challenges/challenge.tsx:318

Components

Challenge Component

Props

NameType
active*processedPropType<boolean>(Boolean)
maxed*processedPropType<boolean>(Boolean)
canComplete*processedPropType<boolean>(Boolean)
displayprocessedPropType<UnwrapRef<GenericChallenge["display"]>>(
String,
Object,
Function
)
requirementsprocessedPropType<Requirements>(Object, Array)
visibility*processedPropType<Visibility | boolean>(Number, Boolean)
styleprocessedPropType<StyleValue>(String, Object, Array)
classesprocessedPropType<Record<string, boolean>>(Object)
completed*processedPropType<boolean>(Boolean)
canStart*processedPropType<boolean>(Boolean)
markprocessedPropType<boolean | string>(Boolean, String)
id*string
toggle*VoidFunction