Improve unit training

This commit is contained in:
2020-05-09 20:44:07 +03:00
parent ea4deb6323
commit 0798e1dc3f
4 changed files with 72 additions and 68 deletions

View File

@ -1,17 +1,15 @@
import { TaskController } from './TaskController';
import { ActionDefinition, TaskController } from './TaskController';
import { GoToPageAction } from '../Action/GoToPageAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
import { TrainTrooperAction } from '../Action/TrainTrooperAction';
import { Action } from '../Queue/ActionQueue';
import { Args } from '../Queue/Args';
import { Task } from '../Queue/TaskProvider';
import { path } from '../Helpers/Path';
import { registerTask, TaskType } from './TaskMap';
@registerTask({ type: TaskType.TrainUnit })
export class TrainTroopTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.args, taskId: task.id };
defineActions(task: Task): Array<ActionDefinition> {
const args = task.args;
const pathArgs = {
newdid: args.villageId,
@ -20,10 +18,10 @@ export class TrainTroopTask extends TaskController {
s: args.sheetId,
};
this.scheduler.scheduleActions([
new Action(GoToPageAction.name, { ...args, path: path('/build.php', pathArgs) }),
new Action(TrainTrooperAction.name, args),
new Action(CompleteTaskAction.name, args),
]);
return [
[GoToPageAction.name, { path: path('/build.php', pathArgs) }],
[TrainTrooperAction.name],
[CompleteTaskAction.name],
];
}
}