Highlight eligible storage zones during bank container bidding
This commit is contained in:
parent
18fc0a90aa
commit
e99b9ccc66
4 changed files with 75 additions and 6 deletions
|
|
@ -163,6 +163,22 @@ try {
|
|||
state.players[player].containersOnWarehouseStore.push({ piece: second, price: 3, moved: false });
|
||||
await push();
|
||||
await page.locator('.offshore-lot[data-type="cash"][data-lot="1"]').click();
|
||||
assert.deepEqual(
|
||||
await page
|
||||
.locator('.bank-bid-storage-zone')
|
||||
.evaluateAll((els) => els.map((el) => [el.dataset.district, el.dataset.owner])),
|
||||
[
|
||||
['factory', String(player)],
|
||||
['warehouse', String(player)],
|
||||
]
|
||||
);
|
||||
assert.equal(
|
||||
await page
|
||||
.locator(`.piece.bid-eligible[data-piece-id="${offered.id}"] > rect`)
|
||||
.evaluate((el) => getComputedStyle(el).stroke),
|
||||
'rgb(33, 52, 59)',
|
||||
'eligible cargo retains its normal border'
|
||||
);
|
||||
await page.locator(`.piece.bid-eligible[data-piece-id="${offered.id}"]`).click();
|
||||
await checkDraft('cash', 1);
|
||||
assert.equal(await page.locator('.bank-lot-draft [data-piece-id]').count(), 1);
|
||||
|
|
@ -173,8 +189,8 @@ try {
|
|||
assert.equal(await page.locator('.piece.bid-selected').count(), 2);
|
||||
assert.equal(
|
||||
await page.locator('rect[stroke="blue"]').count(),
|
||||
0,
|
||||
'no sidebar frame or ordinary action outlines'
|
||||
2,
|
||||
'only the two eligible own storage zones have action outlines'
|
||||
);
|
||||
const selectedPiece = page.locator(`.piece[data-piece-id="${second.id}"]`);
|
||||
await selectedPiece.focus();
|
||||
|
|
@ -190,6 +206,8 @@ try {
|
|||
assert.equal(await page.locator('.bank-lot-draft [data-piece-id]').count(), 0);
|
||||
await page.getByRole('button', { name: 'Cancel', exact: true }).click();
|
||||
assert.equal(await page.locator('.bid-eligible, .bid-selected, .bank-draft').count(), 0);
|
||||
assert.equal(await page.locator('.bank-bid-storage-zone').count(), 0);
|
||||
assert.ok((await page.locator('rect[stroke="blue"]').count()) > 0, 'cancel restores normal action outlines');
|
||||
assert.ok((await page.locator('.piece.canDrag').count()) > 0, 'cancel restores ordinary actions');
|
||||
assert.equal(await page.evaluate(() => moves.length), 0);
|
||||
await page.locator('.offshore-lot[data-type="cash"][data-lot="1"]').click();
|
||||
|
|
|
|||
|
|
@ -439,6 +439,23 @@
|
|||
/>
|
||||
</template>
|
||||
|
||||
<rect
|
||||
v-for="zone in bankBidZones"
|
||||
:key="'bank-bid-' + zone.district"
|
||||
class="bank-bid-storage-zone"
|
||||
:data-district="zone.district"
|
||||
:data-owner="player"
|
||||
:x="6 + player * 250"
|
||||
:y="zone.y"
|
||||
:width="zone.width"
|
||||
height="44"
|
||||
fill="none"
|
||||
stroke="blue"
|
||||
stroke-width="2px"
|
||||
rx="2px"
|
||||
pointer-events="none"
|
||||
/>
|
||||
|
||||
<template v-if="!preferences.disableHelp && !bankCashOffer">
|
||||
<template v-if="ui.dragged == null && ui.selected == null">
|
||||
<rect
|
||||
|
|
@ -1663,6 +1680,15 @@ export default class Game extends Vue {
|
|||
.filter((c) => !c.moved)
|
||||
.map((c) => ({ ...c.piece, price: c.price }));
|
||||
}
|
||||
get bankBidZones() {
|
||||
if (!this.bankCashOffer) return [];
|
||||
const eligible = new Set(this.bankBidCargo.map((c) => c.id));
|
||||
const p = this.G!.players[this.player!];
|
||||
return [
|
||||
{ district: 'factory', cargo: p.containersOnFactoryStore, y: 158, width: 188 },
|
||||
{ district: 'warehouse', cargo: p.containersOnWarehouseStore, y: 248, width: 236 },
|
||||
].filter((zone) => zone.cargo.some((c) => eligible.has(c.piece.id)));
|
||||
}
|
||||
get bankContainerHighlights() {
|
||||
return this.bankCashOffer ? this.bankBidCargo.map((c) => c.id) : [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,6 @@ export default class Container extends Mixins(Piece) {
|
|||
.bid-eligible {
|
||||
cursor: pointer;
|
||||
}
|
||||
.bid-eligible > rect {
|
||||
stroke: blue;
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
.bid-selected > rect {
|
||||
stroke: #ffe154;
|
||||
stroke-width: 2.5;
|
||||
|
|
|
|||
|
|
@ -281,6 +281,35 @@ describe('Offshore bank viewer', () => {
|
|||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it('highlights only own storage zones containing eligible bid cargo', async () => {
|
||||
const { wrapper, state, player, own } = gameFixture();
|
||||
const normalOutlines = wrapper.findAll('rect[stroke="blue"]').length;
|
||||
const bank = wrapper.findComponent(OffshoreBank);
|
||||
bank.vm.$emit('choose-offer', { type: 'cash', lot: 1 });
|
||||
await wrapper.vm.$nextTick();
|
||||
const zones = () => wrapper.findAll('.bank-bid-storage-zone');
|
||||
expect(zones().wrappers.map((z) => z.attributes('data-district'))).toEqual(['factory', 'warehouse']);
|
||||
expect(zones().wrappers.every((z) => z.attributes('data-owner') === String(player))).toBe(true);
|
||||
expect(zones().wrappers.every((z) => z.attributes('pointer-events') === 'none')).toBe(true);
|
||||
expect(wrapper.findAll('rect[stroke="blue"]').length).toBe(2);
|
||||
own.containersOnFactoryStore.forEach((c) => (c.moved = true));
|
||||
await wrapper.setProps({ state: JSON.parse(JSON.stringify(state)) });
|
||||
bank.vm.$emit('choose-offer', { type: 'cash', lot: 1 });
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(zones().wrappers.map((z) => z.attributes('data-district'))).toEqual(['warehouse']);
|
||||
own.containersOnWarehouseStore = [];
|
||||
await wrapper.setProps({ state: JSON.parse(JSON.stringify(state)) });
|
||||
bank.vm.$emit('choose-offer', { type: 'cash', lot: 1 });
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(zones().length).toBe(0);
|
||||
bank.vm.$emit('cancel-draft');
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(zones().length).toBe(0);
|
||||
expect(normalOutlines).toBeGreaterThan(0);
|
||||
expect(wrapper.findAll('rect[stroke="blue"]').length).toBeGreaterThan(0);
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it('requires explicit confirmation for multiple cargo pieces and supports cancel', async () => {
|
||||
const { wrapper, submitted, factory, warehouse } = gameFixture();
|
||||
wrapper.findComponent(OffshoreBank).vm.$emit('choose-offer', { type: 'cash', lot: 1 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue