Display hero health
This commit is contained in:
parent
901bea6b4e
commit
7d477ba35a
@ -86,7 +86,10 @@ export class Container {
|
||||
this._grabberManager =
|
||||
this._grabberManager ||
|
||||
(() => {
|
||||
return new GrabberManager(this.villageFactory);
|
||||
return new GrabberManager(
|
||||
this.villageFactory,
|
||||
new ConsoleLogger(GrabberManager.name)
|
||||
);
|
||||
})();
|
||||
return this._grabberManager;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import { timestamp } from './Helpers/Time';
|
||||
import { notify, parseLocation, waitForLoad } from './Helpers/Browser';
|
||||
import { Action } from './Queue/Action';
|
||||
import { Task } from './Queue/Task';
|
||||
import { HeroAttributes } from './Core/Hero';
|
||||
import { HeroStorage } from './Storage/HeroStorage';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
@ -31,6 +33,7 @@ interface GameState {
|
||||
version: string;
|
||||
activeVillageState: VillageState | undefined;
|
||||
villageStates: ReadonlyArray<VillageState>;
|
||||
heroAttr: HeroAttributes;
|
||||
taskList: ReadonlyArray<Task>;
|
||||
actionList: ReadonlyArray<Action>;
|
||||
pauseSeconds: number;
|
||||
@ -64,17 +67,20 @@ export class ControlPanel {
|
||||
const villageFactory = this.villageFactory;
|
||||
|
||||
const executionState = new ExecutionStorage();
|
||||
const heroStorage = new HeroStorage();
|
||||
|
||||
const state: GameState = {
|
||||
name: 'Control',
|
||||
version: this.version,
|
||||
activeVillageState: undefined,
|
||||
villageStates: [],
|
||||
heroAttr: HeroAttributes.default(),
|
||||
taskList: [],
|
||||
actionList: [],
|
||||
pauseSeconds: 0,
|
||||
|
||||
refresh() {
|
||||
this.heroAttr = heroStorage.getAttributes();
|
||||
this.taskList = scheduler.getTaskItems();
|
||||
this.actionList = scheduler.getActionItems();
|
||||
const { pauseTs } = executionState.getExecutionSettings();
|
||||
|
@ -6,6 +6,10 @@ export class HeroAttributes {
|
||||
constructor(health: number) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
static default() {
|
||||
return new HeroAttributes(0);
|
||||
}
|
||||
}
|
||||
|
||||
export type HeroAllResourcesType = 'all';
|
||||
|
@ -1,8 +1,9 @@
|
||||
<template>
|
||||
<main id="dashboard" v-on:keyup.76="toggleLogs">
|
||||
<section id="dashboard-primary">
|
||||
<hdr></hdr>
|
||||
<hdr />
|
||||
<village-state-list />
|
||||
<hero-view />
|
||||
<hr class="separator" />
|
||||
<task-list />
|
||||
</section>
|
||||
@ -21,10 +22,12 @@ import LogList from './LogList';
|
||||
import { mapState } from 'vuex';
|
||||
import { Mutations } from './Store';
|
||||
import VillageEditor from './VillageEditor';
|
||||
import HeroView from './HeroView';
|
||||
export default {
|
||||
components: {
|
||||
'village-editor': VillageEditor,
|
||||
'hdr': Header,
|
||||
'hero-view': HeroView,
|
||||
'task-list': TaskList,
|
||||
'village-state-list': VillageStateList,
|
||||
'log-list': LogList,
|
||||
|
26
src/Dashboard/HeroView.vue
Normal file
26
src/Dashboard/HeroView.vue
Normal file
@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<table class="hero">
|
||||
<tr>
|
||||
<td>Герой</td>
|
||||
<td>Здоровье</td>
|
||||
<td v-text="shared.heroAttr.health"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
shared: this.$root.$data,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import 'style';
|
||||
.hero {
|
||||
@extend %table;
|
||||
}
|
||||
</style>
|
@ -165,12 +165,8 @@ export class Executor {
|
||||
}
|
||||
|
||||
private runGrabbers() {
|
||||
try {
|
||||
this.logger.info('Rug grabbers');
|
||||
this.grabberManager.grab();
|
||||
} catch (e) {
|
||||
this.logger.warn('Grabbers fails with', e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,18 +8,24 @@ import { ForgePageGrabber } from './ForgePageGrabber';
|
||||
import { GuildHallPageGrabber } from './GuildHallPageGrabber';
|
||||
import { VillageFactory } from '../Village/VillageFactory';
|
||||
import { VillageBuildingsPageGrabber } from './VillageBuildingsPageGrabber';
|
||||
import { GrabError } from '../Errors';
|
||||
import { Logger } from '../Logger';
|
||||
|
||||
export class GrabberManager {
|
||||
private factory: VillageFactory;
|
||||
|
||||
constructor(factory: VillageFactory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
constructor(private readonly factory: VillageFactory, private readonly logger: Logger) {}
|
||||
|
||||
grab() {
|
||||
const grabbers = this.createGrabbers();
|
||||
for (let grabber of grabbers) {
|
||||
try {
|
||||
grabber.grab();
|
||||
} catch (e) {
|
||||
if (e instanceof GrabError) {
|
||||
this.logger.warn('Grabbers fails with', e.message);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user