Display adventure difficulty

This commit is contained in:
Anton Vakhrushev 2020-10-15 10:49:26 +03:00
parent 7d477ba35a
commit 251a616fa4
3 changed files with 22 additions and 1 deletions

View File

@ -14,7 +14,7 @@ import DashboardApp from './Dashboard/Dashboard.vue';
import { createStore } from './Dashboard/Store'; import { createStore } from './Dashboard/Store';
import { ConsoleLogger, Logger } from './Logger'; import { ConsoleLogger, Logger } from './Logger';
import { DataStorage } from './Storage/DataStorage'; import { DataStorage } from './Storage/DataStorage';
import { getBuildingPageAttributes, isBuildingPage } from './Page/PageDetector'; import { getBuildingPageAttributes, isAdventurePage, isBuildingPage } from './Page/PageDetector';
import { ExecutionStorage } from './Storage/ExecutionStorage'; import { ExecutionStorage } from './Storage/ExecutionStorage';
import { VillageState } from './Village/VillageState'; import { VillageState } from './Village/VillageState';
import { VillageFactory } from './Village/VillageFactory'; import { VillageFactory } from './Village/VillageFactory';
@ -25,6 +25,7 @@ import { Action } from './Queue/Action';
import { Task } from './Queue/Task'; import { Task } from './Queue/Task';
import { HeroAttributes } from './Core/Hero'; import { HeroAttributes } from './Core/Hero';
import { HeroStorage } from './Storage/HeroStorage'; import { HeroStorage } from './Storage/HeroStorage';
import { showAdventureDifficulty } from './Page/AdventurePage';
Vue.use(Vuex); Vue.use(Vuex);
@ -148,6 +149,10 @@ export class ControlPanel {
buildPage.run(); buildPage.run();
} }
if (isAdventurePage()) {
showAdventureDifficulty();
}
this.createControlPanel(state, villageFactory); this.createControlPanel(state, villageFactory);
} }

11
src/Page/AdventurePage.ts Normal file
View File

@ -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}`);
});
}

View File

@ -21,6 +21,11 @@ export function isHeroPage() {
return p.pathname === '/hero.php'; return p.pathname === '/hero.php';
} }
export function isAdventurePage() {
const p = parseLocation();
return p.pathname === '/hero.php' && p.query.t === '3';
}
export function getBuildingPageAttributes(): BuildingPageAttributes { export function getBuildingPageAttributes(): BuildingPageAttributes {
if (!isBuildingPage()) { if (!isBuildingPage()) {
throw Error('Not building page'); throw Error('Not building page');