Move bid draft cargo, frame returned containers above bank and simplify win logs
This commit is contained in:
parent
b66e79aa9a
commit
f9a3804512
26 changed files with 467 additions and 79 deletions
|
|
@ -76,9 +76,16 @@ adds a lower bank area without shifting the classic board coordinates. On mobile
|
|||
the **Bank** navigation button brings that area into view.
|
||||
|
||||
Each lot separates its reward from the current bidder's token and bid. Click a
|
||||
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.
|
||||
lot to offer cash or select stored cargo, then confirm the offer. Selected draft
|
||||
cargo moves visually from its store to the bidding area; click it there to remove
|
||||
it from the draft and return it to the original store. Cancelling returns all draft
|
||||
cargo. These previews do not change the engine state until the offer is confirmed.
|
||||
During payment, click a container below the lots; a connecting line and highlighted
|
||||
lot show its fixed destination. For outbid cargo, select a container in the framed
|
||||
**Returned containers** tray above the bank and choose a highlighted price space
|
||||
in its original store. Default choices appear
|
||||
beside the bank. Bank transfers and draft selection use brief container animations,
|
||||
with reduced-motion preferences respected.
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -52,15 +52,42 @@ try {
|
|||
frames,
|
||||
holding: this.closest('.bank-holding')?.getAttribute('data-owner'),
|
||||
copies: [...document.querySelectorAll('[data-piece-id]')].filter(
|
||||
(node) =>
|
||||
node.getAttribute('data-piece-id') === this.getAttribute('data-piece-id') &&
|
||||
!node.closest('.bank-lot-draft')
|
||||
(node) => node.getAttribute('data-piece-id') === this.getAttribute('data-piece-id')
|
||||
).length,
|
||||
});
|
||||
}
|
||||
return animate.call(this, frames, options);
|
||||
};
|
||||
});
|
||||
const checkReturnTray = async () => {
|
||||
const geometry = await page.evaluate(() => {
|
||||
const tray = document.querySelector('.bank-return-tray').getBoundingClientRect();
|
||||
const decision = document.querySelector('.bank-decision');
|
||||
const inside = [...decision.querySelectorAll('[data-piece-id], [role="button"], text')].every(
|
||||
(node) => {
|
||||
const r = node.getBoundingClientRect();
|
||||
return (
|
||||
r.left >= tray.left - 1 &&
|
||||
r.right <= tray.right + 1 &&
|
||||
r.top >= tray.top - 1 &&
|
||||
r.bottom <= tray.bottom + 1
|
||||
);
|
||||
}
|
||||
);
|
||||
const clear = [
|
||||
...document.querySelectorAll('.bank-board, .bank-piers, .point-card, .piece, .island-value'),
|
||||
].every((node) => {
|
||||
const r = node.getBoundingClientRect();
|
||||
return r.right <= tray.left || r.left >= tray.right || r.bottom <= tray.top || r.top >= tray.bottom;
|
||||
});
|
||||
return {
|
||||
inside,
|
||||
clear,
|
||||
aboveBank: tray.bottom < document.querySelector('.bank-board').getBoundingClientRect().top,
|
||||
};
|
||||
});
|
||||
assert.deepEqual(geometry, { inside: true, clear: true, aboveBank: true });
|
||||
};
|
||||
const errors = [];
|
||||
page.on('pageerror', (e) => errors.push(e.message));
|
||||
page.on('console', (msg) => {
|
||||
|
|
@ -236,23 +263,66 @@ try {
|
|||
await page.locator(`.piece.bid-eligible[data-piece-id="${second.id}"]`).click();
|
||||
assert.equal(await page.evaluate(() => moves.length), 0, 'selection never auto-submits');
|
||||
assert.equal(await page.locator('.piece.canDrag, .loan.canDrag, .offshore-lot.legal').count(), 0);
|
||||
assert.equal(await page.locator('.piece.bid-selected').count(), 2);
|
||||
assert.equal(await page.locator('.piece.bid-selected').count(), 0);
|
||||
for (const id of [offered.id, second.id])
|
||||
assert.equal(await page.locator(`[data-piece-id="${id}"]`).count(), 1, 'draft has no store duplicate');
|
||||
assert.equal(
|
||||
await page.locator('rect[stroke="blue"]').count(),
|
||||
2,
|
||||
'only the two eligible own storage zones have action outlines'
|
||||
);
|
||||
const originalStore = copy(state.players[player]);
|
||||
const draftPiece = () => page.locator(`.bank-lot-draft [data-piece-id="${second.id}"]`);
|
||||
await page.waitForTimeout(350);
|
||||
await draftPiece().focus();
|
||||
await draftPiece().press('Space');
|
||||
const selectedPiece = page.locator(`.piece[data-piece-id="${second.id}"]`);
|
||||
assert.equal(await selectedPiece.count(), 1);
|
||||
assert.equal(await draftPiece().count(), 0);
|
||||
await selectedPiece.focus();
|
||||
await selectedPiece.press('Space');
|
||||
assert.equal(await selectedPiece.getAttribute('aria-pressed'), 'false');
|
||||
await selectedPiece.press('Enter');
|
||||
assert.equal(await selectedPiece.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(await selectedPiece.count(), 0);
|
||||
assert.equal(await draftPiece().count(), 1);
|
||||
await draftPiece().focus();
|
||||
await draftPiece().press('Enter');
|
||||
assert.equal(await selectedPiece.count(), 1);
|
||||
await selectedPiece.click();
|
||||
const draftAnimations = await page.evaluate(() => cargoAnimations);
|
||||
assert.ok(draftAnimations.filter((a) => a.id === second.id).length >= 5, 'draft selection and removal animate');
|
||||
assert.ok(
|
||||
draftAnimations.every((a) => a.copies === 1),
|
||||
'animation never introduces a duplicate'
|
||||
);
|
||||
assert.deepEqual(state.players[player], originalStore, 'local draft never changes engine stores or money');
|
||||
const returnAnimation = draftAnimations.filter((a) => a.id === second.id)[1];
|
||||
assert.notEqual(
|
||||
returnAnimation.frames[0].transform,
|
||||
returnAnimation.frames[1].transform,
|
||||
'removal travels back to storage'
|
||||
);
|
||||
await page.waitForTimeout(350);
|
||||
const animationsBeforeSwitch = await page.evaluate(() => cargoAnimations.length);
|
||||
await page.locator('.offshore-lot[data-type="cash"][data-lot="0"]').click();
|
||||
assert.equal(await page.locator('.bank-lot-draft [data-piece-id]').count(), 0);
|
||||
for (const id of [offered.id, second.id]) {
|
||||
assert.equal(await page.locator(`[data-piece-id="${id}"]`).count(), 1);
|
||||
assert.equal(
|
||||
await page.locator(`.piece[data-piece-id="${id}"]`).count(),
|
||||
1,
|
||||
'switch restores original store'
|
||||
);
|
||||
}
|
||||
const returnAnimations = await page.evaluate((count) => cargoAnimations.slice(count), animationsBeforeSwitch);
|
||||
assert.equal(returnAnimations.length, 2, 'switch cancels draft with both return animations');
|
||||
assert.ok(returnAnimations.every((a) => a.copies === 1));
|
||||
await page.locator('.offshore-lot[data-type="cash"][data-lot="1"]').click();
|
||||
for (const id of [offered.id, second.id]) await page.locator(`.piece[data-piece-id="${id}"]`).click();
|
||||
|
||||
if (width < 600) await page.locator('.player-board-tab').nth(player).click();
|
||||
await page.screenshot({ path: `/tmp/container-offshore-cargo-focus-${width}.png`, fullPage: true });
|
||||
|
||||
await page.locator(`.piece.bid-eligible[data-piece-id="${offered.id}"]`).click();
|
||||
await page.locator(`.piece.bid-eligible[data-piece-id="${second.id}"]`).click();
|
||||
await page.locator(`.bank-lot-draft [data-piece-id="${offered.id}"]`).click();
|
||||
await page.locator(`.bank-lot-draft [data-piece-id="${second.id}"]`).click();
|
||||
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);
|
||||
|
|
@ -265,7 +335,11 @@ try {
|
|||
await page.locator(`.piece.bid-eligible[data-piece-id="${second.id}"]`).click();
|
||||
if (width < 600) {
|
||||
await page.getByRole('button', { name: 'Bid (2)', exact: true }).click();
|
||||
assert.equal(await page.locator('.piece.bid-selected').count(), 2, 'navigation preserves draft');
|
||||
assert.equal(
|
||||
await page.locator('.bank-lot-draft [data-piece-id]').count(),
|
||||
2,
|
||||
'navigation preserves draft'
|
||||
);
|
||||
}
|
||||
await checkDraft('cash', 1);
|
||||
await page.screenshot({ path: `/tmp/container-offshore-cargo-draft-${width}.png`, fullPage: true });
|
||||
|
|
@ -283,6 +357,24 @@ try {
|
|||
assert.deepEqual(cargoBid.at(-1).extraData.containers, [offered.id, second.id]);
|
||||
for (const action of cargoBid) state = engine.move(state, action, player);
|
||||
await push();
|
||||
assert.equal(await page.locator('.bank-lot-draft').count(), 0);
|
||||
for (const id of [offered.id, second.id]) {
|
||||
assert.equal(
|
||||
await page.locator(`[data-piece-id="${id}"]`).count(),
|
||||
1,
|
||||
'confirmed escrow has no duplicates'
|
||||
);
|
||||
assert.equal(await page.locator(`.piece[data-piece-id="${id}"]`).count(), 0);
|
||||
}
|
||||
assert.deepEqual(
|
||||
state.offshoreBank.auctions
|
||||
.find((a) => a.type === 'cash' && a.lot === 1)
|
||||
.containers.map((c) => [c.district, c.container.price]),
|
||||
[
|
||||
['factory', originalStore.containersOnFactoryStore[0].price],
|
||||
['warehouse', 3],
|
||||
]
|
||||
);
|
||||
|
||||
await page.locator('.board-scroll').evaluate((el) => {
|
||||
el.scrollLeft = 0;
|
||||
|
|
@ -309,7 +401,9 @@ try {
|
|||
host.emit('player', { index: undefined });
|
||||
host.emit('state', state);
|
||||
}, engine.stripSecret(copy(state)));
|
||||
await page.waitForFunction(() => document.querySelector('.bank-decision')?.textContent.includes('Outbid'));
|
||||
await page.waitForFunction(() =>
|
||||
document.querySelector('.bank-decision')?.textContent.includes('Returned containers')
|
||||
);
|
||||
assert.equal(
|
||||
await page.locator('.bank-decision [data-piece-id]').count(),
|
||||
1,
|
||||
|
|
@ -320,8 +414,11 @@ try {
|
|||
0,
|
||||
'spectator has no decision controls'
|
||||
);
|
||||
await checkReturnTray();
|
||||
await page.evaluate((player) => host.emit('player', { index: player }), player);
|
||||
await push();
|
||||
await checkReturnTray();
|
||||
await page.screenshot({ path: `/tmp/container-offshore-return-tray-${width}.png`, fullPage: true });
|
||||
await page.locator('.bank-choice [data-piece-id]').click();
|
||||
await page.getByRole('button', { name: 'Return to factory store at $3', exact: true }).click();
|
||||
const repricing = await page.evaluate(() => moves.at(-1));
|
||||
|
|
@ -559,6 +656,29 @@ try {
|
|||
}, engine.stripSecret(copy(state)));
|
||||
assert.equal(await page.locator('.bank-holding [data-piece-id][role="button"]').count(), 0);
|
||||
assert.equal(await page.locator('.bank-harbor.canClick').count(), 0);
|
||||
// A large pending return remains bounded with all five berths populated, including spectators.
|
||||
state.phase = 'bankDecision';
|
||||
state.offshoreBank.decision = {
|
||||
kind: 'return',
|
||||
player,
|
||||
resumePlayer: player,
|
||||
containers: state.containersLeft
|
||||
.splice(0)
|
||||
.map((piece) => ({ container: { piece, price: 2, moved: false }, district: 'factory' })),
|
||||
payment: [],
|
||||
cursor: 0,
|
||||
};
|
||||
await page.evaluate((state) => host.emit('state', state), engine.stripSecret(copy(state)));
|
||||
await page.waitForSelector('.bank-return-tray');
|
||||
await checkReturnTray();
|
||||
await page.locator('.bank-decision [aria-label="Next cargo page"]').click();
|
||||
await checkReturnTray();
|
||||
await page.screenshot({ path: `/tmp/container-offshore-return-spectator-${width}.png`, fullPage: true });
|
||||
await page.evaluate((player) => host.emit('player', { index: player }), player);
|
||||
await push();
|
||||
await checkReturnTray();
|
||||
await page.locator('.bank-decision .button').click();
|
||||
await checkReturnTray();
|
||||
// A real pass settles a cash bid for containers and appends an upkeep event.
|
||||
// Both prize pieces must visibly move from their lot into the winner's holding.
|
||||
state = engine.setup(3, { offshoreIsland: true }, 'offshore-browser');
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@
|
|||
:valid-draft="validContainerBid"
|
||||
@confirm-draft="confirmBankContainers"
|
||||
@cancel-draft="resetBankDraft"
|
||||
@remove-draft="toggleBankContainer"
|
||||
:state="G"
|
||||
:player="player"
|
||||
:player-colors="playerColors"
|
||||
|
|
@ -243,6 +244,7 @@
|
|||
|
||||
<template v-for="container in containers">
|
||||
<Container
|
||||
v-if="!bankCashOffer || !offshoreContainers.has(container.id)"
|
||||
ref="containerPieces"
|
||||
:key="container.id"
|
||||
:pieceId="container.id"
|
||||
|
|
@ -1640,7 +1642,14 @@ export default class Game extends Vue {
|
|||
@Watch('G')
|
||||
@Watch('player')
|
||||
@Watch('interactionDisabled')
|
||||
resetBankDraft() {
|
||||
resetBankDraftForState() {
|
||||
this.resetBankDraft(false);
|
||||
}
|
||||
resetBankDraft(animate = true) {
|
||||
if (animate && this.bankCashOffer && this.offshoreContainers.size)
|
||||
this.offshoreMotion.draftTransition(this.$el, this.offshoreContainers, (callback) =>
|
||||
this.$nextTick(callback)
|
||||
);
|
||||
this.selectedBankReturn = null;
|
||||
this.bankDraft = null;
|
||||
this.offshoreContainers = new Set();
|
||||
|
|
@ -1720,7 +1729,7 @@ export default class Game extends Vue {
|
|||
}
|
||||
sendBankMove(action: Move) {
|
||||
if (this.canMove && this.G && legalBankAction(this.G, this.player, action)) {
|
||||
this.resetBankDraft();
|
||||
this.resetBankDraft(false);
|
||||
this.sendMove(action);
|
||||
} else this.bankBidError = true;
|
||||
}
|
||||
|
|
@ -1789,6 +1798,7 @@ export default class Game extends Vue {
|
|||
}
|
||||
toggleBankContainer(id: string) {
|
||||
if (!this.bankContainerHighlights.includes(id)) return;
|
||||
this.offshoreMotion.draftTransition(this.$el, [id], (callback) => this.$nextTick(callback));
|
||||
const selected = new Set(this.offshoreContainers);
|
||||
if (selected.has(id)) selected.delete(id);
|
||||
else selected.add(id);
|
||||
|
|
@ -2214,10 +2224,11 @@ export default class Game extends Vue {
|
|||
logReversed.push('New phase: ' + log.phase);
|
||||
} else if (log.type == 'event') {
|
||||
if (log.event.name == GameEventName.Upkeep) {
|
||||
const bankWin = offshoreWinJournal(log.event.interest, this.G!);
|
||||
logReversed.push(
|
||||
'New event: ' +
|
||||
(bankWin === undefined ? 'New event: ' : '') +
|
||||
journalPieces(
|
||||
offshoreWinJournal(log.event.interest, this.G!) ?? log.event.interest,
|
||||
bankWin ?? log.event.interest,
|
||||
this.preferences.colorBlind,
|
||||
this.playerColors
|
||||
)
|
||||
|
|
@ -2247,7 +2258,9 @@ export default class Game extends Vue {
|
|||
logReversed.push('New phase: ' + log.phase);
|
||||
} else if (log.type == 'event') {
|
||||
if (log.event.name == GameEventName.Upkeep) {
|
||||
logReversed.push('New event: ' + log.event.interest);
|
||||
logReversed.push(
|
||||
offshoreWinJournal(log.event.interest, this.G!, false) ?? 'New event: ' + log.event.interest
|
||||
);
|
||||
} else {
|
||||
logReversed.push('New event: ' + log.event.name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,15 @@
|
|||
:name="owner(player)"
|
||||
:color="playerColors[player]"
|
||||
/>
|
||||
<OffshoreCargo :pieces="draftCargo" transform="translate(32 69)" :columns="2" :rows="1" />
|
||||
<OffshoreCargo
|
||||
:pieces="draftCargo"
|
||||
:selectable="draftCargo.map((piece) => piece.id)"
|
||||
action-label="Remove from bid"
|
||||
transform="translate(32 69)"
|
||||
:columns="2"
|
||||
:rows="1"
|
||||
@select="$emit('remove-draft', $event)"
|
||||
/>
|
||||
</g>
|
||||
<g v-else-if="auction(type, i - 1)">
|
||||
<PlayerToken
|
||||
|
|
@ -190,9 +198,37 @@
|
|||
<g
|
||||
v-if="bank.decision"
|
||||
class="bank-decision"
|
||||
:transform="bank.decision.kind !== 'seize' ? 'translate(20 950)' : 'translate(520 680)'"
|
||||
:transform="
|
||||
bank.decision.kind === 'return'
|
||||
? 'translate(140 480)'
|
||||
: bank.decision.kind === 'distribute'
|
||||
? 'translate(20 950)'
|
||||
: 'translate(520 680)'
|
||||
"
|
||||
>
|
||||
<text v-if="decisionTitle" x="0" y="-12" font-size="14">{{ decisionTitle }}</text>
|
||||
<!-- Between the point card and open sea, clear of all five players' harbors and the bid draft. -->
|
||||
<rect
|
||||
v-if="bank.decision.kind === 'return'"
|
||||
class="bank-return-tray"
|
||||
x="-8"
|
||||
y="-30"
|
||||
width="136"
|
||||
height="150"
|
||||
rx="4"
|
||||
fill="#e2e0d3"
|
||||
fill-opacity=".45"
|
||||
stroke="#899997"
|
||||
pointer-events="none"
|
||||
/>
|
||||
<text
|
||||
v-if="decisionTitle"
|
||||
x="0"
|
||||
y="-12"
|
||||
:font-size="bank.decision.kind === 'return' ? 12 : 14"
|
||||
:textLength="bank.decision.kind === 'return' ? 120 : undefined"
|
||||
lengthAdjust="spacingAndGlyphs"
|
||||
>{{ decisionTitle }}</text
|
||||
>
|
||||
<g
|
||||
v-if="bank.decision.kind === 'distribute'"
|
||||
class="bank-payment-route"
|
||||
|
|
@ -208,16 +244,16 @@
|
|||
</g>
|
||||
<template v-if="!decisionMoves.length">
|
||||
<PlayerToken
|
||||
transform="translate(9 20)"
|
||||
:transform="bank.decision.kind === 'return' ? 'translate(9 0)' : 'translate(9 20)'"
|
||||
:owner="bank.decision.player"
|
||||
:name="owner(bank.decision.player)"
|
||||
:color="playerColors[bank.decision.player]"
|
||||
/>
|
||||
<OffshoreCargo
|
||||
:pieces="pendingCargo"
|
||||
transform="translate(0 35)"
|
||||
:columns="10"
|
||||
:rows="bank.decision.kind === 'distribute' ? 2 : 8"
|
||||
:transform="bank.decision.kind === 'return' ? 'translate(0 20)' : 'translate(0 35)'"
|
||||
:columns="bank.decision.kind === 'return' ? 5 : 10"
|
||||
:rows="bank.decision.kind === 'return' ? 4 : bank.decision.kind === 'distribute' ? 2 : 8"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
|
@ -226,7 +262,9 @@
|
|||
:key="choice.data.id"
|
||||
class="bank-choice"
|
||||
:transform="
|
||||
bank.decision.kind !== 'seize'
|
||||
bank.decision.kind === 'return'
|
||||
? `translate(${(index % 2) * 60} ${Math.floor(index / 2) * 35})`
|
||||
: bank.decision.kind !== 'seize'
|
||||
? `translate(${index * 70} 0)`
|
||||
: `translate(0 ${40 + index * 35})`
|
||||
"
|
||||
|
|
@ -263,7 +301,13 @@
|
|||
</g>
|
||||
<Button
|
||||
v-if="decisionPages > 1"
|
||||
:transform="bank.decision.kind !== 'seize' ? 'translate(0 40)' : 'translate(0 190)'"
|
||||
:transform="
|
||||
bank.decision.kind === 'return'
|
||||
? 'translate(0 85)'
|
||||
: bank.decision.kind !== 'seize'
|
||||
? 'translate(0 40)'
|
||||
: 'translate(0 190)'
|
||||
"
|
||||
:width="100"
|
||||
:text="'More ' + (decisionPage + 1) + '/' + decisionPages"
|
||||
@click="decisionPage = (decisionPage + 1) % decisionPages"
|
||||
|
|
@ -348,7 +392,7 @@ export default class OffshoreBank extends Vue {
|
|||
}
|
||||
get decisionTitle() {
|
||||
return this.bank?.decision?.kind === 'return'
|
||||
? 'Outbid containers'
|
||||
? 'Returned containers'
|
||||
: this.bank?.decision?.kind === 'seize'
|
||||
? 'Loan default'
|
||||
: '';
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Betal til containerparti {p0}: brun container",
|
||||
"Pay into container lot {p0}: dark green container": "Betal til containerparti {p0}: mørkegrøn container",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} vinder bankens containerparti {p1}",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} vinder bankens pengeparti {p1}"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} vinder bankens pengeparti {p1}",
|
||||
"Remove from bid": "Fjern fra bud",
|
||||
"Returned containers": "Returnerede containere"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "In Containerlos {p0} einzahlen: brauner Container",
|
||||
"Pay into container lot {p0}: dark green container": "In Containerlos {p0} einzahlen: dunkelgrüner Container",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} gewinnt Containerlos {p1} der Bank",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} gewinnt Geldlos {p1} der Bank"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} gewinnt Geldlos {p1} der Bank",
|
||||
"Remove from bid": "Aus Gebot entfernen",
|
||||
"Returned containers": "Zurückgegebene Container"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Πλήρωσε στην παρτίδα εμπορευματοκιβωτίων {p0}: καφέ εμπορευματοκιβώτιο",
|
||||
"Pay into container lot {p0}: dark green container": "Πλήρωσε στην παρτίδα εμπορευματοκιβωτίων {p0}: σκούρο πράσινο εμπορευματοκιβώτιο",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} κερδίζει την παρτίδα εμπορευματοκιβωτίων {p1} της τράπεζας",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} κερδίζει την παρτίδα μετρητών {p1} της τράπεζας"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} κερδίζει την παρτίδα μετρητών {p1} της τράπεζας",
|
||||
"Remove from bid": "Αφαίρεση από την προσφορά",
|
||||
"Returned containers": "Επιστραφέντα κοντέινερ"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Pay into container lot {p0}: brown container",
|
||||
"Pay into container lot {p0}: dark green container": "Pay into container lot {p0}: dark green container",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} wins bank containers lot {p1}",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} wins bank cash lot {p1}"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} wins bank cash lot {p1}",
|
||||
"Remove from bid": "Remove from bid",
|
||||
"Returned containers": "Returned containers"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "پرداخت به بستهٔ کانتینر {p0}: کانتینر قهوهای",
|
||||
"Pay into container lot {p0}: dark green container": "پرداخت به بستهٔ کانتینر {p0}: کانتینر سبز تیره",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} برندهٔ بستهٔ کانتینر {p1} بانک میشود",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} برندهٔ بستهٔ پول نقد {p1} بانک میشود"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} برندهٔ بستهٔ پول نقد {p1} بانک میشود",
|
||||
"Remove from bid": "حذف از پیشنهاد",
|
||||
"Returned containers": "کانتینرهای بازگرداندهشده"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Payer dans le lot de conteneurs {p0} : conteneur marron",
|
||||
"Pay into container lot {p0}: dark green container": "Payer dans le lot de conteneurs {p0} : conteneur vert foncé",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} remporte le lot de conteneurs {p1} de la banque",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} remporte le lot d’argent {p1} de la banque"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} remporte le lot d’argent {p1} de la banque",
|
||||
"Remove from bid": "Retirer de l’enchère",
|
||||
"Returned containers": "Conteneurs restitués"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "कंटेनर लॉट {p0} में भुगतान करें: भूरा कंटेनर",
|
||||
"Pay into container lot {p0}: dark green container": "कंटेनर लॉट {p0} में भुगतान करें: गहरा हरा कंटेनर",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} बैंक का कंटेनर लॉट {p1} जीतता है",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} बैंक का नकदी लॉट {p1} जीतता है"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} बैंक का नकदी लॉट {p1} जीतता है",
|
||||
"Remove from bid": "बोली से हटाएँ",
|
||||
"Returned containers": "वापस किए गए कंटेनर"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Paga nel lotto di container {p0}: container marrone",
|
||||
"Pay into container lot {p0}: dark green container": "Paga nel lotto di container {p0}: container verde scuro",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} si aggiudica il lotto di container {p1} della banca",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} si aggiudica il lotto di denaro {p1} della banca"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} si aggiudica il lotto di denaro {p1} della banca",
|
||||
"Remove from bid": "Rimuovi dall’offerta",
|
||||
"Returned containers": "Container restituiti"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "컨테이너 경매 물품 {p0}에 지불: 갈색 컨테이너",
|
||||
"Pay into container lot {p0}: dark green container": "컨테이너 경매 물품 {p0}에 지불: 짙은 녹색 컨테이너",
|
||||
"{p0} wins bank containers lot {p1}": "{p0}: 은행 컨테이너 경매 물품 {p1} 낙찰",
|
||||
"{p0} wins bank cash lot {p1}": "{p0}: 은행 현금 경매 물품 {p1} 낙찰"
|
||||
"{p0} wins bank cash lot {p1}": "{p0}: 은행 현금 경매 물품 {p1} 낙찰",
|
||||
"Remove from bid": "입찰에서 제외",
|
||||
"Returned containers": "반환된 컨테이너"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Betalen in containerkavel {p0}: bruine container",
|
||||
"Pay into container lot {p0}: dark green container": "Betalen in containerkavel {p0}: donkergroene container",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} wint containerkavel {p1} van de bank",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} wint geldkavel {p1} van de bank"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} wint geldkavel {p1} van de bank",
|
||||
"Remove from bid": "Uit bod verwijderen",
|
||||
"Returned containers": "Teruggegeven containers"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Zapłać do puli kontenerów {p0}: brązowy kontener",
|
||||
"Pay into container lot {p0}: dark green container": "Zapłać do puli kontenerów {p0}: ciemnozielony kontener",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} wygrywa bankową pulę kontenerów {p1}",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} wygrywa bankową pulę gotówki {p1}"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} wygrywa bankową pulę gotówki {p1}",
|
||||
"Remove from bid": "Usuń z oferty",
|
||||
"Returned containers": "Zwrócone kontenery"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Pagar no lote de contêineres {p0}: contêiner marrom",
|
||||
"Pay into container lot {p0}: dark green container": "Pagar no lote de contêineres {p0}: contêiner verde-escuro",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} ganha o lote de contêineres {p1} do banco",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} ganha o lote de dinheiro {p1} do banco"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} ganha o lote de dinheiro {p1} do banco",
|
||||
"Remove from bid": "Remover do lance",
|
||||
"Returned containers": "Contêineres devolvidos"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Plătește în lotul de containere {p0}: container maro",
|
||||
"Pay into container lot {p0}: dark green container": "Plătește în lotul de containere {p0}: container verde închis",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} câștigă lotul de containere {p1} al băncii",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} câștigă lotul de bani {p1} al băncii"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} câștigă lotul de bani {p1} al băncii",
|
||||
"Remove from bid": "Elimină din ofertă",
|
||||
"Returned containers": "Containere returnate"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Внести в оплату в лот контейнеров {p0}: коричневый контейнер",
|
||||
"Pay into container lot {p0}: dark green container": "Внести в оплату в лот контейнеров {p0}: тёмно-зелёный контейнер",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} выигрывает лот контейнеров {p1} банка",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} выигрывает денежный лот {p1} банка"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} выигрывает денежный лот {p1} банка",
|
||||
"Remove from bid": "Убрать из ставки",
|
||||
"Returned containers": "Возвращённые контейнеры"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "Thanh toán vào lô container {p0}: container nâu",
|
||||
"Pay into container lot {p0}: dark green container": "Thanh toán vào lô container {p0}: container xanh lá đậm",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} thắng lô container {p1} của ngân hàng",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} thắng lô tiền {p1} của ngân hàng"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} thắng lô tiền {p1} của ngân hàng",
|
||||
"Remove from bid": "Loại khỏi giá đặt",
|
||||
"Returned containers": "Container được trả lại"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "支付至集装箱拍品 {p0}:棕色集装箱",
|
||||
"Pay into container lot {p0}: dark green container": "支付至集装箱拍品 {p0}:深绿色集装箱",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} 赢得银行集装箱拍品 {p1}",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} 赢得银行现金拍品 {p1}"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} 赢得银行现金拍品 {p1}",
|
||||
"Remove from bid": "从出价中移除",
|
||||
"Returned containers": "已退回的集装箱"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -789,5 +789,7 @@
|
|||
"Pay into container lot {p0}: brown container": "支付至貨櫃拍賣標的 {p0}:棕色貨櫃",
|
||||
"Pay into container lot {p0}: dark green container": "支付至貨櫃拍賣標的 {p0}:深綠色貨櫃",
|
||||
"{p0} wins bank containers lot {p1}": "{p0} 標得銀行貨櫃拍賣標的 {p1}",
|
||||
"{p0} wins bank cash lot {p1}": "{p0} 標得銀行現金拍賣標的 {p1}"
|
||||
"{p0} wins bank cash lot {p1}": "{p0} 標得銀行現金拍賣標的 {p1}",
|
||||
"Remove from bid": "從出價中移除",
|
||||
"Returned containers": "已退回的貨櫃"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,9 +54,10 @@ export function offshoreJournal(
|
|||
* Match the complete public name and suffix rather than replacing name substrings.
|
||||
* Ambiguous or unknown names keep their original prose without guessing a seat.
|
||||
*/
|
||||
export function offshoreWinJournal(message: string, state: GameState): string | undefined {
|
||||
export function offshoreWinJournal(message: string, state: GameState, rich = true): string | undefined {
|
||||
const match = /^(.*)( wins bank (?:containers|cash) lot [1-3])$/.exec(message);
|
||||
if (!match) return undefined;
|
||||
if (!rich) return message;
|
||||
const players = state.players.filter((player) => player.name === match[1]);
|
||||
if (players.length !== 1) return escapeJournal(message);
|
||||
return playerBadge(match[1], players[0].id) + match[2];
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ function visibleCargo(root: Element): Map<string, SVGGraphicsElement> {
|
|||
const duplicates = new Set<string>();
|
||||
root.querySelectorAll<SVGGraphicsElement>('[data-piece-id]').forEach((node) => {
|
||||
const id = node.getAttribute('data-piece-id')!;
|
||||
// Drafts and seizure choices are UI copies, not the physical container.
|
||||
if (!/^C\d+$/.test(id) || node.closest('.bank-lot-draft')) return;
|
||||
// Draft cargo replaces its store node; seizure choices remain UI copies.
|
||||
if (!/^C\d+$/.test(id)) return;
|
||||
if (node.closest('.bank-decision')?.querySelector('[aria-label^="Select for loan default"]')) return;
|
||||
if (nodes.has(id)) duplicates.add(id);
|
||||
else nodes.set(id, node);
|
||||
|
|
@ -111,8 +111,40 @@ export class OffshoreMotion {
|
|||
}
|
||||
this.cancel();
|
||||
if (!root || !origins.size || this.disposed) return;
|
||||
this.animateOrigins(root, origins, oldNodes, revision, nextTick);
|
||||
}
|
||||
|
||||
/** Local draft relocation only: never changes the authoritative location/log snapshot. */
|
||||
draftTransition(root: Element | undefined, ids: Iterable<string>, nextTick: (callback: () => void) => void) {
|
||||
const revision = ++this.revision;
|
||||
const origins = new Map<string, DOMMatrix>();
|
||||
const oldNodes = new Map<string, SVGGraphicsElement>();
|
||||
const selected = new Set(ids);
|
||||
if (root && !this.media?.matches) {
|
||||
visibleCargo(root).forEach((node, id) => {
|
||||
const matrix = selected.has(id) && node.getCTM?.();
|
||||
if (matrix) {
|
||||
origins.set(id, matrix);
|
||||
oldNodes.set(id, node);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.cancel();
|
||||
// Called immediately before the reactive draft edit. The first tick can precede
|
||||
// Vue's queued render; the second observes the real replacement nodes.
|
||||
if (root && origins.size && !this.disposed)
|
||||
this.animateOrigins(root, origins, oldNodes, revision, (callback) => nextTick(() => nextTick(callback)));
|
||||
}
|
||||
|
||||
private animateOrigins(
|
||||
root: Element,
|
||||
origins: Map<string, DOMMatrix>,
|
||||
oldNodes: Map<string, SVGGraphicsElement>,
|
||||
revision: number,
|
||||
nextTick: (callback: () => void) => void
|
||||
) {
|
||||
nextTick(() => {
|
||||
if (this.disposed || revision !== this.revision || reduced()) return;
|
||||
if (this.disposed || revision !== this.revision || this.media?.matches) return;
|
||||
visibleCargo(root).forEach((node, id) => {
|
||||
const origin = origins.get(id);
|
||||
const parent = (node.parentNode as SVGGraphicsElement).getCTM?.();
|
||||
|
|
|
|||
|
|
@ -300,11 +300,14 @@ describe('Offshore bank viewer', () => {
|
|||
piece(warehouse.id).vm.$emit('bid-select');
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(bank.props('validDraft')).toBe(true);
|
||||
piece(factory.id).vm.$emit('bid-select');
|
||||
expect(piece(factory.id)).toBeUndefined();
|
||||
expect(piece(warehouse.id)).toBeUndefined();
|
||||
bank.vm.$emit('remove-draft', factory.id);
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(piece(factory.id)).toBeDefined();
|
||||
expect(bank.props('draftCargo').map((p) => p.id)).toEqual([warehouse.id]);
|
||||
expect(bank.props('validDraft')).toBe(false);
|
||||
piece(warehouse.id).vm.$emit('bid-select');
|
||||
bank.vm.$emit('remove-draft', warehouse.id);
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(bank.props('draftCargo')).toEqual([]);
|
||||
bank.vm.$emit('cancel-draft');
|
||||
|
|
@ -314,6 +317,57 @@ describe('Offshore bank viewer', () => {
|
|||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it('restores exact store positions on cancel, lot switch and state reset without changing stores or cash', async () => {
|
||||
const { wrapper, state, factory, warehouse, submitted } = gameFixture();
|
||||
const bank = wrapper.findComponent(OffshoreBank);
|
||||
const stores = () => wrapper.findAllComponents(Container).wrappers;
|
||||
const original = stores().map((p) => [p.props('pieceId'), p.props('targetState')]);
|
||||
const before = JSON.stringify(state);
|
||||
for (const reset of ['cancel', 'switch', 'state']) {
|
||||
bank.vm.$emit('choose-offer', { type: 'cash', lot: 1 });
|
||||
await wrapper.vm.$nextTick();
|
||||
for (const id of [factory.id, warehouse.id])
|
||||
stores()
|
||||
.find((p) => p.props('pieceId') === id)!
|
||||
.vm.$emit('bid-select');
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(stores().some((p) => [factory.id, warehouse.id].includes(p.props('pieceId')))).toBe(false);
|
||||
expect(bank.props('draftCargo').map((p) => p.price)).toEqual([2, 3]);
|
||||
if (reset === 'cancel') bank.vm.$emit('cancel-draft');
|
||||
if (reset === 'switch') bank.vm.$emit('choose-offer', { type: 'cash', lot: 0 });
|
||||
if (reset === 'state') await wrapper.setProps({ state: JSON.parse(before) });
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(stores().map((p) => [p.props('pieceId'), p.props('targetState')])).toEqual(original);
|
||||
expect(JSON.stringify(state)).toBe(before);
|
||||
expect(submitted).toEqual([]);
|
||||
}
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it('removes draft cargo with click, Enter and Space without selecting the lot; clamps the last page', async () => {
|
||||
const { render, factory, warehouse, state } = fixture();
|
||||
const wrapper = render();
|
||||
let cargo = [factory, warehouse, state.containersLeft[0]];
|
||||
await wrapper.setProps({ selectedOffer: { type: 'cash', lot: 1 }, draftCargo: cargo });
|
||||
wrapper.vm.$on('remove-draft', (id: string) => {
|
||||
cargo = cargo.filter((p) => p.id !== id);
|
||||
wrapper.setProps({ draftCargo: cargo });
|
||||
});
|
||||
await wrapper.find('.bank-lot-draft [aria-label="Next cargo page"]').trigger('click');
|
||||
for (const event of ['keydown.space', 'keydown.enter', 'click']) {
|
||||
const piece = wrapper.find('.bank-lot-draft [data-piece-id]');
|
||||
expect(piece.attributes('role')).toBe('button');
|
||||
expect(piece.attributes('tabindex')).toBe('0');
|
||||
expect(piece.attributes('aria-label')).toContain('Remove from bid');
|
||||
await piece.trigger(event);
|
||||
await wrapper.vm.$nextTick();
|
||||
}
|
||||
expect(wrapper.emitted('remove-draft')).toHaveLength(3);
|
||||
expect(wrapper.emitted('choose-offer')).toBeUndefined();
|
||||
expect(wrapper.findAll('.bank-lot-draft [data-piece-id]')).toHaveLength(0);
|
||||
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;
|
||||
|
|
@ -478,6 +532,7 @@ describe('Offshore bank viewer', () => {
|
|||
refresh();
|
||||
let wrapper = render();
|
||||
expect(wrapper.text()).toContain('Loan default');
|
||||
expect(wrapper.find('.bank-decision').attributes('transform')).toBe('translate(520 680)');
|
||||
await wrapper.find('.bank-choice [data-piece-id][role="button"]').trigger('keydown.enter');
|
||||
expect(wrapper.emitted('move')![0][0].name).toBe(MoveName.SeizeBankContainer);
|
||||
wrapper.destroy();
|
||||
|
|
@ -494,6 +549,8 @@ describe('Offshore bank viewer', () => {
|
|||
expect(wrapper.find('.offshore-lot.destination').attributes('data-lot')).toBe('0');
|
||||
expect(wrapper.find('.offshore-lot.destination').attributes('role')).toBeUndefined();
|
||||
expect(wrapper.find('.bank-decision > text').exists()).toBe(false);
|
||||
expect(wrapper.find('.bank-decision').attributes('transform')).toBe('translate(20 950)');
|
||||
expect(wrapper.find('.bank-payment-route').exists()).toBe(true);
|
||||
expect(wrapper.emitted('move')).toBeUndefined();
|
||||
expect(wrapper.find('.bank-choice [data-piece-id][role="button"]').attributes('aria-label')).toContain(
|
||||
'Pay into container lot 1'
|
||||
|
|
@ -531,6 +588,52 @@ describe('Offshore bank viewer', () => {
|
|||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it('keeps maximum pending returns in the framed tray for actors and spectators', async () => {
|
||||
const { state, player, refresh, render } = fixture();
|
||||
const containers = Array.from({ length: 103 }, (_, i) => ({
|
||||
container: { piece: { ...state.containersLeft[0], id: `C${i}` as const }, price: 2, moved: false },
|
||||
district: 'factory' as const,
|
||||
}));
|
||||
state.phase = Phase.BankDecision;
|
||||
state.offshoreBank!.decision = {
|
||||
kind: 'return',
|
||||
player,
|
||||
resumePlayer: player,
|
||||
containers,
|
||||
payment: [],
|
||||
cursor: 0,
|
||||
};
|
||||
refresh();
|
||||
const wrapper = render();
|
||||
expect(wrapper.find('.bank-decision').attributes('transform')).toBe('translate(140 480)');
|
||||
expect(wrapper.find('.bank-return-tray').attributes('height')).toBe('150');
|
||||
expect(wrapper.text()).toContain('Returned containers');
|
||||
const seen = new Set<string>();
|
||||
for (let page = 0; page < 26; page++) {
|
||||
wrapper.findAll('.bank-choice').wrappers.forEach((choice, i) => {
|
||||
expect(choice.attributes('transform')).toBe(`translate(${(i % 2) * 60} ${Math.floor(i / 2) * 35})`);
|
||||
seen.add(choice.find('[data-piece-id]').attributes('data-piece-id')!);
|
||||
});
|
||||
await wrapper.find(`[aria-label="More ${page + 1}/26"]`).trigger('click');
|
||||
}
|
||||
expect(seen.size).toBe(103);
|
||||
await wrapper.setProps({ player: undefined });
|
||||
const cargo = wrapper.find('.bank-decision').findComponent(OffshoreCargo);
|
||||
expect(cargo.props('columns')).toBe(5);
|
||||
expect(cargo.props('rows')).toBe(4);
|
||||
seen.clear();
|
||||
for (let page = 0; page < 6; page++) {
|
||||
cargo.findAll('[data-piece-id]').wrappers.forEach((piece) => {
|
||||
expect(piece.attributes('role')).toBeUndefined();
|
||||
seen.add(piece.attributes('data-piece-id')!);
|
||||
});
|
||||
await cargo.find('[aria-label="Next cargo page"]').trigger('keydown.enter');
|
||||
}
|
||||
expect(seen.size).toBe(103);
|
||||
expect(wrapper.emitted('move')).toBeUndefined();
|
||||
wrapper.destroy();
|
||||
});
|
||||
|
||||
it('places five bank ships in separate berths beside the lots', () => {
|
||||
const state = setup(5, { offshoreIsland: true }, 'bank-berths');
|
||||
state.players.forEach((p) => {
|
||||
|
|
|
|||
|
|
@ -24,33 +24,41 @@ function render(log: LogMove, state = fixture(), blind = true) {
|
|||
}
|
||||
|
||||
describe('Offshore rich journal', () => {
|
||||
it.each(['containers', 'cash'])(
|
||||
'badges %s winners in the rich journal without changing engine or plain logs',
|
||||
(type) => {
|
||||
const state = fixture();
|
||||
state.players[0].name = 'You';
|
||||
const message = `You wins bank ${type} lot 1`;
|
||||
state.log = [{ type: 'event', event: { name: GameEventName.Upkeep, interest: message } }];
|
||||
const context = { G: state, preferences: { colorBlind: true }, playerColors: ['#123456'] };
|
||||
const root = document.createElement('div');
|
||||
root.innerHTML = (Game as any).options.computed.logReversed.get.call(context)[0];
|
||||
const badge = root.querySelector('[data-localized-journal] > span') as HTMLElement;
|
||||
expect(badge.textContent).toBe('You');
|
||||
expect(badge.style.backgroundColor).toBe('rgb(18, 52, 86)');
|
||||
expect(badge.style.fontWeight).toBe('bold');
|
||||
expect(root.textContent).toBe(`New event: ${message}`);
|
||||
expect((Game as any).options.computed.logReversedSimple.get.call(context)).toEqual([
|
||||
`New event: ${message}`,
|
||||
]);
|
||||
expect((state.log[0] as any).event.interest).toBe(message);
|
||||
const localization = mountLocalization(root, { fr }, 'fr');
|
||||
expect(root.textContent).toContain('remporte');
|
||||
expect(badge.textContent).toBe('You');
|
||||
localization.setLocale('en');
|
||||
expect(root.textContent).toContain(message);
|
||||
localization.destroy();
|
||||
}
|
||||
);
|
||||
it.each(['containers', 'cash'])('badges %s winners and omits the event prefix in both viewer journals', (type) => {
|
||||
const state = fixture();
|
||||
state.players[0].name = 'You';
|
||||
const message = `You wins bank ${type} lot 1`;
|
||||
state.log = [{ type: 'event', event: { name: GameEventName.Upkeep, interest: message } }];
|
||||
const context = { G: state, preferences: { colorBlind: true }, playerColors: ['#123456'] };
|
||||
const root = document.createElement('div');
|
||||
root.innerHTML = (Game as any).options.computed.logReversed.get.call(context)[0];
|
||||
const badge = root.querySelector('[data-localized-journal] > span') as HTMLElement;
|
||||
expect(badge.textContent).toBe('You');
|
||||
expect(badge.style.backgroundColor).toBe('rgb(18, 52, 86)');
|
||||
expect(badge.style.fontWeight).toBe('bold');
|
||||
expect(root.textContent).toBe(message);
|
||||
expect((Game as any).options.computed.logReversedSimple.get.call(context)).toEqual([message]);
|
||||
expect((state.log[0] as any).event.interest).toBe(message);
|
||||
const localization = mountLocalization(root, { fr }, 'fr');
|
||||
expect(root.textContent).toContain('remporte');
|
||||
expect(badge.textContent).toBe('You');
|
||||
localization.setLocale('en');
|
||||
expect(root.textContent).toContain(message);
|
||||
localization.destroy();
|
||||
});
|
||||
|
||||
it('keeps the existing prefix for unrelated upkeep and game-start events', () => {
|
||||
const state = fixture();
|
||||
state.log = [
|
||||
{ type: 'event', event: { name: GameEventName.GameStart } },
|
||||
{ type: 'event', event: { name: GameEventName.Upkeep, interest: 'Ada pays $1 interest' } },
|
||||
];
|
||||
const context = { G: state, preferences: { colorBlind: false }, playerColors: ['#123456'] };
|
||||
const simple = (Game as any).options.computed.logReversedSimple.get.call(context);
|
||||
expect(simple).toEqual(['New event: Ada pays $1 interest', 'New event: ' + GameEventName.GameStart]);
|
||||
const rich = (Game as any).options.computed.logReversed.get.call(context);
|
||||
expect(rich.every((line: string) => line.startsWith('New event: '))).toBe(true);
|
||||
});
|
||||
|
||||
it('escapes winner names, matches whole names and leaves unrelated upkeep alone', () => {
|
||||
const state = fixture();
|
||||
|
|
|
|||
|
|
@ -118,10 +118,36 @@ describe('offshore physical cargo motion', () => {
|
|||
expect(destination.animate).toHaveBeenCalledOnce();
|
||||
f.motion.destroy();
|
||||
});
|
||||
it('animates draft selection and return on the sole real node without changing engine snapshots', () => {
|
||||
const f = fixture();
|
||||
for (const draft of [true, false]) {
|
||||
f.motion.draftTransition(f.root, [f.piece.id], f.tick);
|
||||
const destination = f.node();
|
||||
if (draft) destination.element.classList.add('bank-lot-draft');
|
||||
while (f.callbacks.length) f.callbacks.shift()!();
|
||||
expect(destination.animate).toHaveBeenCalledOnce();
|
||||
expect(f.root.querySelectorAll('[data-piece-id]')).toHaveLength(1);
|
||||
}
|
||||
f.motion.transition(f.root, f.before, f.after, f.tick);
|
||||
const destination = f.node();
|
||||
while (f.callbacks.length) f.callbacks.shift()!();
|
||||
expect(destination.animate).toHaveBeenCalledOnce();
|
||||
f.motion.destroy();
|
||||
});
|
||||
it('invalidates queued draft animation on authoritative updates', () => {
|
||||
const f = fixture();
|
||||
f.motion.draftTransition(f.root, [f.piece.id], f.tick);
|
||||
f.motion.transition(f.root, f.before, f.before, f.tick);
|
||||
const destination = f.node();
|
||||
f.callbacks.forEach((fn) => fn());
|
||||
expect(destination.animate).not.toHaveBeenCalled();
|
||||
f.motion.destroy();
|
||||
});
|
||||
it('honors reduced motion', () => {
|
||||
vi.stubGlobal('matchMedia', () => ({ matches: true }));
|
||||
const f = fixture();
|
||||
f.motion.transition(f.root, f.before, f.after, f.tick);
|
||||
f.motion.draftTransition(f.root, [f.piece.id], f.tick);
|
||||
expect(f.callbacks).toHaveLength(0);
|
||||
f.motion.destroy();
|
||||
vi.unstubAllGlobals();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue