Add hero adventures task
This commit is contained in:
41
src/Task/SendOnAdventureTask.ts
Normal file
41
src/Task/SendOnAdventureTask.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import Scheduler from '../Scheduler';
|
||||
import { Args, Command } from '../Common';
|
||||
import { Task } from '../Storage/TaskQueue';
|
||||
import TaskController from './TaskController';
|
||||
import GoToPageAction from '../Action/GoToPageAction';
|
||||
import GrabHeroAttributesAction from '../Action/GrabHeroAttributesAction';
|
||||
import CompleteTaskAction from '../Action/CompleteTaskAction';
|
||||
import SendOnAdventureAction from '../Action/SendOnAdventureAction';
|
||||
import ClickButtonAction from '../Action/ClickButtonAction';
|
||||
|
||||
export default class SendOnAdventureTask extends TaskController {
|
||||
static NAME = 'send_on_adventure';
|
||||
private scheduler: Scheduler;
|
||||
|
||||
constructor(scheduler: Scheduler) {
|
||||
super();
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
name(): string {
|
||||
return SendOnAdventureTask.NAME;
|
||||
}
|
||||
|
||||
run(task: Task) {
|
||||
const args: Args = { ...task.cmd.args, taskId: task.id };
|
||||
this.scheduler.scheduleActions([
|
||||
new Command(GoToPageAction.NAME, { ...args, path: 'hero.php' }),
|
||||
new Command(GrabHeroAttributesAction.NAME, args),
|
||||
new Command(GoToPageAction.NAME, {
|
||||
...args,
|
||||
path: '/hero.php?t=3',
|
||||
}),
|
||||
new Command(SendOnAdventureAction.NAME, args),
|
||||
new Command(ClickButtonAction.NAME, {
|
||||
...args,
|
||||
selector: '.adventureSendButton button',
|
||||
}),
|
||||
new Command(CompleteTaskAction.NAME, args),
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import { Task } from '../Storage/TaskQueue';
|
||||
|
||||
export default abstract class TaskController {
|
||||
abstract name(): string;
|
||||
abstract run(task: Task);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { Task } from '../Storage/TaskQueue';
|
||||
import TaskController from './TaskController';
|
||||
import GoToPageAction from '../Action/GoToPageAction';
|
||||
import CheckBuildingRemainingTimeAction from '../Action/CheckBuildingRemainingTimeAction';
|
||||
import CompleteTaskAction from '../Action/CompleteTaskAction';
|
||||
|
||||
export default class UpgradeBuildingTask extends TaskController {
|
||||
static NAME = 'upgrade_building';
|
||||
@ -15,6 +16,10 @@ export default class UpgradeBuildingTask extends TaskController {
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
name(): string {
|
||||
return UpgradeBuildingTask.NAME;
|
||||
}
|
||||
|
||||
run(task: Task) {
|
||||
console.log('RUN', UpgradeBuildingTask.NAME, 'with', task);
|
||||
const args: Args = { ...task.cmd.args, taskId: task.id };
|
||||
@ -26,6 +31,7 @@ export default class UpgradeBuildingTask extends TaskController {
|
||||
path: '/build.php?id=' + args.id,
|
||||
}),
|
||||
new Command(UpgradeBuildingAction.NAME, args),
|
||||
new Command(CompleteTaskAction.NAME, args),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user