Add shipment indication

This commit is contained in:
Anton Vakhrushev 2020-05-02 21:22:41 +03:00
parent dfbab68d46
commit e88d1380c5
3 changed files with 10 additions and 4 deletions

View File

@ -177,9 +177,10 @@
<td></td>
<td class="right" colspan="6">
<a
class="village-quick-link"
v-for="s in shared.villageStates"
v-if="s.id !== villageState.id"
class="village-quick-link"
:class="{ active: villageState.shipment.includes(s.id) }"
:href="marketPath(villageState.village, s.village)"
:title="'Отправить ресурсы из ' + villageState.village.name + ' в ' + s.village.name"
>$->{{ s.village.name }}</a
@ -295,6 +296,10 @@ export default {
display: inline-block;
}
.village-quick-link.active {
color: midnightblue;
}
.village-quick-link + .village-quick-link {
margin-left: 0.4em;
}

View File

@ -166,7 +166,7 @@ export class Scheduler {
return tasks.reduce((acc, t) => acc.add(t.args.resources!), Resources.zero());
}
getResourceCommitments(villageId: number): Array<number> {
getResourceShipmentVillageIds(villageId: number): Array<number> {
const tasks = this.taskQueue
.seeItems()
.filter(t => t.name === SendResourcesTask.name && t.args.villageId === villageId && t.args.targetVillageId);

View File

@ -28,6 +28,7 @@ interface VillageOwnStateDictionary {
export interface VillageState extends VillageOwnState {
commitments: Resources;
shipment: Array<number>;
}
function calcResourceBalance(resources: Resources, current: Resources, performance: Resources): RequiredResources {
@ -86,13 +87,13 @@ function createVillageState(
ownStates: VillageOwnStateDictionary,
scheduler: Scheduler
): VillageState {
const villageIds = scheduler.getResourceCommitments(state.id);
const villageIds = scheduler.getResourceShipmentVillageIds(state.id);
const commitments = villageIds.reduce((res, villageId) => {
const villageRequired = ownStates[villageId].required;
const missing = villageRequired.balance.min(Resources.zero());
return res.add(missing);
}, Resources.zero());
return { ...state, commitments };
return { ...state, commitments, shipment: villageIds };
}
export function createVillageStates(villages: Array<Village>, scheduler: Scheduler): Array<VillageState> {