First attempt to resource sending

This commit is contained in:
2020-04-24 10:45:05 +03:00
parent 542bc353b0
commit fb4ac6424c
25 changed files with 437 additions and 74 deletions

View File

@ -0,0 +1,31 @@
import { Args, Command } from '../Command';
import { Task } from '../Queue/TaskQueue';
import { TaskController, registerTask } from './TaskController';
import { GoToPageAction } from '../Action/GoToPageAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
import { path } from '../utils';
import { SendResourcesAction } from '../Action/SendResourcesAction';
import { ClickButtonAction } from '../Action/ClickButtonAction';
@registerTask
export class SendResourcesTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.args, taskId: task.id };
const pathArgs = {
newdid: args.villageId,
gid: args.buildTypeId || undefined,
id: args.buildId || undefined,
t: args.tabId,
};
const pagePath = path('/build.php', pathArgs);
this.scheduler.scheduleActions([
new Command(GoToPageAction.name, { ...args, path: pagePath }),
new Command(SendResourcesAction.name, args),
new Command(ClickButtonAction.name, { ...args, selector: '#enabledButton.green.sendRessources' }),
new Command(CompleteTaskAction.name, args),
]);
}
}

View File

@ -15,7 +15,7 @@ export class TrainTroopTask extends TaskController {
newdid: args.villageId,
gid: args.buildTypeId || undefined,
id: args.buildId || undefined,
s: args.tabId,
s: args.sheetId,
};
const pagePath = path('/build.php', pathArgs);