Add resource performance values

This commit is contained in:
2020-04-17 22:00:47 +03:00
parent 1ce79092bd
commit 8ef3c60d46
8 changed files with 174 additions and 42 deletions

View File

@ -1,4 +1,4 @@
import { Coordinates, Village, VillageList } from '../Game';
import { Coordinates, Resources, Village, VillageList } from '../Game';
import { GrabError } from '../Errors';
import * as URLParse from 'url-parse';
import { getNumber } from '../utils';
@ -56,3 +56,19 @@ function grabVillageInfo($el): Village {
);
return new Village(id, name, active, new Coordinates(x, y));
}
export function grabResourcesPerformance(): Resources {
const $el = jQuery('#production');
if ($el.length !== 1) {
throw new GrabError();
}
const $nums = $el.find('td.num');
return new Resources(
getNumber($nums.get(0).innerText),
getNumber($nums.get(1).innerText),
getNumber($nums.get(2).innerText),
getNumber($nums.get(3).innerText)
);
}