Improvements

This commit is contained in:
2020-03-29 21:22:38 +03:00
parent c980abfc63
commit e215b5ca93
7 changed files with 95 additions and 18 deletions

View File

@ -1,7 +0,0 @@
import Action from './Action';
export default class GoToMainAction extends Action {
async run(): Promise<any> {
return Promise.resolve(null);
}
}

View File

@ -0,0 +1,8 @@
import Action from './Action';
export default class GoToResourceFieldsAction extends Action {
static NAME = 'go_to_resource_fields';
async run(): Promise<any> {
window.location.assign('/dorf1.php');
}
}

View File

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

View File

@ -1,19 +1,26 @@
import Action from './Action';
import { Args } from '../Common';
import { TryLaterError } from '../Errors';
import Scheduler from '../Scheduler';
export default class UpgradeBuildingAction extends Action {
static NAME = 'upgrade_building';
private scheduler: Scheduler;
constructor(scheduler: Scheduler) {
super();
this.scheduler = scheduler;
}
async run(args: Args): Promise<any> {
const btn = jQuery(
'.upgradeButtonsContainer .section1 button.green.build'
);
if (btn.length === 1) {
this.scheduler.completeCurrentTask();
btn.trigger('click');
} else {
console.log('NO UPGRADE BUTTON');
throw new TryLaterError(60);
throw new TryLaterError(60, 'No upgrade button, try later');
}
return null;
}