Change hero balance action

Target - required by next build resources
This commit is contained in:
2020-04-18 18:56:32 +03:00
parent 236135f1ca
commit 809b54e0b9
9 changed files with 172 additions and 27 deletions

View File

@ -0,0 +1,35 @@
import { Args, Command } from '../Common';
import { Task } from '../Storage/TaskQueue';
import { TaskController, registerTask } from './TaskController';
import { GoToPageAction } from '../Action/GoToPageAction';
import { path } from '../utils';
import { UpgradeBuildingTask } from './UpgradeBuildingTask';
import { UpdateBuildingTaskResourcesAction } from '../Action/UpdateBuildingTaskResourcesAction';
import { CompleteTaskAction } from '../Action/CompleteTaskAction';
@registerTask
export class UpdateResourceContracts extends TaskController {
async run(task: Task) {
const args: Args = { ...task.args, taskId: task.id };
const actions: Array<Command> = [];
const tasks = this.scheduler.getTaskItems();
for (let task of tasks) {
const { villageId, buildId } = task.args;
if (task.name === UpgradeBuildingTask.name && villageId && buildId) {
actions.push(
new Command(GoToPageAction.name, {
...args,
path: path('/build.php', { newdid: villageId, id: buildId }),
})
);
actions.push(new Command(UpdateBuildingTaskResourcesAction.name, { ...args, taskId: task.id }));
}
}
actions.push(new Command(CompleteTaskAction.name, args));
this.scheduler.scheduleActions(actions);
}
}