Added setupAutoComplete
This commit is contained in:
parent
14b1420b55
commit
b33de01a96
1 changed files with 13 additions and 0 deletions
|
@ -272,6 +272,19 @@ export function createChallenge<T extends ChallengeOptions>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setupAutoComplete(
|
||||||
|
challenge: GenericChallenge,
|
||||||
|
autoActive: Computable<boolean> = true,
|
||||||
|
exitOnComplete = true
|
||||||
|
): WatchStopHandle {
|
||||||
|
const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive;
|
||||||
|
return watch([challenge.canComplete, isActive], ([canComplete, isActive]) => {
|
||||||
|
if (canComplete && isActive) {
|
||||||
|
challenge.complete(!exitOnComplete);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
declare module "game/settings" {
|
declare module "game/settings" {
|
||||||
interface Settings {
|
interface Settings {
|
||||||
hideChallenges: boolean;
|
hideChallenges: boolean;
|
||||||
|
|
Loading…
Reference in a new issue