Refactored actions, 'cast a spell' task now works

This commit is contained in:
Thaum Rystra
2024-10-28 12:28:36 +02:00
parent 804c5f3aee
commit 8f8c9c28aa
39 changed files with 423 additions and 399 deletions

View File

@@ -1,16 +1,24 @@
import { CheckParams } from '/imports/api/engine/action/functions/userInput/InputProvider';
type Task = PropTask | DamagePropTask | ItemAsAmmoTask | CheckTask | ResetTask;
type Task = PropTask | DamagePropTask | ItemAsAmmoTask | CheckTask | ResetTask | CastSpellTask;
export default Task;
type BaseTask = {
prop: { type: string, [key: string]: any };
targetIds: string[];
silent?: boolean | undefined;
}
type Prop = {
_id: string;
type: string;
[key: string]: any,
}
export type PropTask = BaseTask & {
subtaskFn?: undefined,
prop: Prop;
subtaskFn?: undefined;
silent?: undefined;
}
export type DamagePropTask = BaseTask & {
@@ -22,12 +30,14 @@ export type DamagePropTask = BaseTask & {
title?: string;
operation: 'increment' | 'set';
value: number;
targetProp: any;
targetProp: Prop;
};
}
export type ItemAsAmmoTask = BaseTask & {
subtaskFn: 'consumeItemAsAmmo';
prop: Prop;
silent?: undefined;
params: {
value: number;
item: any;
@@ -40,8 +50,17 @@ export type CheckTask = BaseTask & CheckParams & {
}
export type ResetTask = BaseTask & {
subtaskFn: 'reset',
subtaskFn: 'reset';
eventName: string;
// One and only one target
targetIds: [string];
}
export type CastSpellTask = BaseTask & {
prop?: Prop | undefined;
silent?: undefined;
subtaskFn: 'castSpell';
params: {
spellId: string | undefined;
};
}