Rewrite task queue
This commit is contained in:
5
src/Task/TaskController.ts
Normal file
5
src/Task/TaskController.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { Task } from '../Storage/TaskQueue';
|
||||
|
||||
export default abstract class TaskController {
|
||||
abstract run(task: Task);
|
||||
}
|
@ -1,18 +1,22 @@
|
||||
import Scheduler from '../Scheduler';
|
||||
import GoToBuildingAction from '../Action/GoToBuildingAction';
|
||||
import UpgradeBuildingAction from '../Action/UpgradeBuildingAction';
|
||||
import { Args, Command } from '../Common';
|
||||
import { Command } from '../Common';
|
||||
import { Task } from '../Storage/TaskQueue';
|
||||
import TaskController from './TaskController';
|
||||
|
||||
export default class UpgradeBuildingTask {
|
||||
export default class UpgradeBuildingTask extends TaskController {
|
||||
static NAME = 'upgrade_building';
|
||||
private scheduler: Scheduler;
|
||||
|
||||
constructor(scheduler: Scheduler) {
|
||||
super();
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
run(args: Args) {
|
||||
console.log('RUN', UpgradeBuildingTask.NAME, 'with', args);
|
||||
run(task: Task) {
|
||||
console.log('RUN', UpgradeBuildingTask.NAME, 'with', task);
|
||||
const args = { ...task.cmd.args, taskId: task.id };
|
||||
this.scheduler.scheduleActions([
|
||||
new Command(GoToBuildingAction.NAME, args),
|
||||
new Command(UpgradeBuildingAction.NAME, args),
|
||||
|
Reference in New Issue
Block a user