diff --git a/src/Action/BalanceHeroResourcesAction.ts b/src/Action/BalanceHeroResourcesAction.ts index fbe8db3..dfec63b 100644 --- a/src/Action/BalanceHeroResourcesAction.ts +++ b/src/Action/BalanceHeroResourcesAction.ts @@ -3,10 +3,10 @@ import { Args } from '../Command'; import { Task } from '../Queue/TaskQueue'; import { grabResources, grabResourceStorage } from '../Page/ResourcesBlock'; import { changeHeroResource, grabCurrentHeroResource } from '../Page/HeroPage'; -import { HeroAllResources } from '../Game'; import { grabActiveVillageId } from '../Page/VillageBlock'; import { HeroState } from '../State/HeroState'; import { calcHeroResource } from '../Core/HeroBalance'; +import { HeroAllResources } from '../Core/Hero'; @registerAction export class BalanceHeroResourcesAction extends ActionController { diff --git a/src/ControlPanel.ts b/src/ControlPanel.ts index 4267c2a..104f4e8 100644 --- a/src/ControlPanel.ts +++ b/src/ControlPanel.ts @@ -14,8 +14,8 @@ import DashboardApp from './DashboardView/Dashboard.vue'; import { ResourcesToLevel } from './Task/ResourcesToLevel'; import { ConsoleLogger, Logger } from './Logger'; import { VillageState } from './State/VillageState'; -import { Village } from './Game'; import { Resources } from './Core/Resources'; +import { Village } from './Core/Village'; interface QuickAction { label: string; diff --git a/src/Core/Hero.ts b/src/Core/Hero.ts new file mode 100644 index 0000000..5c3b6a2 --- /dev/null +++ b/src/Core/Hero.ts @@ -0,0 +1,13 @@ +import { ResourceType } from './ResourceType'; + +export class HeroAttributes { + readonly health: number; + + constructor(health: number) { + this.health = health; + } +} + +export type HeroAllResourcesType = 'all'; +export const HeroAllResources: HeroAllResourcesType = 'all'; +export type HeroResourceType = ResourceType | HeroAllResourcesType; diff --git a/src/Core/HeroBalance.ts b/src/Core/HeroBalance.ts index d857203..9bcb0af 100644 --- a/src/Core/HeroBalance.ts +++ b/src/Core/HeroBalance.ts @@ -1,5 +1,6 @@ import { Resources } from './Resources'; -import { HeroAllResources, HeroResourceType, ResourceStorage } from '../Game'; +import { ResourceStorage } from './ResourceStorage'; +import { HeroAllResources, HeroResourceType } from './Hero'; export function calcHeroResource( current: Resources, diff --git a/src/Core/ResourceStorage.ts b/src/Core/ResourceStorage.ts new file mode 100644 index 0000000..5c9bc4e --- /dev/null +++ b/src/Core/ResourceStorage.ts @@ -0,0 +1,9 @@ +export class ResourceStorage { + readonly warehouse: number; + readonly granary: number; + + constructor(warehouse: number, granary: number) { + this.warehouse = warehouse; + this.granary = granary; + } +} diff --git a/src/Core/Resources.ts b/src/Core/Resources.ts index e3f7bae..5b31a6b 100644 --- a/src/Core/Resources.ts +++ b/src/Core/Resources.ts @@ -1,5 +1,5 @@ -import { ResourceStorage } from '../Game'; import { ResourceList, ResourceMapping, ResourceType } from './ResourceType'; +import { ResourceStorage } from './ResourceStorage'; export interface ResourcesInterface { lumber: number; diff --git a/src/Core/Village.ts b/src/Core/Village.ts new file mode 100644 index 0000000..201da19 --- /dev/null +++ b/src/Core/Village.ts @@ -0,0 +1,25 @@ +export class Coordinates { + readonly x: number; + readonly y: number; + + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } +} + +export class Village { + readonly id: number; + readonly name: string; + readonly active: boolean; + readonly crd: Coordinates; + + constructor(id: number, name: string, active: boolean, crd: Coordinates) { + this.id = id; + this.name = name; + this.active = active; + this.crd = crd; + } +} + +export type VillageList = Array; diff --git a/src/Game.ts b/src/Game.ts index f2d28dc..9756400 100644 --- a/src/Game.ts +++ b/src/Game.ts @@ -1,38 +1,5 @@ import { ResourceType } from './Core/ResourceType'; -export class ResourceStorage { - readonly warehouse: number; - readonly granary: number; - constructor(warehouse: number, granary: number) { - this.warehouse = warehouse; - this.granary = granary; - } -} - -export class Coordinates { - readonly x: number; - readonly y: number; - constructor(x: number, y: number) { - this.x = x; - this.y = y; - } -} - -export class Village { - readonly id: number; - readonly name: string; - readonly active: boolean; - readonly crd: Coordinates; - constructor(id: number, name: string, active: boolean, crd: Coordinates) { - this.id = id; - this.name = name; - this.active = active; - this.crd = crd; - } -} - -export type VillageList = Array; - export class BuildingQueueInfo { readonly seconds: number; constructor(seconds: number) { @@ -40,18 +7,6 @@ export class BuildingQueueInfo { } } -export class HeroAttributes { - readonly health: number; - constructor(health: number) { - this.health = health; - } -} - -export type HeroAllResourcesType = 'all'; -export const HeroAllResources: HeroAllResourcesType = 'all'; - -export type HeroResourceType = ResourceType | HeroAllResourcesType; - export class ResourceDeposit { readonly buildId: number; readonly type: ResourceType; diff --git a/src/Page/HeroPage.ts b/src/Page/HeroPage.ts index 062c4ea..6c0fb18 100644 --- a/src/Page/HeroPage.ts +++ b/src/Page/HeroPage.ts @@ -1,7 +1,7 @@ import { GrabError } from '../Errors'; -import { HeroAllResources, HeroAttributes, HeroResourceType } from '../Game'; import { getNumber } from '../utils'; import { ResourceMapping, ResourceType } from '../Core/ResourceType'; +import { HeroAllResources, HeroAttributes, HeroResourceType } from '../Core/Hero'; export function grabHeroAttributes(): HeroAttributes { const healthElement = jQuery('#attributes .attribute.health .powervalue .value'); diff --git a/src/Page/ResourcesBlock.ts b/src/Page/ResourcesBlock.ts index 57eb526..f51bf92 100644 --- a/src/Page/ResourcesBlock.ts +++ b/src/Page/ResourcesBlock.ts @@ -1,8 +1,8 @@ -import { ResourceStorage } from '../Game'; import { GrabError } from '../Errors'; import { getNumber } from '../utils'; import { Resources } from '../Core/Resources'; import { ResourceType } from '../Core/ResourceType'; +import { ResourceStorage } from '../Core/ResourceStorage'; export function grabResources(): Resources { const lumber = grabResource(ResourceType.Lumber); diff --git a/src/Page/VillageBlock.ts b/src/Page/VillageBlock.ts index 9ef3114..9a6fdb3 100644 --- a/src/Page/VillageBlock.ts +++ b/src/Page/VillageBlock.ts @@ -1,7 +1,8 @@ -import { BuildingQueueInfo, Coordinates, Village, VillageList } from '../Game'; +import { BuildingQueueInfo } from '../Game'; import { GrabError } from '../Errors'; import { getNumber, parseLocation } from '../utils'; import { Resources } from '../Core/Resources'; +import { Coordinates, Village, VillageList } from '../Core/Village'; function getVillageListItems() { const $elements = jQuery('#sidebarBoxVillagelist ul li a'); diff --git a/src/State/HeroState.ts b/src/State/HeroState.ts index cbc1d8d..2a9ea67 100644 --- a/src/State/HeroState.ts +++ b/src/State/HeroState.ts @@ -1,5 +1,5 @@ import { DataStorage } from '../DataStorage'; -import { HeroAttributes } from '../Game'; +import { HeroAttributes } from '../Core/Hero'; const VILLAGE_ID_KEY = 'village_id'; const ATTRIBUTES_KEY = 'attr'; diff --git a/src/State/VillageState.ts b/src/State/VillageState.ts index 2457203..6338c59 100644 --- a/src/State/VillageState.ts +++ b/src/State/VillageState.ts @@ -1,6 +1,7 @@ import { DataStorage } from '../DataStorage'; -import { BuildingQueueInfo, ResourceStorage } from '../Game'; +import { BuildingQueueInfo } from '../Game'; import { Resources } from '../Core/Resources'; +import { ResourceStorage } from '../Core/ResourceStorage'; const RESOURCES_KEY = 'res'; const CAPACITY_KEY = 'cap'; diff --git a/tests/Core/HeroBalanceTest.ts b/tests/Core/HeroBalanceTest.ts index 035a16d..27e3375 100644 --- a/tests/Core/HeroBalanceTest.ts +++ b/tests/Core/HeroBalanceTest.ts @@ -1,10 +1,10 @@ import { it, describe } from 'mocha'; import { expect } from 'chai'; -import { ResourceStorage } from '../../src/Game'; import { calcHeroResource } from '../../src/Core/HeroBalance'; import { Resources } from '../../src/Core/Resources'; import { ResourceType } from '../../src/Core/ResourceType'; +import { ResourceStorage } from '../../src/Core/ResourceStorage'; describe('HeroBalance', function() { it('Get resource for requirement', function() {