Add resource balance indication
This commit is contained in:
parent
8ccef8be75
commit
2bad0e1b5d
@ -54,10 +54,12 @@ export class ControlPanel {
|
|||||||
activeVillage: {},
|
activeVillage: {},
|
||||||
villages: [],
|
villages: [],
|
||||||
taskList: [],
|
taskList: [],
|
||||||
|
actionList: [],
|
||||||
quickActions: quickActions,
|
quickActions: quickActions,
|
||||||
|
|
||||||
refreshTasks() {
|
refreshTasks() {
|
||||||
this.taskList = scheduler.getTaskItems();
|
this.taskList = scheduler.getTaskItems();
|
||||||
|
this.actionList = scheduler.getActionItems();
|
||||||
},
|
},
|
||||||
|
|
||||||
removeTask(taskId: string) {
|
removeTask(taskId: string) {
|
||||||
|
38
src/DashboardView/Resource.vue
Normal file
38
src/DashboardView/Resource.vue
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<template>
|
||||||
|
<span :class="classes" v-text="formatted"></span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['value'],
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
formatted() {
|
||||||
|
if (this.value === undefined) {
|
||||||
|
return '';
|
||||||
|
} else if (this.value > 0) {
|
||||||
|
return '+' + this.value;
|
||||||
|
} else {
|
||||||
|
return '' + this.value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
classes() {
|
||||||
|
return {
|
||||||
|
good: this.value > 0,
|
||||||
|
bad: this.value < 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.good {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
.bad {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,6 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="task-list">
|
<section class="task-list">
|
||||||
<p class="summary">Task count: {{ shared.taskList.length }}</p>
|
<p class="summary">
|
||||||
|
Task count: {{ shared.taskList.length }}
|
||||||
|
<template v-if="actionCount">, actions left {{ actionCount }}</template>
|
||||||
|
</p>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<table class="task-table">
|
<table class="task-table">
|
||||||
<tr v-for="task in shared.taskList" class="task-item" :class="{ 'this-village': isThisVillageTask(task) }">
|
<tr v-for="task in shared.taskList" class="task-item" :class="{ 'this-village': isThisVillageTask(task) }">
|
||||||
@ -27,6 +30,11 @@ export default {
|
|||||||
activeVillage: this.$root.$data.activeVillage,
|
activeVillage: this.$root.$data.activeVillage,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
actionCount() {
|
||||||
|
return this.shared.actionList.length;
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatDate(ts) {
|
formatDate(ts) {
|
||||||
const d = new Date(ts * 1000);
|
const d = new Date(ts * 1000);
|
||||||
|
@ -51,11 +51,19 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="required-line">
|
<tr class="required-line">
|
||||||
<td class="right">Профицит:</td>
|
<td class="right">Баланс:</td>
|
||||||
<td class="right" v-text="village.lumber - village.lumber_need || ''"></td>
|
<td class="right">
|
||||||
<td class="right" v-text="village.clay - village.clay_need || ''"></td>
|
<resource :value="village.lumber - village.lumber_need"></resource>
|
||||||
<td class="right" v-text="village.iron - village.iron_need || ''"></td>
|
</td>
|
||||||
<td class="right" v-text="village.crop - village.crop_need || ''"></td>
|
<td class="right">
|
||||||
|
<resource :value="village.clay - village.clay_need"></resource>
|
||||||
|
</td>
|
||||||
|
<td class="right">
|
||||||
|
<resource :value="village.iron - village.iron_need"></resource>
|
||||||
|
</td>
|
||||||
|
<td class="right">
|
||||||
|
<resource :value="village.crop - village.crop_need"></resource>
|
||||||
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -90,8 +98,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { path } from '../utils';
|
import { path } from '../utils';
|
||||||
|
import Resource from './Resource';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
resource: Resource,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
shared: this.$root.$data,
|
shared: this.$root.$data,
|
||||||
|
@ -37,6 +37,10 @@ export class ActionQueue {
|
|||||||
this.flushState([]);
|
this.flushState([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seeItems(): ActionList {
|
||||||
|
return this.getCommands();
|
||||||
|
}
|
||||||
|
|
||||||
private getCommands(): ActionList {
|
private getCommands(): ActionList {
|
||||||
const serialized = this.storage.get(QUEUE_NAME);
|
const serialized = this.storage.get(QUEUE_NAME);
|
||||||
if (!Array.isArray(serialized)) {
|
if (!Array.isArray(serialized)) {
|
||||||
|
@ -7,7 +7,7 @@ import { BalanceHeroResourcesTask } from './Task/BalanceHeroResourcesTask';
|
|||||||
import { ConsoleLogger, Logger } from './Logger';
|
import { ConsoleLogger, Logger } from './Logger';
|
||||||
import { BuildBuildingTask } from './Task/BuildBuildingTask';
|
import { BuildBuildingTask } from './Task/BuildBuildingTask';
|
||||||
import { GrabVillageState } from './Task/GrabVillageState';
|
import { GrabVillageState } from './Task/GrabVillageState';
|
||||||
import { ActionQueue } from './Queue/ActionQueue';
|
import { ActionList, ActionQueue } from './Queue/ActionQueue';
|
||||||
import { Resources, ResourcesInterface } from './Game';
|
import { Resources, ResourcesInterface } from './Game';
|
||||||
import { UpdateResourceContracts } from './Task/UpdateResourceContracts';
|
import { UpdateResourceContracts } from './Task/UpdateResourceContracts';
|
||||||
|
|
||||||
@ -43,6 +43,10 @@ export class Scheduler {
|
|||||||
return this.taskQueue.seeItems();
|
return this.taskQueue.seeItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getActionItems(): ActionList {
|
||||||
|
return this.actionQueue.seeItems();
|
||||||
|
}
|
||||||
|
|
||||||
nextTask(ts: number) {
|
nextTask(ts: number) {
|
||||||
return this.taskQueue.get(ts);
|
return this.taskQueue.get(ts);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user