Store incoming merchants

This commit is contained in:
2020-04-25 12:01:07 +03:00
parent 6bd04ee6e2
commit f005072d9c
13 changed files with 227 additions and 52 deletions

View File

@ -2,6 +2,7 @@ import { Grabber } from './Grabber';
import { VillageResourceGrabber } from './VillageResourceGrabber';
import { VillageOverviewPageGrabber } from './VillageOverviewPageGrabber';
import { HeroPageGrabber } from './HeroPageGrabber';
import { MarketPageGrabber } from './MarketPageGrabber';
export class GrabberManager {
private readonly grabbers: Array<Grabber> = [];
@ -11,6 +12,7 @@ export class GrabberManager {
this.grabbers.push(new VillageResourceGrabber());
this.grabbers.push(new VillageOverviewPageGrabber());
this.grabbers.push(new HeroPageGrabber());
this.grabbers.push(new MarketPageGrabber());
}
grab() {

View File

@ -1,21 +1,12 @@
import { Grabber } from './Grabber';
import {
grabActiveVillageId,
grabBuildingQueueInfo,
grabResourcesPerformance,
grabVillageList,
} from '../Page/VillageBlock';
import { VillageState } from '../State/VillageState';
import { parseLocation } from '../utils';
import { GrabError } from '../Errors';
import { BuildingQueueInfo } from '../Game';
import { grabVillageList } from '../Page/VillageBlock';
import { HeroState } from '../State/HeroState';
import { grabHeroAttributes, grabHeroVillage } from '../Page/HeroPage';
import { isHeroPage } from '../Page/PageDetectors';
export class HeroPageGrabber extends Grabber {
grab(): void {
const p = parseLocation();
if (p.pathname !== '/hero.php') {
if (!isHeroPage()) {
return;
}

View File

@ -0,0 +1,17 @@
import { Grabber } from './Grabber';
import { grabActiveVillageId } from '../Page/VillageBlock';
import { VillageState } from '../State/VillageState';
import { grabIncomingMerchants } from '../Page/BuildingPage';
import { isMarketSendResourcesPage } from '../Page/PageDetectors';
export class MarketPageGrabber extends Grabber {
grab(): void {
if (!isMarketSendResourcesPage()) {
return;
}
const villageId = grabActiveVillageId();
const state = new VillageState(villageId);
state.storeIncomingMerchants(grabIncomingMerchants());
}
}