diff --git a/src/ControlPanel.ts b/src/ControlPanel.ts index 2e7e00b..a7bb0c2 100644 --- a/src/ControlPanel.ts +++ b/src/ControlPanel.ts @@ -14,7 +14,7 @@ import DashboardApp from './Dashboard/Dashboard.vue'; import { createStore } from './Dashboard/Store'; import { ConsoleLogger, Logger } from './Logger'; import { DataStorage } from './Storage/DataStorage'; -import { getBuildingPageAttributes, isBuildingPage } from './Page/PageDetector'; +import { getBuildingPageAttributes, isAdventurePage, isBuildingPage } from './Page/PageDetector'; import { ExecutionStorage } from './Storage/ExecutionStorage'; import { VillageState } from './Village/VillageState'; import { VillageFactory } from './Village/VillageFactory'; @@ -25,6 +25,7 @@ import { Action } from './Queue/Action'; import { Task } from './Queue/Task'; import { HeroAttributes } from './Core/Hero'; import { HeroStorage } from './Storage/HeroStorage'; +import { showAdventureDifficulty } from './Page/AdventurePage'; Vue.use(Vuex); @@ -148,6 +149,10 @@ export class ControlPanel { buildPage.run(); } + if (isAdventurePage()) { + showAdventureDifficulty(); + } + this.createControlPanel(state, villageFactory); } diff --git a/src/Page/AdventurePage.ts b/src/Page/AdventurePage.ts new file mode 100644 index 0000000..a974442 --- /dev/null +++ b/src/Page/AdventurePage.ts @@ -0,0 +1,11 @@ +import { getNumber, trimPrefix } from '../Helpers/Convert'; + +export function showAdventureDifficulty() { + jQuery('td.difficulty').each((index, el) => { + const $el = jQuery(el); + const $img = $el.find('img'); + const imgClass = $img.attr('class') || ''; + const level = getNumber(trimPrefix(imgClass, 'adventureDifficulty')); + $img.after(` - ${level}`); + }); +} diff --git a/src/Page/PageDetector.ts b/src/Page/PageDetector.ts index e05d7f3..1688688 100644 --- a/src/Page/PageDetector.ts +++ b/src/Page/PageDetector.ts @@ -21,6 +21,11 @@ export function isHeroPage() { return p.pathname === '/hero.php'; } +export function isAdventurePage() { + const p = parseLocation(); + return p.pathname === '/hero.php' && p.query.t === '3'; +} + export function getBuildingPageAttributes(): BuildingPageAttributes { if (!isBuildingPage()) { throw Error('Not building page');