Improve hero village detection
This commit is contained in:
parent
3f4534a72e
commit
2137e7e684
@ -4,6 +4,7 @@ import { Task } from '../Queue/TaskQueue';
|
|||||||
import { grabVillageList } from '../Page/VillageBlock';
|
import { grabVillageList } from '../Page/VillageBlock';
|
||||||
import { grabHeroVillage } from '../Page/HeroPage';
|
import { grabHeroVillage } from '../Page/HeroPage';
|
||||||
import { path } from '../utils';
|
import { path } from '../utils';
|
||||||
|
import { HeroState } from '../State/HeroState';
|
||||||
|
|
||||||
@registerAction
|
@registerAction
|
||||||
export class GoToHeroVillageAction extends ActionController {
|
export class GoToHeroVillageAction extends ActionController {
|
||||||
@ -24,6 +25,6 @@ export class GoToHeroVillageAction extends ActionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return new HeroState().getVillageId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,10 @@ function heroResourceTypeToNumber(type: HeroResourceType): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function grabHeroVillage(): string | undefined {
|
export function grabHeroVillage(): string | undefined {
|
||||||
const status = jQuery('.heroStatusMessage').text();
|
const statusSpan = jQuery('.heroStatusMessage span:not(.titleExtra)');
|
||||||
const hrefText = jQuery('.heroStatusMessage a').text();
|
const statusText = statusSpan.text();
|
||||||
if (status.toLowerCase().includes('в родной деревне')) {
|
const hrefText = statusSpan.find('a').text();
|
||||||
|
if (statusText.toLowerCase().includes('в родной деревне')) {
|
||||||
return hrefText || undefined;
|
return hrefText || undefined;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -42,4 +42,13 @@ describe('HeroBalance', function() {
|
|||||||
const heroRes = calcHeroResource(current, required, totalRequired, storage);
|
const heroRes = calcHeroResource(current, required, totalRequired, storage);
|
||||||
expect(ResourceType.Iron).to.equals(heroRes);
|
expect(ResourceType.Iron).to.equals(heroRes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Get resource if enough, but total not enough', function() {
|
||||||
|
const current = new Resources(300, 300, 300, 300);
|
||||||
|
const required = new Resources(100, 100, 100, 100);
|
||||||
|
const totalRequired = new Resources(500, 600, 200, 200);
|
||||||
|
const storage = new ResourceStorage(1000, 1000);
|
||||||
|
const heroRes = calcHeroResource(current, required, totalRequired, storage);
|
||||||
|
expect(ResourceType.Clay).to.equals(heroRes);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user