import { BaseAction } from './BaseAction'; import { GrabError, TryLaterError } from '../../Errors'; import { clickUpgradeButton } from '../../Page/BuildingPage/BuildingPage'; import { Args } from '../../Queue/Args'; import { Task } from '../../Queue/TaskProvider'; import { aroundMinutes } from '../../Helpers/Time'; import { registerAction } from '../ActionMap'; @registerAction export class UpgradeBuildingAction extends BaseAction { async run(args: Args, task: Task): Promise { try { this.ensureSameVillage(args); clickUpgradeButton(); } catch (e) { if (e instanceof GrabError) { throw new TryLaterError(aroundMinutes(5), 'No upgrade button, try later'); } throw e; } } }