Add multiple village support

This commit is contained in:
2020-04-10 18:32:51 +03:00
parent bf7f4c1b7d
commit 3a673ac334
11 changed files with 120 additions and 72 deletions

View File

@ -3,18 +3,24 @@ 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';
import { path } from '../utils';
@registerTask
export class BalanceHeroResourcesTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.cmd.args, taskId: task.id };
const args: Args = { ...task.args, taskId: task.id };
this.scheduler.scheduleActions([
new Command(GoToPageAction.name, { ...args, path: '/dorf1.php' }),
new Command(GoToPageAction.name, {
...args,
path: path('/dorf1.php'),
}),
new Command(GrabVillageResourcesAction.name, args),
new Command(GoToPageAction.name, { ...args, path: 'hero.php' }),
new Command(GoToPageAction.name, {
...args,
path: path('/hero.php'),
}),
new Command(BalanceHeroResourcesAction.name, args),
new Command(CompleteTaskAction.name, args),
]);

View File

@ -6,17 +6,21 @@ import { GrabHeroAttributesAction } from '../Action/GrabHeroAttributesAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
import { SendOnAdventureAction } from '../Action/SendOnAdventureAction';
import { ClickButtonAction } from '../Action/ClickButtonAction';
import { path } from '../utils';
@registerTask
export class SendOnAdventureTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.cmd.args, taskId: task.id };
const args: Args = { ...task.args, taskId: task.id };
this.scheduler.scheduleActions([
new Command(GoToPageAction.name, { ...args, path: 'hero.php' }),
new Command(GoToPageAction.name, {
...args,
path: path('/hero.php'),
}),
new Command(GrabHeroAttributesAction.name, args),
new Command(GoToPageAction.name, {
...args,
path: '/hero.php?t=3',
path: path('/hero.php', { t: 3 }),
}),
new Command(SendOnAdventureAction.name, args),
new Command(ClickButtonAction.name, {

View File

@ -4,13 +4,17 @@ import { TaskController, registerTask } from './TaskController';
import { GoToPageAction } from '../Action/GoToPageAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
import { TrainTrooperAction } from '../Action/TrainTrooperAction';
import { path } from '../utils';
@registerTask
export class TrainTroopTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.cmd.args, taskId: task.id };
const args: Args = { ...task.args, taskId: task.id };
this.scheduler.scheduleActions([
new Command(GoToPageAction.name, { ...args, path: '/build.php?id=' + args.buildId }),
new Command(GoToPageAction.name, {
...args,
path: path('/build.php', { newdid: args.villageId, id: args.buildId }),
}),
new Command(TrainTrooperAction.name, args),
new Command(CompleteTaskAction.name, args),
]);

View File

@ -5,17 +5,21 @@ import { TaskController, registerTask } from './TaskController';
import { GoToPageAction } from '../Action/GoToPageAction';
import { CheckBuildingRemainingTimeAction } from '../Action/CheckBuildingRemainingTimeAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
import { path } from '../utils';
@registerTask
export class UpgradeBuildingTask extends TaskController {
async run(task: Task) {
const args: Args = { ...task.cmd.args, taskId: task.id };
const args: Args = { ...task.args, taskId: task.id };
this.scheduler.scheduleActions([
new Command(GoToPageAction.name, { ...args, path: '/dorf1.php' }),
new Command(GoToPageAction.name, {
...args,
path: path('/dorf1.php', { newdid: args.villageId }),
}),
new Command(CheckBuildingRemainingTimeAction.name, args),
new Command(GoToPageAction.name, {
...args,
path: '/build.php?id=' + args.id,
path: path('/build.php', { newdid: args.villageId, id: args.buildId }),
}),
new Command(UpgradeBuildingAction.name, args),
new Command(CompleteTaskAction.name, args),