Restore open bank berths with player-colored borders and cargo inside
This commit is contained in:
parent
2782601446
commit
1580a03be6
6 changed files with 80 additions and 55 deletions
|
|
@ -78,8 +78,10 @@ lot to offer cash or select stored cargo, then confirm the offer. During payment
|
|||
click a container below the lots; a connecting line and highlighted lot show its
|
||||
fixed destination. Repricing and default choices appear beside the bank.
|
||||
|
||||
Each player's colored bank harbor row contains separate ship and waiting-cargo
|
||||
spaces. Won containers remain in that row until clicked to load on arrival.
|
||||
Each player's open-water berth has solid player-colored piers; shared piers split
|
||||
evenly between adjacent colors. Won containers wait directly in the berth, without
|
||||
a separate holding box or harbor token, until clicked to load on arrival. Cargo
|
||||
moves beside a docked ship within the same unpartitioned berth.
|
||||
Empty harbor rows stay visible, and large cargo lists are paginated. There is no
|
||||
separate expansion banner or collapsible card panel.
|
||||
|
||||
|
|
|
|||
|
|
@ -262,9 +262,9 @@ try {
|
|||
.boundingBox();
|
||||
assert.ok(shipBounds.x + shipBounds.width < holdingBounds.x, 'ship never overlaps waiting cargo');
|
||||
assert.equal(await page.locator('.bank-berth').count(), 3);
|
||||
assert.equal(await ownBerth.locator('[data-piece-id]').count(), 5);
|
||||
assert.equal(await ownBerth.locator('[data-piece-id]').count(), 2);
|
||||
await ownBerth.getByRole('button', { name: 'Next cargo page' }).click();
|
||||
assert.equal(await ownBerth.locator('[data-piece-id]').count(), 3);
|
||||
assert.equal(await ownBerth.locator('[data-piece-id]').count(), 2);
|
||||
await ownBerth.getByRole('button', { name: 'Previous cargo page' }).click();
|
||||
await page.screenshot({ path: `/tmp/container-offshore-harbor-${width}.png`, fullPage: true });
|
||||
// Arrival-only pickup still uses the displayed holding cargo.
|
||||
|
|
@ -375,6 +375,8 @@ try {
|
|||
await push();
|
||||
await page.waitForTimeout(1200);
|
||||
assert.equal(await page.locator('.bank-berth').count(), 5);
|
||||
assert.equal(await page.locator('.bank-berth .player-token, .bank-berth [fill-opacity]').count(), 0);
|
||||
assert.equal(await page.locator('.bank-berth-border[fill="none"][stroke-width="2"]').count(), 5);
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const berth = page.locator(`.bank-berth[data-owner="${i}"]`);
|
||||
const cargo = await berth.locator('.bank-holding').boundingBox();
|
||||
|
|
@ -384,6 +386,8 @@ try {
|
|||
.boundingBox();
|
||||
const bounds = await berth.boundingBox();
|
||||
assert.ok(ship.x + ship.width < cargo.x);
|
||||
assert.ok(cargo.x >= bounds.x && cargo.x + cargo.width <= bounds.x + bounds.width + 1);
|
||||
assert.ok(cargo.y >= bounds.y && cargo.y + cargo.height <= bounds.y + bounds.height);
|
||||
assert.ok(
|
||||
ship.y >= bounds.y - 2 && ship.y + ship.height <= bounds.y + bounds.height + 2,
|
||||
JSON.stringify({ i, ship, bounds })
|
||||
|
|
|
|||
|
|
@ -193,6 +193,21 @@
|
|||
:data="{ type: 'islandHarbor' }"
|
||||
/>
|
||||
|
||||
<template v-if="G && G.options.offshoreIsland">
|
||||
<DropZone
|
||||
v-for="berth in 5"
|
||||
:key="'bank-berth-' + berth"
|
||||
class="bank-harbor"
|
||||
:data-berth="berth - 1"
|
||||
:transform="`translate(336 ${684 + (berth - 1) * 42})`"
|
||||
:width="156"
|
||||
:height="38"
|
||||
:enabled="canMove && player === berth - 1"
|
||||
:accepts="'ship'"
|
||||
:data="{ type: 'offshoreBank' }"
|
||||
:available-moves="getCurrentPlayerMoves()"
|
||||
/>
|
||||
</template>
|
||||
<g v-if="G && G.options.offshoreIsland">
|
||||
<OffshoreBank
|
||||
:selectedOffer="bankDraft"
|
||||
|
|
@ -204,21 +219,6 @@
|
|||
@choose-offer="chooseBankOffer"
|
||||
/>
|
||||
</g>
|
||||
<template v-if="G && G.options.offshoreIsland">
|
||||
<DropZone
|
||||
v-for="berth in 5"
|
||||
:key="'bank-berth-' + berth"
|
||||
class="bank-harbor"
|
||||
:data-berth="berth - 1"
|
||||
:transform="`translate(336 ${684 + (berth - 1) * 42})`"
|
||||
:width="108"
|
||||
:height="38"
|
||||
:enabled="canMove && player === berth - 1"
|
||||
:accepts="'ship'"
|
||||
:data="{ type: 'offshoreBank' }"
|
||||
:available-moves="getCurrentPlayerMoves()"
|
||||
/>
|
||||
</template>
|
||||
<Ship
|
||||
v-for="ship in ships"
|
||||
:key="ship.id"
|
||||
|
|
@ -381,7 +381,7 @@
|
|||
<g
|
||||
v-if="bankDraft && canMove"
|
||||
class="bank-draft"
|
||||
transform="translate(630 680)"
|
||||
transform="translate(520 680)"
|
||||
role="group"
|
||||
:aria-label="bankDraft.type === 'cash' ? 'Offer cargo' : 'Offer cash'"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@
|
|||
</g>
|
||||
<g class="bank-piers" transform="translate(332 680)">
|
||||
<rect width="4" height="214" fill="#c6c6b8" />
|
||||
<rect v-for="i in 6" :key="'pier-' + i" x="4" :y="(i - 1) * 42" width="156" height="4" fill="#c6c6b8" />
|
||||
<g
|
||||
v-for="(p, i) in state.players"
|
||||
:key="i"
|
||||
|
|
@ -123,36 +124,29 @@
|
|||
class="bank-berth"
|
||||
:data-owner="i"
|
||||
>
|
||||
<rect
|
||||
width="268"
|
||||
height="38"
|
||||
:fill="playerColors[i]"
|
||||
fill-opacity=".16"
|
||||
<!-- Shared four-pixel piers split evenly between adjacent owners; water stays open. -->
|
||||
<path
|
||||
class="bank-berth-border"
|
||||
:d="`M156 -1 H-2 V39 H156`"
|
||||
fill="none"
|
||||
:stroke="playerColors[i]"
|
||||
stroke-width="1"
|
||||
stroke-width="2"
|
||||
pointer-events="none"
|
||||
/>
|
||||
<path d="M112 1 V37" :stroke="playerColors[i]" stroke-opacity=".5" pointer-events="none" />
|
||||
<g class="bank-holding" :data-owner="i" transform="translate(112 0)">
|
||||
<path
|
||||
v-if="i === 0 || i === state.players.length - 1"
|
||||
:d="`M0 ${i === 0 ? -3 : 41} H156`"
|
||||
:stroke="playerColors[i]"
|
||||
stroke-width="2"
|
||||
pointer-events="none"
|
||||
/>
|
||||
<rect x="-4" y="0" width="4" height="38" :fill="playerColors[i]" pointer-events="none" />
|
||||
<g class="bank-holding" :data-owner="i" :transform="docked(i) ? 'translate(104 3)' : 'translate(8 3)'">
|
||||
<title>{{ owner(i) }}: waiting cargo</title>
|
||||
<PlayerToken transform="translate(12 19)" :owner="i" :name="owner(i)" :color="playerColors[i]" />
|
||||
<rect
|
||||
v-if="!p.bankHolding?.length"
|
||||
x="28"
|
||||
y="3"
|
||||
width="20"
|
||||
height="10"
|
||||
rx="1"
|
||||
fill="none"
|
||||
:stroke="playerColors[i]"
|
||||
stroke-opacity=".4"
|
||||
stroke-dasharray="2 2"
|
||||
pointer-events="none"
|
||||
/>
|
||||
<OffshoreCargo
|
||||
:pieces="p.bankHolding || []"
|
||||
transform="translate(28 3)"
|
||||
:columns="5"
|
||||
:columns="docked(i) ? 2 : 6"
|
||||
:compact-pagination="docked(i)"
|
||||
:rows="1"
|
||||
:selectable="
|
||||
canAct && i === player
|
||||
|
|
@ -168,7 +162,7 @@
|
|||
<g
|
||||
v-if="bank.decision"
|
||||
class="bank-decision"
|
||||
:transform="bank.decision.kind === 'distribute' ? 'translate(20 950)' : 'translate(630 680)'"
|
||||
:transform="bank.decision.kind === 'distribute' ? 'translate(20 950)' : 'translate(520 680)'"
|
||||
>
|
||||
<text v-if="decisionTitle" x="0" y="0" font-size="14">{{ decisionTitle }}</text>
|
||||
<g
|
||||
|
|
@ -265,7 +259,7 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { BankAuction, BankAuctionType, GameState } from 'container-engine/src/gamestate';
|
||||
import { BankAuction, BankAuctionType, GameState, ShipPosition } from 'container-engine/src/gamestate';
|
||||
import { AvailableMoves } from 'container-engine/src/available-moves';
|
||||
import { playerColors } from 'container-engine/src/engine';
|
||||
import { Move, MoveName, Moves } from 'container-engine/src/move';
|
||||
|
|
@ -340,6 +334,9 @@ export default class OffshoreBank extends Vue {
|
|||
const lots = [0, 1, 2].filter((i) => !this.bank?.auctions.some((a) => a.type === 'containers' && a.lot === i));
|
||||
return lots[(this.bank?.decision?.cursor || 0) % lots.length];
|
||||
}
|
||||
docked(index: number) {
|
||||
return this.state.players[index].ship.shipPosition === ShipPosition.OffshoreBank;
|
||||
}
|
||||
owner(index: number) {
|
||||
return this.state.players[index]?.name || String(index + 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,21 +39,31 @@
|
|||
@keydown.enter.prevent.stop="page = (currentPage + pages - 1) % pages"
|
||||
@keydown.space.prevent.stop="page = (currentPage + pages - 1) % pages"
|
||||
>
|
||||
<rect width="20" height="16" fill="#c6c6b8" /><text x="10" y="12" text-anchor="middle" font-size="12"
|
||||
<rect :width="compactPagination ? 12 : 20" height="16" fill="#c6c6b8" /><text
|
||||
:x="compactPagination ? 6 : 10"
|
||||
y="12"
|
||||
text-anchor="middle"
|
||||
font-size="12"
|
||||
>‹</text
|
||||
>
|
||||
</g>
|
||||
<text x="23" y="12" font-size="8">{{ currentPage + 1 }}/{{ pages }}</text>
|
||||
<text :x="compactPagination ? 14 : 23" y="12" :font-size="compactPagination ? 6 : 8"
|
||||
>{{ currentPage + 1 }}/{{ pages }}</text
|
||||
>
|
||||
<g
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Next cargo page"
|
||||
:transform="`translate(${columns * 23 - 22} 0)`"
|
||||
:transform="`translate(${columns * 23 - (compactPagination ? 14 : 22)} 0)`"
|
||||
@click.stop="page = (currentPage + 1) % pages"
|
||||
@keydown.enter.prevent.stop="page = (currentPage + 1) % pages"
|
||||
@keydown.space.prevent.stop="page = (currentPage + 1) % pages"
|
||||
>
|
||||
<rect width="20" height="16" fill="#c6c6b8" /><text x="10" y="12" text-anchor="middle" font-size="12"
|
||||
<rect :width="compactPagination ? 12 : 20" height="16" fill="#c6c6b8" /><text
|
||||
:x="compactPagination ? 6 : 10"
|
||||
y="12"
|
||||
text-anchor="middle"
|
||||
font-size="12"
|
||||
>›</text
|
||||
>
|
||||
</g>
|
||||
|
|
@ -72,6 +82,7 @@ export default class OffshoreCargo extends Vue {
|
|||
@Prop({ default: () => [] }) selected!: string[];
|
||||
@Prop({ default: '' }) actionLabel!: string;
|
||||
@Prop({ default: 3 }) columns!: number;
|
||||
@Prop({ default: false }) compactPagination!: boolean;
|
||||
|
||||
@Prop({ default: 2 }) rows!: number;
|
||||
page = 0;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ describe('Offshore bank viewer', () => {
|
|||
);
|
||||
});
|
||||
expect(wrapper.findAll('.bank-board text').wrappers.some((text) => text.text().includes(name))).toBe(false);
|
||||
expect(wrapper.findAllComponents(PlayerToken).length).toBe(2 + state.players.length);
|
||||
expect(wrapper.findAllComponents(PlayerToken).length).toBe(2);
|
||||
wrapper.destroy();
|
||||
}
|
||||
});
|
||||
|
|
@ -350,7 +350,7 @@ describe('Offshore bank viewer', () => {
|
|||
expect(berths.length).toBe(5);
|
||||
berths.wrappers.forEach((berth, i) => {
|
||||
expect(berth.attributes('transform')).toBe(`translate(336 ${684 + i * 42})`);
|
||||
expect(berth.props('width')).toBe(108);
|
||||
expect(berth.props('width')).toBe(156);
|
||||
expect(berth.props('height')).toBe(38);
|
||||
expect(berth.props('enabled')).toBe(i === state.currentPlayers[0]);
|
||||
});
|
||||
|
|
@ -367,7 +367,7 @@ describe('Offshore bank viewer', () => {
|
|||
game.destroy();
|
||||
});
|
||||
|
||||
it('reserves colored ship and cargo bays for all five players, even when empty', async () => {
|
||||
it('outlines open berths with solid split piers and places cargo directly in the water', async () => {
|
||||
const state = setup(5, { offshoreIsland: true }, 'bank-holding-berths');
|
||||
const player = state.currentPlayers[0];
|
||||
const colors = ['#123456', '#234567', '#345678', '#456789', '#56789a'];
|
||||
|
|
@ -384,15 +384,26 @@ describe('Offshore bank viewer', () => {
|
|||
expect(wrapper.findAll('.bank-berth')).toHaveLength(5);
|
||||
wrapper.findAll('.bank-berth').wrappers.forEach((berth, i) => {
|
||||
expect(berth.attributes('transform')).toBe(`translate(4 ${i * 42 + 4})`);
|
||||
expect(berth.find('rect').attributes('fill')).toBe(colors[i]);
|
||||
expect(berth.find('.player-token text').text()).toBe(String(i + 1));
|
||||
expect(berth.find('.bank-holding').attributes('transform')).toBe('translate(112 0)');
|
||||
expect(berth.find('.bank-berth-border').attributes('stroke')).toBe(colors[i]);
|
||||
expect(berth.find('.bank-berth-border').attributes('fill')).toBe('none');
|
||||
expect(berth.find('.bank-berth-border').attributes('stroke-width')).toBe('2');
|
||||
expect(berth.find('.bank-berth-border').attributes('d')).toBe('M156 -1 H-2 V39 H156');
|
||||
expect(berth.find('.player-token').exists()).toBe(false);
|
||||
expect(berth.find('[fill-opacity]').exists()).toBe(false);
|
||||
expect(berth.find('.bank-holding').attributes('transform')).toBe('translate(104 3)');
|
||||
});
|
||||
expect(wrapper.find(`.bank-berth[data-owner="${player}"] [data-piece-id]`).exists()).toBe(false);
|
||||
const holding = wrapper.find(`.bank-holding[data-owner="${other}"]`);
|
||||
expect(holding.findAll('[data-piece-id]')).toHaveLength(5);
|
||||
expect(holding.findAll('[data-piece-id]')).toHaveLength(2);
|
||||
await holding.find('[aria-label="Next cargo page"]').trigger('click');
|
||||
expect(holding.findAll('[data-piece-id]')).toHaveLength(3);
|
||||
expect(holding.findAll('[data-piece-id]')).toHaveLength(2);
|
||||
state.players[other].ship.shipPosition = ShipPosition.OpenSea;
|
||||
await wrapper.setProps({ state: { ...state } });
|
||||
await holding.find('[aria-label="Previous cargo page"]').trigger('click');
|
||||
expect(holding.attributes('transform')).toBe('translate(8 3)');
|
||||
expect(holding.findAll('[data-piece-id]')).toHaveLength(6);
|
||||
await holding.find('[aria-label="Next cargo page"]').trigger('click');
|
||||
expect(holding.findAll('[data-piece-id]')).toHaveLength(2);
|
||||
await wrapper.setProps({ player: undefined });
|
||||
expect(wrapper.findAll('.bank-berth')).toHaveLength(5);
|
||||
expect(wrapper.find('.bank-holding [data-piece-id][role="button"]').exists()).toBe(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue