Change task id generation
Id must be generated sequentially
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { ActionController, registerAction } from './ActionController';
|
||||
import { Args } from '../Common';
|
||||
import { Task } from '../Storage/TaskQueue';
|
||||
import { BuildingQueueFullError, GrabError } from '../Errors';
|
||||
import { PostponeAllBuildingsError, GrabError } from '../Errors';
|
||||
import { grabActiveVillageId, grabBuildingQueueInfo } from '../Page/VillageBlock';
|
||||
import { BuildingQueueInfo } from '../Game';
|
||||
|
||||
@ -10,7 +10,7 @@ export class CheckBuildingRemainingTimeAction extends ActionController {
|
||||
async run(args: Args, task: Task): Promise<any> {
|
||||
const info = this.grabBuildingQueueInfoOrDefault();
|
||||
if (info.seconds > 0) {
|
||||
throw new BuildingQueueFullError(
|
||||
throw new PostponeAllBuildingsError(
|
||||
task.id,
|
||||
grabActiveVillageId(),
|
||||
info.seconds + 1,
|
||||
|
@ -1,17 +1,22 @@
|
||||
import { ActionController, registerAction } from './ActionController';
|
||||
import { Args } from '../Common';
|
||||
import { GrabError, TryLaterError } from '../Errors';
|
||||
import { ActionError, GrabError, PostponeAllBuildingsError } from '../Errors';
|
||||
import { Task } from '../Storage/TaskQueue';
|
||||
import { clickUpgradeButton } from '../Page/BuildingPage';
|
||||
|
||||
@registerAction
|
||||
export class UpgradeBuildingAction extends ActionController {
|
||||
async run(args: Args, task: Task): Promise<any> {
|
||||
let villageId = args.villageId;
|
||||
if (villageId === undefined) {
|
||||
throw new ActionError(task.id, 'No village id');
|
||||
}
|
||||
|
||||
try {
|
||||
clickUpgradeButton();
|
||||
} catch (e) {
|
||||
if (e instanceof GrabError) {
|
||||
throw new TryLaterError(task.id, 15 * 60, 'No upgrade button, try later');
|
||||
throw new PostponeAllBuildingsError(task.id, villageId, 15 * 60, 'No upgrade button, try later');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
Reference in New Issue
Block a user