From d099218003bd85ba30840c010de3b74f1ded4f73 Mon Sep 17 00:00:00 2001 From: Arturas Date: Thu, 15 Dec 2022 21:41:04 +0200 Subject: [PATCH] feat: Wait action --- src/actions/core/delay-action.mts | 25 +++++++++++++++++++++++++ src/actions/core/index.mts | 1 + 2 files changed, 26 insertions(+) create mode 100644 src/actions/core/delay-action.mts diff --git a/src/actions/core/delay-action.mts b/src/actions/core/delay-action.mts new file mode 100644 index 0000000..d9ff013 --- /dev/null +++ b/src/actions/core/delay-action.mts @@ -0,0 +1,25 @@ +import {map, noop, timer} from 'rxjs'; +import {InternalCategory} from '../../lib/registries/action-registry.mjs'; +import {defineLocalAction} from '../../lib/util/define-local.mjs'; + +interface Props { + duration: number; +} + +defineLocalAction({ + category: InternalCategory.CORE, + execute: ({duration}) => timer(duration).pipe(map(noop)), + label: 'Wait', + localID: 'wait', + media: cdnMedia('assets/media/main/timer.svg'), + options: [ + { + description: 'Wait for the given number of milliseconds. The actual wait may be significantly longer if the game is minimised in the browser.', + label: 'Duration', + localID: 'duration', + min: 0, + required: true, + type: Number, + }, + ], +}); diff --git a/src/actions/core/index.mts b/src/actions/core/index.mts index bdc8659..b65586d 100644 --- a/src/actions/core/index.mts +++ b/src/actions/core/index.mts @@ -1,5 +1,6 @@ import '../../option-types/option-types.mjs'; import './buy-item-action.mjs'; +import './delay-action.mjs'; import './equip-item-action.mjs'; import './sell-item-action.mjs'; import './set-step-idx-action.mjs';