diff --git a/package.json b/package.json
index 22f2d3c..914bba4 100644
--- a/package.json
+++ b/package.json
@@ -15,10 +15,10 @@
"coverage": "nyc mocha",
"build:dev": "webpack",
"build": "webpack --env.production",
- "format": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --quote-props consistent --write '{src,tests}/**/*.{ts,js}'",
- "format-check": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --quote-props consistent --check '{src,tests}/**/*.{ts,js}'",
- "format-vue": "prettier --tab-width=2 --print-width 120 --single-quote --trailing-comma es5 --quote-props consistent --write '{src,tests}/**/*.vue'",
- "format-wp": "prettier --tab-width=4 --print-width 120 --single-quote --trailing-comma es5 --quote-props consistent --write 'webpack.config.js'"
+ "format": "prettier --tab-width=4 --print-width 100 --single-quote --trailing-comma es5 --quote-props consistent --write '{src,tests}/**/*.{ts,js}'",
+ "format-check": "prettier --tab-width=4 --print-width 100 --single-quote --trailing-comma es5 --quote-props consistent --check '{src,tests}/**/*.{ts,js}'",
+ "format-vue": "prettier --tab-width=2 --print-width 100 --single-quote --trailing-comma es5 --quote-props consistent --write '{src,tests}/**/*.vue'",
+ "format-wp": "prettier --tab-width=4 --print-width 100 --single-quote --trailing-comma es5 --quote-props consistent --write 'webpack.config.js'"
},
"devDependencies": {
"@types/chai": "^4.2.11",
diff --git a/src/Action/FindSendResourcesPath.ts b/src/Action/FindSendResourcesPath.ts
index 6428437..f0f895a 100644
--- a/src/Action/FindSendResourcesPath.ts
+++ b/src/Action/FindSendResourcesPath.ts
@@ -40,7 +40,11 @@ export class FindSendResourcesPath extends ActionController {
const storage = new ResourceTransferStorage();
storage.storeReport(bestReport);
- const marketPath = path('/build.php', { newdid: bestReport.fromVillageId, gid: MARKET_ID, t: 5 });
+ const marketPath = path('/build.php', {
+ newdid: bestReport.fromVillageId,
+ gid: MARKET_ID,
+ t: 5,
+ });
window.location.assign(marketPath);
}
}
diff --git a/src/Action/TrainTrooperAction.ts b/src/Action/TrainTrooperAction.ts
index f2fc8d7..e186265 100644
--- a/src/Action/TrainTrooperAction.ts
+++ b/src/Action/TrainTrooperAction.ts
@@ -3,7 +3,11 @@ import { taskError, TryLaterError } from '../Errors';
import { aroundMinutes, randomInRange } from '../utils';
import { Args } from '../Queue/Args';
import { Task } from '../Queue/TaskProvider';
-import { clickTrainButton, fillTrainCount, getAvailableCount } from '../Page/BuildingPage/TrooperPage';
+import {
+ clickTrainButton,
+ fillTrainCount,
+ getAvailableCount,
+} from '../Page/BuildingPage/TrooperPage';
import { TrainTroopTask } from '../Task/TrainTroopTask';
import { Resources } from '../Core/Resources';
diff --git a/src/Action/UpgradeResourceToLevel.ts b/src/Action/UpgradeResourceToLevel.ts
index 09aa7e0..32c8195 100644
--- a/src/Action/UpgradeResourceToLevel.ts
+++ b/src/Action/UpgradeResourceToLevel.ts
@@ -19,7 +19,9 @@ export class UpgradeResourceToLevel extends ActionController {
const requiredLevel = getNumber(args.level);
- const notUpgraded = deposits.filter(dep => !dep.underConstruction && requiredLevel > dep.level);
+ const notUpgraded = deposits.filter(
+ dep => !dep.underConstruction && requiredLevel > dep.level
+ );
if (notUpgraded.length === 0) {
this.scheduler.removeTask(task.id);
@@ -34,11 +36,17 @@ export class UpgradeResourceToLevel extends ActionController {
const secondNotUpgraded = notUpgraded.shift();
if (firstNotUpgraded && this.isTaskNotInQueue(villageId, firstNotUpgraded)) {
- this.scheduler.scheduleTask(UpgradeBuildingTask.name, { villageId, buildId: firstNotUpgraded.buildId });
+ this.scheduler.scheduleTask(UpgradeBuildingTask.name, {
+ villageId,
+ buildId: firstNotUpgraded.buildId,
+ });
}
if (secondNotUpgraded && this.isTaskNotInQueue(villageId, secondNotUpgraded)) {
- this.scheduler.scheduleTask(UpgradeBuildingTask.name, { villageId, buildId: secondNotUpgraded.buildId });
+ this.scheduler.scheduleTask(UpgradeBuildingTask.name, {
+ villageId,
+ buildId: secondNotUpgraded.buildId,
+ });
}
throw new TryLaterError(aroundMinutes(10), 'Sleep for next round');
diff --git a/src/Core/GatheringTimings.ts b/src/Core/GatheringTimings.ts
index d7d5885..4125548 100644
--- a/src/Core/GatheringTimings.ts
+++ b/src/Core/GatheringTimings.ts
@@ -53,7 +53,12 @@ export class GatheringTimings {
return new GatheringTimings(factory(lumber), factory(clay), factory(iron), factory(crop));
}
- constructor(lumber: GatheringTime, clay: GatheringTime, iron: GatheringTime, crop: GatheringTime) {
+ constructor(
+ lumber: GatheringTime,
+ clay: GatheringTime,
+ iron: GatheringTime,
+ crop: GatheringTime
+ ) {
this.lumber = lumber;
this.clay = clay;
this.iron = iron;
@@ -97,7 +102,11 @@ function calcGatheringTime(val: number, desired: number, speed: number): Gatheri
return GatheringTime.makeCounting((diff / speed) * 3600);
}
-export function calcGatheringTimings(resources: Resources, desired: Resources, speed: Resources): GatheringTimings {
+export function calcGatheringTimings(
+ resources: Resources,
+ desired: Resources,
+ speed: Resources
+): GatheringTimings {
return new GatheringTimings(
calcGatheringTime(resources.lumber, desired.lumber, speed.lumber),
calcGatheringTime(resources.clay, desired.clay, speed.clay),
diff --git a/src/Core/Resources.ts b/src/Core/Resources.ts
index 4a3fcd3..3463e07 100644
--- a/src/Core/Resources.ts
+++ b/src/Core/Resources.ts
@@ -26,7 +26,12 @@ export class Resources implements ResourcesInterface {
}
static fromStorage(storage: ResourceStorage): Resources {
- return new Resources(storage.warehouse, storage.warehouse, storage.warehouse, storage.granary);
+ return new Resources(
+ storage.warehouse,
+ storage.warehouse,
+ storage.warehouse,
+ storage.granary
+ );
}
static zero(): Resources {
@@ -86,16 +91,29 @@ export class Resources implements ResourcesInterface {
}
anyLower(other: ResourcesInterface): boolean {
- return this.lumber < other.lumber || this.clay < other.clay || this.iron < other.iron || this.crop < other.crop;
+ return (
+ this.lumber < other.lumber ||
+ this.clay < other.clay ||
+ this.iron < other.iron ||
+ this.crop < other.crop
+ );
}
allGreater(other: ResourcesInterface): boolean {
- return this.lumber > other.lumber && this.clay > other.clay && this.iron > other.iron && this.crop > other.crop;
+ return (
+ this.lumber > other.lumber &&
+ this.clay > other.clay &&
+ this.iron > other.iron &&
+ this.crop > other.crop
+ );
}
allGreaterOrEqual(other: ResourcesInterface): boolean {
return (
- this.lumber >= other.lumber && this.clay >= other.clay && this.iron >= other.iron && this.crop >= other.crop
+ this.lumber >= other.lumber &&
+ this.clay >= other.clay &&
+ this.iron >= other.iron &&
+ this.crop >= other.crop
);
}
@@ -136,7 +154,12 @@ export class Resources implements ResourcesInterface {
return (Math.floor(v / multiplier) + 1) * multiplier;
};
- return new Resources(upper(this.lumber), upper(this.clay), upper(this.iron), upper(this.crop));
+ return new Resources(
+ upper(this.lumber),
+ upper(this.clay),
+ upper(this.iron),
+ upper(this.crop)
+ );
}
downTo(multiplier: number): Resources {
@@ -151,6 +174,11 @@ export class Resources implements ResourcesInterface {
return part * multiplier;
};
- return new Resources(lower(this.lumber), lower(this.clay), lower(this.iron), lower(this.crop));
+ return new Resources(
+ lower(this.lumber),
+ lower(this.clay),
+ lower(this.iron),
+ lower(this.crop)
+ );
}
}
diff --git a/src/DashboardView/Header.vue b/src/DashboardView/Header.vue
index 06cac6b..45202f4 100644
--- a/src/DashboardView/Header.vue
+++ b/src/DashboardView/Header.vue
@@ -6,7 +6,11 @@
- pause
+ pause
+
logs
diff --git a/src/DashboardView/Store.ts b/src/DashboardView/Store.ts
index cccf914..ed6726a 100644
--- a/src/DashboardView/Store.ts
+++ b/src/DashboardView/Store.ts
@@ -57,7 +57,8 @@ export function createStore(villageFactory: VillageFactory) {
state.logs = logs;
},
[Mutations.ToggleVillageEditor](state, visible?: any) {
- state.views.villageEditor = visible === undefined ? !state.views.villageEditor : !!visible;
+ state.views.villageEditor =
+ visible === undefined ? !state.views.villageEditor : !!visible;
},
[Mutations.SetVillageSettings](state, settings) {
state.villageSettings = settings;
@@ -90,9 +91,11 @@ export function createStore(villageFactory: VillageFactory) {
const villageName = state.villageSettings.villageName;
const newSettings: VillageSettings = {
sendResourcesThreshold:
- state.villageSettings.sendResourcesThreshold || VillageSettingsDefaults.sendResourcesThreshold,
+ state.villageSettings.sendResourcesThreshold ||
+ VillageSettingsDefaults.sendResourcesThreshold,
sendResourcesTimeout:
- state.villageSettings.sendResourcesTimeout || VillageSettingsDefaults.sendResourcesTimeout,
+ state.villageSettings.sendResourcesTimeout ||
+ VillageSettingsDefaults.sendResourcesTimeout,
sendResourcesMultiplier:
state.villageSettings.sendResourcesMultiplier ||
VillageSettingsDefaults.sendResourcesMultiplier,
diff --git a/src/DashboardView/TaskList.vue b/src/DashboardView/TaskList.vue
index a4a79bb..6d4c52d 100644
--- a/src/DashboardView/TaskList.vue
+++ b/src/DashboardView/TaskList.vue
@@ -9,14 +9,32 @@
diff --git a/src/DashboardView/VillageStateList.vue b/src/DashboardView/VillageStateList.vue
index 95b72de..1c5084e 100644
--- a/src/DashboardView/VillageStateList.vue
+++ b/src/DashboardView/VillageStateList.vue
@@ -15,7 +15,11 @@
-
+ |
{{ villageState.village.name }}
[ред]:
|
@@ -146,12 +150,18 @@
v-if="s.id !== villageState.id"
class="village-quick-link"
:href="marketPath(villageState.village, s.village)"
- :title="'Отправить ресурсы из ' + villageState.village.name + ' в ' + s.village.name"
+ :title="
+ 'Отправить ресурсы из ' + villageState.village.name + ' в ' + s.village.name
+ "
>$->{{ s.village.name }}
Казармы
- Конюшни
- Войска
+ Конюшни
+ Войска
diff --git a/src/Executor.ts b/src/Executor.ts
index a9a0623..ff7435e 100644
--- a/src/Executor.ts
+++ b/src/Executor.ts
@@ -1,5 +1,12 @@
import { markPage, sleepMicro, timestamp, waitForLoad } from './utils';
-import { AbortTaskError, ActionError, FailTaskError, GrabError, TryLaterError, VillageNotFound } from './Errors';
+import {
+ AbortTaskError,
+ ActionError,
+ FailTaskError,
+ GrabError,
+ TryLaterError,
+ VillageNotFound,
+} from './Errors';
import { TaskQueueRenderer } from './TaskQueueRenderer';
import { createActionHandler } from './Action/ActionController';
import { Logger } from './Logger';
diff --git a/src/Grabber/ForgePageGrabber.ts b/src/Grabber/ForgePageGrabber.ts
index c5836a4..7e3c02a 100644
--- a/src/Grabber/ForgePageGrabber.ts
+++ b/src/Grabber/ForgePageGrabber.ts
@@ -30,6 +30,9 @@ export class ForgePageGrabber extends Grabber {
private grabTimer(): void {
const seconds = grabRemainingSeconds();
- this.storage.storeQueueTaskEnding(ProductionQueue.UpgradeUnit, seconds ? seconds + timestamp() : 0);
+ this.storage.storeQueueTaskEnding(
+ ProductionQueue.UpgradeUnit,
+ seconds ? seconds + timestamp() : 0
+ );
}
}
diff --git a/src/Grabber/GuildHallPageGrabber.ts b/src/Grabber/GuildHallPageGrabber.ts
index 60663d8..e3a200e 100644
--- a/src/Grabber/GuildHallPageGrabber.ts
+++ b/src/Grabber/GuildHallPageGrabber.ts
@@ -11,6 +11,9 @@ export class GuildHallPageGrabber extends Grabber {
}
const seconds = grabRemainingSeconds();
- this.storage.storeQueueTaskEnding(ProductionQueue.Celebration, seconds ? seconds + timestamp() : 0);
+ this.storage.storeQueueTaskEnding(
+ ProductionQueue.Celebration,
+ seconds ? seconds + timestamp() : 0
+ );
}
}
diff --git a/src/Grabber/VillageOverviewPageGrabber.ts b/src/Grabber/VillageOverviewPageGrabber.ts
index ee1ebb4..cce3509 100644
--- a/src/Grabber/VillageOverviewPageGrabber.ts
+++ b/src/Grabber/VillageOverviewPageGrabber.ts
@@ -16,7 +16,9 @@ export class VillageOverviewPageGrabber extends Grabber {
this.storage.storeBuildingQueueInfo(this.grabBuildingQueueInfoOrDefault());
const buildingQueueInfo = this.grabBuildingQueueInfoOrDefault();
- const buildingEndTime = buildingQueueInfo.seconds ? buildingQueueInfo.seconds + timestamp() : 0;
+ const buildingEndTime = buildingQueueInfo.seconds
+ ? buildingQueueInfo.seconds + timestamp()
+ : 0;
this.storage.storeQueueTaskEnding(ProductionQueue.Building, buildingEndTime);
}
diff --git a/src/Page/BuildingPage/BuildingPage.ts b/src/Page/BuildingPage/BuildingPage.ts
index aed7863..76d3548 100644
--- a/src/Page/BuildingPage/BuildingPage.ts
+++ b/src/Page/BuildingPage/BuildingPage.ts
@@ -14,7 +14,9 @@ export function clickBuildButton(typeId: number) {
btn.trigger('click');
}
-export function createBuildButton(onClickHandler: (buildTypeId: number, resources: Resources) => void) {
+export function createBuildButton(
+ onClickHandler: (buildTypeId: number, resources: Resources) => void
+) {
const $els = jQuery('[id^=contract_building]');
$els.each((idx, el) => {
const $el = jQuery(el);
diff --git a/src/Page/BuildingPage/GuildHallPage.ts b/src/Page/BuildingPage/GuildHallPage.ts
index 30e54f8..d7ab7f1 100644
--- a/src/Page/BuildingPage/GuildHallPage.ts
+++ b/src/Page/BuildingPage/GuildHallPage.ts
@@ -28,7 +28,11 @@ export function clickCelebrationButton() {
$btn.trigger('click');
}
-function createCelebrationButton($blockEl: JQuery, idx: number, onClickHandler: CelebrationClickHandler) {
+function createCelebrationButton(
+ $blockEl: JQuery,
+ idx: number,
+ onClickHandler: CelebrationClickHandler
+) {
const resources = grabResources($blockEl);
const id = uniqId();
diff --git a/src/Page/BuildingPage/MarketPage.ts b/src/Page/BuildingPage/MarketPage.ts
index 58c569e..ba5ec3f 100644
--- a/src/Page/BuildingPage/MarketPage.ts
+++ b/src/Page/BuildingPage/MarketPage.ts
@@ -24,7 +24,10 @@ export function createSendResourcesButton(onClickHandler: SendResourcesClickHand
getNumber(sendSelect.find('#r3').val()),
getNumber(sendSelect.find('#r4').val())
);
- const crd = new Coordinates(getNumber(jQuery('#xCoordInput').val()), getNumber(jQuery('#yCoordInput').val()));
+ const crd = new Coordinates(
+ getNumber(jQuery('#xCoordInput').val()),
+ getNumber(jQuery('#yCoordInput').val())
+ );
onClickHandler(resources, crd);
};
diff --git a/src/Page/BuildingPage/TrooperPage.ts b/src/Page/BuildingPage/TrooperPage.ts
index 149af4f..44dfb34 100644
--- a/src/Page/BuildingPage/TrooperPage.ts
+++ b/src/Page/BuildingPage/TrooperPage.ts
@@ -17,7 +17,9 @@ export function createTrainTroopButtons(
return;
}
const id = uniqId();
- $el.find('.details').append(``);
+ $el.find('.details').append(
+ ``
+ );
const resElement = $el.find('.resourceWrapper .resource');
const resources = grabResourcesFromList(resElement);
jQuery(`#${id}`).on('click', evt => {
diff --git a/src/Page/BuildingPageController.ts b/src/Page/BuildingPageController.ts
index 30b7d88..3e637d2 100644
--- a/src/Page/BuildingPageController.ts
+++ b/src/Page/BuildingPageController.ts
@@ -10,7 +10,12 @@ import { Resources } from '../Core/Resources';
import { Coordinates } from '../Core/Village';
import { SendResourcesTask } from '../Task/SendResourcesTask';
import { EMBASSY_ID, HORSE_STABLE_ID, PALACE_ID, QUARTERS_ID } from '../Core/Buildings';
-import { BuildingPageAttributes, isForgePage, isGuildHallPage, isMarketSendResourcesPage } from './PageDetectors';
+import {
+ BuildingPageAttributes,
+ isForgePage,
+ isGuildHallPage,
+ isMarketSendResourcesPage,
+} from './PageDetectors';
import { createTrainTroopButtons } from './BuildingPage/TrooperPage';
import { createSendResourcesButton } from './BuildingPage/MarketPage';
import { createResearchButtons } from './BuildingPage/ForgePage';
@@ -25,7 +30,11 @@ export class BuildingPageController {
private villageController: VillageController;
private readonly logger: Logger;
- constructor(scheduler: Scheduler, attributes: BuildingPageAttributes, villageController: VillageController) {
+ constructor(
+ scheduler: Scheduler,
+ attributes: BuildingPageAttributes,
+ villageController: VillageController
+ ) {
this.scheduler = scheduler;
this.attributes = attributes;
this.villageController = villageController;
@@ -43,19 +52,27 @@ export class BuildingPageController {
}
if (buildTypeId === QUARTERS_ID) {
- createTrainTroopButtons((troopId, res, count) => this.onScheduleTrainTroopers(troopId, res, count));
+ createTrainTroopButtons((troopId, res, count) =>
+ this.onScheduleTrainTroopers(troopId, res, count)
+ );
}
if (buildTypeId === HORSE_STABLE_ID) {
- createTrainTroopButtons((troopId, res, count) => this.onScheduleTrainTroopers(troopId, res, count));
+ createTrainTroopButtons((troopId, res, count) =>
+ this.onScheduleTrainTroopers(troopId, res, count)
+ );
}
if (buildTypeId === EMBASSY_ID && sheetId === 1) {
- createTrainTroopButtons((troopId, res, count) => this.onScheduleTrainTroopers(troopId, res, count));
+ createTrainTroopButtons((troopId, res, count) =>
+ this.onScheduleTrainTroopers(troopId, res, count)
+ );
}
if (buildTypeId === PALACE_ID && sheetId === 1) {
- createTrainTroopButtons((troopId, res, count) => this.onScheduleTrainTroopers(troopId, res, count));
+ createTrainTroopButtons((troopId, res, count) =>
+ this.onScheduleTrainTroopers(troopId, res, count)
+ );
}
if (isMarketSendResourcesPage()) {
diff --git a/src/Queue/TaskQueue.ts b/src/Queue/TaskQueue.ts
index bf00a58..d576906 100644
--- a/src/Queue/TaskQueue.ts
+++ b/src/Queue/TaskQueue.ts
@@ -1,6 +1,13 @@
import { Logger } from '../Logger';
import { Args } from './Args';
-import { ImmutableTaskList, Task, TaskId, TaskList, TaskProvider, uniqTaskId } from './TaskProvider';
+import {
+ ImmutableTaskList,
+ Task,
+ TaskId,
+ TaskList,
+ TaskProvider,
+ uniqTaskId,
+} from './TaskProvider';
export class TaskQueue {
private provider: TaskProvider;
diff --git a/src/ResourceTransfer.ts b/src/ResourceTransfer.ts
index 1c7e3f6..928ac23 100644
--- a/src/ResourceTransfer.ts
+++ b/src/ResourceTransfer.ts
@@ -22,7 +22,9 @@ export class ResourceTransferCalculator {
const recipientController = this.factory.createController(toVillageId);
const multiplier = senderState.settings.sendResourcesMultiplier;
- const senderReadyResources = senderController.getAvailableForSendResources().downTo(multiplier);
+ const senderReadyResources = senderController
+ .getAvailableForSendResources()
+ .downTo(multiplier);
const recipientNeedResources = recipientController.getRequiredResources().upTo(multiplier);
const contractResources = senderReadyResources.min(recipientNeedResources);
@@ -44,6 +46,11 @@ export class ResourceTransferCalculator {
{ name: 'Ready to transfer', ...readyToTransfer },
]);
- return { fromVillageId, toVillageId, resources: readyToTransfer, score: readyToTransfer.amount() };
+ return {
+ fromVillageId,
+ toVillageId,
+ resources: readyToTransfer,
+ score: readyToTransfer.amount(),
+ };
}
}
diff --git a/src/Scheduler.ts b/src/Scheduler.ts
index d373913..3398018 100644
--- a/src/Scheduler.ts
+++ b/src/Scheduler.ts
@@ -1,6 +1,5 @@
import { around, timestamp } from './utils';
import { TaskQueue } from './Queue/TaskQueue';
-import { SendOnAdventureTask } from './Task/SendOnAdventureTask';
import { BalanceHeroResourcesTask } from './Task/BalanceHeroResourcesTask';
import { Logger } from './Logger';
import { GrabVillageState } from './Task/GrabVillageState';
@@ -9,12 +8,10 @@ import { UpdateResourceContracts } from './Task/UpdateResourceContracts';
import { SendResourcesTask } from './Task/SendResourcesTask';
import { Args } from './Queue/Args';
import { ImmutableTaskList, Task, TaskId, uniqTaskId, withTime } from './Queue/TaskProvider';
-import { MARKET_ID } from './Core/Buildings';
import { VillageRepositoryInterface } from './VillageRepository';
import { isProductionTask } from './Core/ProductionQueue';
import { VillageFactory } from './VillageFactory';
import { RunVillageProductionTask } from './Task/RunVillageProductionTask';
-import { VillageNotFound } from './Errors';
export interface NextExecution {
task?: Task;
@@ -47,7 +44,9 @@ export class Scheduler {
const villages = this.villageRepository.all();
for (let village of villages) {
- this.createUniqTaskTimer(5 * 60, RunVillageProductionTask.name, { villageId: village.id });
+ this.createUniqTaskTimer(5 * 60, RunVillageProductionTask.name, {
+ villageId: village.id,
+ });
}
this.createUniqTaskTimer(5 * 60, GrabVillageState.name);
@@ -127,7 +126,9 @@ export class Scheduler {
scheduleUniqTask(name: string, args: Args, ts?: number | undefined): void {
let alreadyHasTask;
if (args.villageId) {
- alreadyHasTask = this.taskQueue.has(t => t.name === name && t.args.villageId === args.villageId);
+ alreadyHasTask = this.taskQueue.has(
+ t => t.name === name && t.args.villageId === args.villageId
+ );
} else {
alreadyHasTask = this.taskQueue.has(t => t.name === name);
}
diff --git a/src/Storage/VillageStorage.ts b/src/Storage/VillageStorage.ts
index 0a4a6a4..a3ab352 100644
--- a/src/Storage/VillageStorage.ts
+++ b/src/Storage/VillageStorage.ts
@@ -82,7 +82,9 @@ export class VillageStorage {
}
getIncomingMerchants(): ReadonlyArray {
- const objects = this.storage.getTypedList