Add hero resource switch

This commit is contained in:
2020-04-04 15:41:18 +03:00
parent 6e85f9f443
commit d85490958b
8 changed files with 151 additions and 13 deletions

View File

@ -0,0 +1,22 @@
import { Args, Command } from '../Common';
import { Task } from '../Storage/TaskQueue';
import { TaskController, registerTask } from './TaskController';
import { GoToPageAction } from '../Action/GoToPageAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
import { TrainTrooperAction } from '../Action/TrainTrooperAction';
import { GrabVillageResourcesAction } from '../Action/GrabVillageResourcesAction';
import { BalanceHeroResourcesAction } from '../Action/BalanceHeroResourcesAction';
@registerTask
export class BalanceHeroResourcesTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.cmd.args, taskId: task.id };
this.scheduler.scheduleActions([
new Command(GoToPageAction.name, { ...args, path: '/dorf1.php' }),
new Command(GrabVillageResourcesAction.name, args),
new Command(GoToPageAction.name, { ...args, path: 'hero.php' }),
new Command(BalanceHeroResourcesAction.name, args),
new Command(CompleteTaskAction.name, args),
]);
}
}

View File

@ -4,7 +4,6 @@ import { Scheduler } from '../Scheduler';
const taskMap: { [name: string]: Function | undefined } = {};
export function registerTask(constructor: Function) {
console.log('REGISTER TASK', constructor.name);
taskMap[constructor.name] = constructor;
}