Add ability to check building queue

This commit is contained in:
2020-04-02 10:57:21 +03:00
parent cd2bc8d7fb
commit 473e3572e3
7 changed files with 62 additions and 56 deletions

View File

@ -0,0 +1,21 @@
import ActionController from './ActionController';
import { Args } from '../Common';
import { Task } from '../Storage/TaskQueue';
import { TryLaterError } from '../Errors';
export default class CheckBuildingRemainingTimeAction extends ActionController {
static NAME = 'check_building_remaining_time';
async run(args: Args, task: Task): Promise<any> {
const timer = jQuery('.buildDuration .timer');
if (timer.length === 1) {
const remainingSeconds = Number(timer.attr('value'));
if (remainingSeconds > 0) {
throw new TryLaterError(
remainingSeconds + 1,
'Building queue is full'
);
}
}
}
}

View File

@ -2,9 +2,9 @@ import ActionController from './ActionController';
import { Args } from '../Common';
import { Task } from '../Storage/TaskQueue';
export default class GoToResourceFieldsAction extends ActionController {
static NAME = 'go_to_resource_fields';
export default class GoToPageAction extends ActionController {
static NAME = 'go_to_page';
async run(args: Args, task: Task): Promise<any> {
window.location.assign('/dorf1.php');
window.location.assign(args.path);
}
}

View File

@ -1,15 +0,0 @@
import ActionController from './ActionController';
import { Args } from '../Common';
import { Task } from '../Storage/TaskQueue';
export default class StoreRemainingBuildTimeAction extends ActionController {
static NAME = 'store_remaining_build_time';
async run(args: Args, task: Task): Promise<any> {
const timer = jQuery('.buildDuration .timer');
// if (timer.length === 1) {
// const remainingSeconds = +timer.val();
// }
return null;
}
}