Files
DiceCloud/app/imports/api/engine/action/tasks/Task.ts
2024-05-14 10:02:54 +02:00

48 lines
969 B
TypeScript

import { CheckParams } from '/imports/api/engine/action/functions/userInput/InputProvider';
type Task = PropTask | DamagePropTask | ItemAsAmmoTask | CheckTask | ResetTask;
export default Task;
type BaseTask = {
prop: { type: string, [key: string]: any };
targetIds: string[];
}
export type PropTask = BaseTask & {
subtaskFn?: undefined,
}
export type DamagePropTask = BaseTask & {
subtaskFn: 'damageProp';
params: {
/**
* Use getPropertyTitle(prop) to set the title
*/
title?: string;
operation: 'increment' | 'set';
value: number;
targetProp: any;
};
}
export type ItemAsAmmoTask = BaseTask & {
subtaskFn: 'consumeItemAsAmmo';
params: {
value: number;
item: any;
skipChildren: boolean;
};
}
export type CheckTask = BaseTask & CheckParams & {
subtaskFn: 'check';
}
export type ResetTask = BaseTask & {
subtaskFn: 'reset',
eventName: string;
// One and only one target
targetIds: [string];
}