diff --git a/src/ControlPanel.ts b/src/ControlPanel.ts
index a7bb0c2..57b9162 100644
--- a/src/ControlPanel.ts
+++ b/src/ControlPanel.ts
@@ -14,7 +14,12 @@ import DashboardApp from './Dashboard/Dashboard.vue';
import { createStore } from './Dashboard/Store';
import { ConsoleLogger, Logger } from './Logger';
import { DataStorage } from './Storage/DataStorage';
-import { getBuildingPageAttributes, isAdventurePage, isBuildingPage } from './Page/PageDetector';
+import {
+ getBuildingPageAttributes,
+ isAdventurePage,
+ isBuildingPage,
+ isTrapperPage,
+} from './Page/PageDetector';
import { ExecutionStorage } from './Storage/ExecutionStorage';
import { VillageState } from './Village/VillageState';
import { VillageFactory } from './Village/VillageFactory';
@@ -26,6 +31,7 @@ import { Task } from './Queue/Task';
import { HeroAttributes } from './Core/Hero';
import { HeroStorage } from './Storage/HeroStorage';
import { showAdventureDifficulty } from './Page/AdventurePage';
+import { getTrapStats } from './Page/BuildingPage/TrapperPage';
Vue.use(Vuex);
@@ -153,6 +159,10 @@ export class ControlPanel {
showAdventureDifficulty();
}
+ if (isTrapperPage()) {
+ console.log('TRAPS', getTrapStats());
+ }
+
this.createControlPanel(state, villageFactory);
}
diff --git a/src/Core/Buildings.ts b/src/Core/Buildings.ts
index dbe5284..19c6def 100644
--- a/src/Core/Buildings.ts
+++ b/src/Core/Buildings.ts
@@ -8,3 +8,4 @@ export const HORSE_STABLE_ID = 20;
export const GUILD_HALL_ID = 24;
export const EMBASSY_ID = 25;
export const PALACE_ID = 26;
+export const TRAPPER_ID = 36;
diff --git a/src/Core/Traps.ts b/src/Core/Traps.ts
new file mode 100644
index 0000000..e63ad3a
--- /dev/null
+++ b/src/Core/Traps.ts
@@ -0,0 +1,7 @@
+export interface TrapStat {
+ overall: number;
+ current: number;
+ built: number;
+ used: number;
+ canBuiltNow: number;
+}
diff --git a/src/Dashboard/Store.ts b/src/Dashboard/Store.ts
index 2c0f10a..0aaa03a 100644
--- a/src/Dashboard/Store.ts
+++ b/src/Dashboard/Store.ts
@@ -24,6 +24,7 @@ export enum Actions {
RemoveVillageTask = 'remove_village_task',
UpVillageTask = 'up_village_task',
DownVillageTask = 'down_village_task',
+ MakeFirstVillageTask = 'make_first_village_task',
}
export function createStore(villageFactory: VillageFactory) {
@@ -111,6 +112,10 @@ export function createStore(villageFactory: VillageFactory) {
const controller = villageFactory.getById(villageId).controller();
controller.removeTask(taskId);
},
+ [Actions.MakeFirstVillageTask]({}, { villageId, taskId }) {
+ const controller = villageFactory.getById(villageId).controller();
+ controller.makeFirst(taskId);
+ },
[Actions.UpVillageTask]({}, { villageId, taskId }) {
const controller = villageFactory.getById(villageId).controller();
controller.upTask(taskId);
diff --git a/src/Dashboard/VillageTaskList.vue b/src/Dashboard/VillageTaskList.vue
index e67f780..3b8c32f 100644
--- a/src/Dashboard/VillageTaskList.vue
+++ b/src/Dashboard/VillageTaskList.vue
@@ -3,6 +3,9 @@
|
+ fst
up
dn
x
@@ -39,6 +42,9 @@ export default {
}
return taskStatus + task.name;
},
+ makeFirstTask(taskId) {
+ this.$store.dispatch(Actions.MakeFirstVillageTask, { villageId: this.villageId, taskId });
+ },
upTask(taskId) {
this.$store.dispatch(Actions.UpVillageTask, { villageId: this.villageId, taskId });
},
diff --git a/src/Page/BuildingPage/TrapperPage.ts b/src/Page/BuildingPage/TrapperPage.ts
new file mode 100644
index 0000000..0577d3c
--- /dev/null
+++ b/src/Page/BuildingPage/TrapperPage.ts
@@ -0,0 +1,18 @@
+import { Resources } from '../../Core/Resources';
+import { GrabError } from '../../Errors';
+import { grabResourcesFromList } from './BuildingPage';
+import { elClassId, getNumber } from '../../Helpers/Convert';
+import { uniqId } from '../../Helpers/Identity';
+import { TrapStat } from '../../Core/Traps';
+
+export function getTrapStats(): TrapStat {
+ const $buildValue = jQuery('#build_value');
+ const $trapsEl = jQuery('.traps');
+ return {
+ built: getNumber($trapsEl.find('b').get(0).innerText),
+ canBuiltNow: 0,
+ current: getNumber($buildValue.find('.currentLevel .number').text()),
+ overall: getNumber($buildValue.find('.overall .number').text()),
+ used: getNumber($trapsEl.find('b').get(1).innerText),
+ };
+}
diff --git a/src/Page/PageDetector.ts b/src/Page/PageDetector.ts
index 1688688..dbbbc70 100644
--- a/src/Page/PageDetector.ts
+++ b/src/Page/PageDetector.ts
@@ -1,4 +1,4 @@
-import { FORGE_ID, GUILD_HALL_ID, MARKET_ID } from '../Core/Buildings';
+import { FORGE_ID, GUILD_HALL_ID, MARKET_ID, TRAPPER_ID } from '../Core/Buildings';
import { elClassId, getNumber } from '../Helpers/Convert';
import { parseLocation } from '../Helpers/Browser';
@@ -65,3 +65,11 @@ export function isGuildHallPage(): boolean {
const { buildTypeId } = getBuildingPageAttributes();
return buildTypeId === GUILD_HALL_ID;
}
+
+export function isTrapperPage(): boolean {
+ if (!isBuildingPage()) {
+ return false;
+ }
+ const { buildTypeId } = getBuildingPageAttributes();
+ return buildTypeId === TRAPPER_ID;
+}
diff --git a/src/Village/VillageController.ts b/src/Village/VillageController.ts
index 3bb4c2c..cb07740 100644
--- a/src/Village/VillageController.ts
+++ b/src/Village/VillageController.ts
@@ -56,6 +56,10 @@ export class VillageController {
this.taskCollection.upTask(taskId);
}
+ makeFirst(taskId: TaskId) {
+ this.taskCollection.makeFirst(taskId);
+ }
+
downTask(taskId: TaskId) {
this.taskCollection.downTask(taskId);
}
diff --git a/src/Village/VillageTaskCollection.ts b/src/Village/VillageTaskCollection.ts
index 28e365a..a6eda54 100644
--- a/src/Village/VillageTaskCollection.ts
+++ b/src/Village/VillageTaskCollection.ts
@@ -52,6 +52,17 @@ export class VillageTaskCollection {
this.removeTasks((t) => t.id === taskId);
}
+ makeFirst(taskId: TaskId): void {
+ const tasks = this.storage.getTasks();
+ const index = tasks.findIndex((t) => t.id === taskId);
+ if (index < 0 || index === 0) {
+ return;
+ }
+ const movedTask = tasks.splice(index, 1)[0];
+ tasks.unshift(movedTask);
+ this.storage.storeTaskList(tasks);
+ }
+
upTask(taskId: TaskId): void {
const tasks = this.storage.getTasks();
const index = tasks.findIndex((t) => t.id === taskId);
|