Add shipment indication
This commit is contained in:
parent
dfbab68d46
commit
e88d1380c5
@ -177,9 +177,10 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td class="right" colspan="6">
|
<td class="right" colspan="6">
|
||||||
<a
|
<a
|
||||||
class="village-quick-link"
|
|
||||||
v-for="s in shared.villageStates"
|
v-for="s in shared.villageStates"
|
||||||
v-if="s.id !== villageState.id"
|
v-if="s.id !== villageState.id"
|
||||||
|
class="village-quick-link"
|
||||||
|
:class="{ active: villageState.shipment.includes(s.id) }"
|
||||||
:href="marketPath(villageState.village, s.village)"
|
:href="marketPath(villageState.village, s.village)"
|
||||||
:title="'Отправить ресурсы из ' + villageState.village.name + ' в ' + s.village.name"
|
:title="'Отправить ресурсы из ' + villageState.village.name + ' в ' + s.village.name"
|
||||||
>$->{{ s.village.name }}</a
|
>$->{{ s.village.name }}</a
|
||||||
@ -295,6 +296,10 @@ export default {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.village-quick-link.active {
|
||||||
|
color: midnightblue;
|
||||||
|
}
|
||||||
|
|
||||||
.village-quick-link + .village-quick-link {
|
.village-quick-link + .village-quick-link {
|
||||||
margin-left: 0.4em;
|
margin-left: 0.4em;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ export class Scheduler {
|
|||||||
return tasks.reduce((acc, t) => acc.add(t.args.resources!), Resources.zero());
|
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
|
const tasks = this.taskQueue
|
||||||
.seeItems()
|
.seeItems()
|
||||||
.filter(t => t.name === SendResourcesTask.name && t.args.villageId === villageId && t.args.targetVillageId);
|
.filter(t => t.name === SendResourcesTask.name && t.args.villageId === villageId && t.args.targetVillageId);
|
||||||
|
@ -28,6 +28,7 @@ interface VillageOwnStateDictionary {
|
|||||||
|
|
||||||
export interface VillageState extends VillageOwnState {
|
export interface VillageState extends VillageOwnState {
|
||||||
commitments: Resources;
|
commitments: Resources;
|
||||||
|
shipment: Array<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcResourceBalance(resources: Resources, current: Resources, performance: Resources): RequiredResources {
|
function calcResourceBalance(resources: Resources, current: Resources, performance: Resources): RequiredResources {
|
||||||
@ -86,13 +87,13 @@ function createVillageState(
|
|||||||
ownStates: VillageOwnStateDictionary,
|
ownStates: VillageOwnStateDictionary,
|
||||||
scheduler: Scheduler
|
scheduler: Scheduler
|
||||||
): VillageState {
|
): VillageState {
|
||||||
const villageIds = scheduler.getResourceCommitments(state.id);
|
const villageIds = scheduler.getResourceShipmentVillageIds(state.id);
|
||||||
const commitments = villageIds.reduce((res, villageId) => {
|
const commitments = villageIds.reduce((res, villageId) => {
|
||||||
const villageRequired = ownStates[villageId].required;
|
const villageRequired = ownStates[villageId].required;
|
||||||
const missing = villageRequired.balance.min(Resources.zero());
|
const missing = villageRequired.balance.min(Resources.zero());
|
||||||
return res.add(missing);
|
return res.add(missing);
|
||||||
}, Resources.zero());
|
}, Resources.zero());
|
||||||
return { ...state, commitments };
|
return { ...state, commitments, shipment: villageIds };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createVillageStates(villages: Array<Village>, scheduler: Scheduler): Array<VillageState> {
|
export function createVillageStates(villages: Array<Village>, scheduler: Scheduler): Array<VillageState> {
|
||||||
|
Loading…
Reference in New Issue
Block a user