Fix insert build tasks, so order is matter

This commit is contained in:
2020-04-18 15:33:32 +03:00
parent db16c54137
commit 57ccf14553
11 changed files with 134 additions and 26 deletions

View File

@ -2,6 +2,8 @@ import { StateGrabber } from './StateGrabber';
import { grabActiveVillageId, grabBuildingQueueInfo, grabResourcesPerformance } from '../Page/VillageBlock';
import { VillageState } from './VillageState';
import { parseLocation } from '../utils';
import { GrabError } from '../Errors';
import { BuildingQueueInfo } from '../Game';
export class VillageOverviewPageGrabber extends StateGrabber {
grab(): void {
@ -13,6 +15,17 @@ export class VillageOverviewPageGrabber extends StateGrabber {
const villageId = grabActiveVillageId();
const state = new VillageState(villageId);
state.storeResourcesPerformance(grabResourcesPerformance());
state.storeBuildingQueueInfo(grabBuildingQueueInfo());
state.storeBuildingQueueInfo(this.grabBuildingQueueInfoOrDefault());
}
private grabBuildingQueueInfoOrDefault() {
try {
return grabBuildingQueueInfo();
} catch (e) {
if (e instanceof GrabError) {
return new BuildingQueueInfo(0);
}
throw e;
}
}
}