Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 3x 3x 3x 3x 3x 3x 3x | /**
* @module Engine.Commands
* Commands Tools
*/
import { MotdCommand, MoveCommand } from '@commands/index';
import { RunCommands } from '@engine/Commands/tasks';
import { Command, CommandList } from './Command';
export const commandsTemplates = (command: CommandList, payload: any) => {
let template = {} as Command;
switch (command) {
case CommandList.move:
template = new MoveCommand(payload);
break;
case CommandList.motd:
template = new MotdCommand(payload);
break;
default:
break;
}
return template;
};
export const addCommandAction = (command: CommandList, payload: any) => {
console.log({ command, payload });
RunCommands.queueCommand.push(commandsTemplates(command, payload));
};
export const addCommandUpdate = (command: CommandList, payload: any, callback?) => {
const current = commandsTemplates(command, payload);
RunCommands.resolveCommand(current, callback);
};
export const addLazyCommand = (command: Command) => {
if (RunCommands.queueCommand.length() > 0) {
RunCommands.lazyCommands = RunCommands.lazyCommands.push(command);
} else {
RunCommands.queueCommand.push(command);
}
};
|