Clarify New Goals objective exchange choices
This commit is contained in:
parent
af673d0abf
commit
ba8f7e8e8d
29 changed files with 344 additions and 27 deletions
|
|
@ -312,6 +312,8 @@ pub(super) fn describe(game: &Game, seat: usize) -> Option<Value> {
|
|||
let mut max = 1;
|
||||
let mut fields = vec![];
|
||||
let p = game.player(game.current_event().player.index);
|
||||
let objective_exchange = matches!(&h.request, PersistentEventRequest::SelectHandCards(_))
|
||||
&& matches!(&h.origin, EventOrigin::CivilCard(31 | 32));
|
||||
let tactics_selection = matches!(&h.request, PersistentEventRequest::SelectHandCards(_))
|
||||
&& (matches!(
|
||||
&h.origin,
|
||||
|
|
@ -590,6 +592,9 @@ pub(super) fn describe(game: &Game, seat: usize) -> Option<Value> {
|
|||
} else { None }
|
||||
});
|
||||
let mut choice = option(card, card.name(game), text, None);
|
||||
if objective_exchange {
|
||||
choice["exchangeRole"] = json!(if matches!(card, HandCard::ObjectiveCard(id) if p.objective_cards.contains(id)) { "return" } else { "keep" });
|
||||
}
|
||||
if let Some(owner) = owner {
|
||||
choice["owner"] = json!({"player":owner.index,"civilization":owner.civilization.name,"you":owner.index == seat});
|
||||
}
|
||||
|
|
@ -665,6 +670,7 @@ pub(super) fn describe(game: &Game, seat: usize) -> Option<Value> {
|
|||
"eventContext":event_context,
|
||||
"calendarPreview":super::journal::calendar_preview(game, seat),
|
||||
"reward":matches!(h.request,PersistentEventRequest::ResourceReward(_)),
|
||||
"objectiveExchange":objective_exchange,
|
||||
"tacticsSelection":tactics_selection,
|
||||
"advanceSelection":matches!(h.request,PersistentEventRequest::SelectAdvance(_)),
|
||||
"advanceMode":matches!(h.request,PersistentEventRequest::SelectAdvance(_)).then(|| advance_mode(game, h)),
|
||||
|
|
|
|||
|
|
@ -1145,3 +1145,33 @@ Verified with Rust 1.94.1 build/format/Clippy and all 482 native workspace tests
|
|||
17 locale catalogs and four extraction tests, Svelte checks (zero errors/warnings)
|
||||
and the production build. Clippy retains existing warnings; intentional rejected
|
||||
moves in the regression suite emit expected WASM panic diagnostics.
|
||||
|
||||
# Viewer 0.1.210 / engine 0.4.142
|
||||
|
||||
New Goals (canonical New Plans, cards 31/32) separates newly drawn objectives to
|
||||
keep from current objectives to return. Each group allows one selection, with
|
||||
independent highlights and complete card faces. Explicit **Exchange objectives**
|
||||
and **Keep current objectives** controls replace generic confirmation; keeping
|
||||
always submits an empty selection, regardless of highlights. Toolbar and panel
|
||||
use the printed card name. All 17 locales include the new wording.
|
||||
|
||||
The private decision bridge supplies optional `objectiveExchange` and per-option
|
||||
`exchangeRole` metadata only to the active player. Canonical card enums and move
|
||||
payloads are unchanged. Existing generic card choices, including Spies and Great
|
||||
Oracle, retain their behavior. The rules still charge one action and one culture
|
||||
and allow exchanging exactly one objective or none; no saved history is changed.
|
||||
|
||||
Card-choice browser coverage also caught a pre-existing 320px collection-list
|
||||
layout bug: flex shrinking placed tile choices beneath the sticky Collect button.
|
||||
The expanded list now retains its height in the scrolling panel. Real pointer
|
||||
clicks verify Free Economy without forced interaction.
|
||||
|
||||
Publish the matching bridge as `@boardgamers/clash-server` 0.4.142 using
|
||||
`npm run publish:bgs -- --engine=/absolute/path/to/package.tgz` (dry-run first).
|
||||
Preserve unrelated metadata, including game-length labels/order and Standard as
|
||||
the default. Coverage includes all 482 native workspace tests (one existing
|
||||
ignored test), 1,054 frontend tests against the packed engine, 17 locales and four
|
||||
extraction tests, Svelte checks, and the production build. Browser checks cover
|
||||
both copies in English/German at 1400/390/320px, generic card choices, combat and
|
||||
playback. Existing Clippy warnings and expected rejected-move WASM panic
|
||||
diagnostics remain. No live moves or historical repairs are performed.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.209",
|
||||
"version": "0.1.210",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.209",
|
||||
"version": "0.1.210",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.209",
|
||||
"version": "0.1.210",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ try {
|
|||
},
|
||||
{ state: engine.stripSecret(state, 0), dark },
|
||||
);
|
||||
const panel = page.getByRole('region', { name: 'Great Seer', exact: true });
|
||||
const panel = page.getByRole('region', { name: 'Great Oracle', exact: true });
|
||||
await panel.waitFor();
|
||||
assert.match(await panel.innerText(), /The other card goes to Greece on their next objective draw/);
|
||||
assert.equal(await panel.locator('.decision-card-face').count(), 4);
|
||||
|
|
@ -100,7 +100,7 @@ try {
|
|||
);
|
||||
state = spy;
|
||||
await page.evaluate((state) => host.emit('state', state), engine.stripSecret(state, 0));
|
||||
const spyPanel = page.getByRole('region', { name: 'Spy', exact: true });
|
||||
const spyPanel = page.getByRole('region', { name: 'Spies', exact: true });
|
||||
await spyPanel.waitFor();
|
||||
assert.ok(await spyPanel.getByText('Battle · Requires Tactics', { exact: true }).count());
|
||||
assert.ok(await spyPanel.evaluate((el) => el.scrollWidth <= el.clientWidth + 1));
|
||||
|
|
@ -112,6 +112,7 @@ try {
|
|||
await page.locator('.variant-picker button').filter({ hasText: 'Free Economy' }).click();
|
||||
const tiles = page.locator('.collection-tile-list');
|
||||
await tiles.locator('summary').click();
|
||||
// Real pointer clicks must reach the list even above the sticky footer at 320px.
|
||||
await tiles.locator('button').first().click();
|
||||
await page.locator('.collect-submit').click();
|
||||
await page.waitForFunction(
|
||||
|
|
|
|||
77
web-client/scripts/new-goals-smoke.mjs
Normal file
77
web-client/scripts/new-goals-smoke.mjs
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { createServer } from 'node:http';
|
||||
import { createRequire } from 'node:module';
|
||||
import { chromium } from 'playwright';
|
||||
const engine = createRequire(import.meta.url)('../.engine/server.js');
|
||||
const server = createServer(async (req, res) => {
|
||||
if (req.url === '/') return res.end('<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><div id="app"></div><script src="/viewer.js"></script>');
|
||||
if (!/^\/(viewer.js|server_bg.wasm|de.json)$/.test(req.url)) return res.writeHead(404).end();
|
||||
res.setHeader('Content-Type', req.url.endsWith('.wasm') ? 'application/wasm' : req.url.endsWith('.json') ? 'application/json' : 'text/javascript');
|
||||
res.end(await readFile(new URL('../dist' + req.url, import.meta.url)));
|
||||
});
|
||||
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
||||
const browser = await chromium.launch({headless:true, args:['--use-gl=angle', '--use-angle=swiftshader']});
|
||||
try {
|
||||
for (const locale of ['en','de']) for (const width of [1400,390,320]) for (const id of [31,32]) {
|
||||
const game = JSON.parse(await engine.init(2, [], {}, `goals-${id}`, {}));
|
||||
const seat = engine.currentPlayer(JSON.stringify(game));
|
||||
game.players[seat].action_cards = [id];
|
||||
game.players[seat].resources.culture_tokens = 5;
|
||||
game.players[seat].objective_cards.push(game.objective_cards_left.pop());
|
||||
const move = (state, action) => engine.tryMove(state, typeof action === 'string' ? action : JSON.stringify(action), seat);
|
||||
const initial = move(move(JSON.stringify(game), {Playing:{ActionCard:id}}), {Response:{Payment:[{culture_tokens:1}]}});
|
||||
let state = initial, sent = [];
|
||||
const page = await browser.newPage({viewport:{width,height:width===1400?900:844}}), errors=[];
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
await page.exposeFunction('applyMove', async action => {
|
||||
sent.push(typeof action === 'string' ? JSON.parse(action) : action);
|
||||
state=move(state, action);
|
||||
await page.evaluate(s => host.emit('state',s), engine.stripSecret(state,seat));
|
||||
});
|
||||
await page.goto('http://127.0.0.1:'+server.address().port);
|
||||
await page.evaluate(({state,seat,locale}) => {
|
||||
window.host=clash3d.launch('#app');host.on('move', a=>window.applyMove(a));
|
||||
host.emit('player',{index:seat});host.emit('preferences',{sound:false,locale});host.emit('state',state);
|
||||
},{state:engine.stripSecret(state,seat),seat,locale});
|
||||
await page.waitForSelector(`[data-clash-locale="${locale}"] .objective-exchange-footer`);
|
||||
const panel=page.locator('.card-decision'), options=panel.locator('.decision-option');
|
||||
const exchange=panel.locator('.objective-exchange-footer .primary'), keep=panel.locator('.objective-exchange-footer .secondary');
|
||||
assert.equal(await panel.locator('.decision-card-group').count(),2);
|
||||
assert.equal(await panel.locator('.decision-card-face').count(),8);
|
||||
assert.equal(await panel.locator('.decision-count').count(),0);
|
||||
assert.equal(await exchange.isEnabled(),false);
|
||||
assert.equal(await keep.isEnabled(),true);
|
||||
await keep.click();
|
||||
await page.waitForFunction(()=>!document.querySelector('.card-decision'));
|
||||
assert.deepEqual(sent.at(-1), {Response:{SelectHandCards:[]}});
|
||||
state=initial;
|
||||
await page.evaluate(s=>host.emit('state',s),engine.stripSecret(state,seat));
|
||||
await panel.waitFor();
|
||||
await options.nth(0).click(); assert.equal(await exchange.isEnabled(),false);
|
||||
await options.nth(1).click(); assert.equal(await options.nth(0).getAttribute('aria-pressed'),'false');
|
||||
await options.nth(2).click(); assert.equal(await exchange.isEnabled(),true);
|
||||
await options.nth(3).click(); assert.equal(await options.nth(2).getAttribute('aria-pressed'),'false');
|
||||
assert.equal(await panel.locator('.exchange-selection').count(),2);
|
||||
assert.equal(await panel.locator('.inline-error').count(),0);
|
||||
assert.ok(await panel.evaluate(el=>el.scrollWidth<=el.clientWidth+1));
|
||||
assert.ok(await exchange.evaluate(el=>{const r=el.getBoundingClientRect();return r.left>=0 && r.right<=innerWidth+1 && el.scrollWidth<=el.clientWidth+1}));
|
||||
await panel.evaluate(el=>el.scrollTop=0);
|
||||
await page.screenshot({path:`/tmp/clash-new-goals-${locale}-${width}-${id}.png`});
|
||||
// Keeping is independent of an otherwise valid highlighted exchange.
|
||||
await keep.click();
|
||||
await page.waitForFunction(()=>!document.querySelector('.card-decision'));
|
||||
assert.deepEqual(sent.at(-1), {Response:{SelectHandCards:[]}});
|
||||
state=initial;
|
||||
await page.evaluate(s=>host.emit('state',s),engine.stripSecret(state,seat));
|
||||
await panel.waitFor();
|
||||
await options.nth(1).click();
|
||||
await options.nth(3).click();
|
||||
await exchange.click();
|
||||
await page.waitForFunction(()=>!document.querySelector('.card-decision'));
|
||||
assert.equal(sent.at(-1).Response.SelectHandCards.length,2);
|
||||
assert.deepEqual(errors,[]);
|
||||
console.log(`${locale} ${width}px card ${id}: groups, faces, switching, keep, exchange, fit passed`);
|
||||
await page.close();
|
||||
}
|
||||
} finally { await browser.close();server.close(); }
|
||||
|
|
@ -375,7 +375,7 @@
|
|||
: $session.view?.decision
|
||||
? $session.view.decision.endOfAge
|
||||
? 'End of age'
|
||||
: $session.view.decision.name
|
||||
: printedCardName($session.view.decision.name)
|
||||
: $session.view?.explorationDecision
|
||||
? 'Place explored terrain'
|
||||
: choiceDecision
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
&& decision.fields.some((field) => field.name === 'Pay to gain the Action Card')
|
||||
? decision.eventContext.card : null);
|
||||
const description = $derived(
|
||||
decision.objectiveExchange ? 'Exchange one objective from your hand for one new objective, or keep your current hand.' :
|
||||
razeChoice ? 'Select a highlighted city on the map.' : combatBenefit ??
|
||||
(decision.tacticsSelection && decision.name === 'Tactics'
|
||||
? ''
|
||||
|
|
@ -144,6 +145,10 @@
|
|||
);
|
||||
const optionGroups = $derived.by(() => {
|
||||
const indexed = decision.options.map((option, index) => ({option,index}));
|
||||
if (decision.objectiveExchange) return [
|
||||
{label:'New objectives — choose one to keep', options:indexed.filter(({option}) => option.exchangeRole === 'keep')},
|
||||
{label:'Your objectives — choose one to return', options:indexed.filter(({option}) => option.exchangeRole === 'return')},
|
||||
];
|
||||
if (new Set(indexed.map(({option})=>option.owner?.player).filter(p=>p!==undefined)).size < 2)
|
||||
return [{label:'', options:indexed}];
|
||||
const type = (option: typeof decision.options[number]) => option.card?.kind === 'action' ? 'Action cards' : option.card?.kind === 'objective' ? 'Objectives' : 'Wonders';
|
||||
|
|
@ -190,12 +195,13 @@
|
|||
class="decision-option"
|
||||
class:has-description={!!presented.description || !!option.handCounts}
|
||||
class:card-option={!!option.card}
|
||||
class:exchange-option={decision.objectiveExchange}
|
||||
class:selected={selected.includes(i)}
|
||||
aria-label={presented.name}
|
||||
aria-describedby={presented.description || option.handCounts ? `${panelId}-option-${i}` : undefined}
|
||||
aria-pressed={selected.includes(i)}
|
||||
disabled={$session.pending ||
|
||||
(!selected.includes(i) && decision.max > 1 && selected.length >= decision.max)}
|
||||
(!decision.objectiveExchange && !selected.includes(i) && decision.max > 1 && selected.length >= decision.max)}
|
||||
onmouseenter={() => onHighlight(option.position)}
|
||||
onmouseleave={() => onHighlight(null)}
|
||||
onfocus={() => onHighlight(option.position)}
|
||||
|
|
@ -209,7 +215,9 @@
|
|||
{foodRecipient.resources?.food ?? 0}/{foodRecipient.resource_limit?.food ?? 0}<Wheat size={15} />
|
||||
</span>
|
||||
{/if}
|
||||
{#if firstPlayerChoice}
|
||||
{#if decision.objectiveExchange && selected.includes(i)}
|
||||
<span class="exchange-selection"><Check size={13} />{option.exchangeRole === 'keep' ? 'Keep' : 'Return'}</span>
|
||||
{:else if firstPlayerChoice}
|
||||
{#if selected.includes(i)}<Check size={18} aria-hidden="true" />{/if}
|
||||
{:else}<span class="decision-selection" aria-hidden="true"
|
||||
>{#if selected.includes(i)}<Check size={13} />{/if}</span>{/if}
|
||||
|
|
@ -492,11 +500,22 @@
|
|||
{#if (decision.tacticsSelection || decision.name === 'Siegecraft') && preview.action}
|
||||
<CombatEstimate {controller} action={preview.action} />
|
||||
{/if}
|
||||
<div class="decision-footer" class:map-decision-footer={mapChoice}>
|
||||
<div class="decision-footer" class:objective-exchange-footer={decision.objectiveExchange} class:map-decision-footer={mapChoice}>
|
||||
{#if razeChoice}
|
||||
<RazeActions selected={selected.length ? decision.options[selected[0]].position : null} pending={$session.pending}
|
||||
onkeep={() => { const response = controller.query<{action: Move}>({kind:'decision', values:[], payments:[]}); controller.submit(response.action); }}
|
||||
onraze={() => preview.action && controller.submit(preview.action)} />
|
||||
{:else if decision.objectiveExchange}
|
||||
<button class="secondary" disabled={$session.pending}
|
||||
onclick={() => {
|
||||
const response = controller.query<{action: Move}>({kind:'decision', values:[], payments:[]});
|
||||
controller.submit(response.action);
|
||||
}}>Keep current objectives</button>
|
||||
<button class="primary" disabled={$session.pending || !preview.action || selected.length !== 2 ||
|
||||
!selected.some(i => decision.options[i].exchangeRole === 'keep') ||
|
||||
!selected.some(i => decision.options[i].exchangeRole === 'return')}
|
||||
onclick={() => preview.action && selected.length === 2 && controller.submit(preview.action)}
|
||||
>Exchange objectives<Check size={16} /></button>
|
||||
{:else if decision.tacticsSelection}
|
||||
{#if selected.length}<small class="tactics-discard">Discards the selected card</small>{/if}
|
||||
<button
|
||||
|
|
@ -541,7 +560,7 @@
|
|||
/>
|
||||
</button>
|
||||
{/if}
|
||||
{#if preview.error && (selected.length > 0 || decision.fields.length)}<p class="inline-error">
|
||||
{#if !decision.objectiveExchange && preview.error && (selected.length > 0 || decision.fields.length)}<p class="inline-error">
|
||||
{preview.error}
|
||||
</p>{/if}
|
||||
</div>
|
||||
|
|
@ -550,6 +569,12 @@
|
|||
</section>
|
||||
|
||||
<style>
|
||||
.decision-options .exchange-option { flex-direction: column; }
|
||||
.exchange-option :global(.decision-option-content) { width: 100%; }
|
||||
.exchange-option > .exchange-selection, .exchange-option > .decision-selection { order: -1; align-self: flex-end; }
|
||||
.exchange-selection { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: var(--ink); }
|
||||
.objective-exchange-footer { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.objective-exchange-footer button { white-space: normal; flex: 1 1 180px; }
|
||||
@media (min-width: 761px) {
|
||||
:global(.play-layout) .action-panel.floating-panel.calendar-decision {
|
||||
width: min(460px, calc(100% - 40px));
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ export function mapDecisionIndex(decision: Decision, position: string, pick: Map
|
|||
export function toggleDecisionSelection(decision: Decision, selected: number[], index: number) {
|
||||
if (!decision.options[index]) return selected;
|
||||
if (selected.includes(index)) return selected.filter((i) => i !== index);
|
||||
if (decision.objectiveExchange) {
|
||||
const role = decision.options[index].exchangeRole;
|
||||
if (!role) return selected;
|
||||
return [...selected.filter((i) => decision.options[i]?.exchangeRole !== role), index];
|
||||
}
|
||||
if (decision.max === 1) return [index];
|
||||
return selected.length < decision.max ? [...selected, index] : selected;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Tab",
|
||||
"Casualties:": "Tab:",
|
||||
"Casualties: {p0}": "Tab: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Byt et mål fra din hånd med et nyt mål, eller behold din nuværende hånd.",
|
||||
"New objectives — choose one to keep": "Nye mål — vælg et at beholde",
|
||||
"Your objectives — choose one to return": "Dine mål — vælg et at returnere",
|
||||
"Exchange objectives": "Byt mål",
|
||||
"Keep current objectives": "Behold nuværende mål",
|
||||
"Keep": "Behold",
|
||||
"Return": "Returnér"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Verluste",
|
||||
"Casualties:": "Verluste:",
|
||||
"Casualties: {p0}": "Verluste: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Tausche ein Ziel aus deiner Hand gegen ein neues Ziel oder behalte deine aktuelle Hand.",
|
||||
"New objectives — choose one to keep": "Neue Ziele — wähle eines zum Behalten",
|
||||
"Your objectives — choose one to return": "Deine Ziele — wähle eines zum Zurückgeben",
|
||||
"Exchange objectives": "Ziele tauschen",
|
||||
"Keep current objectives": "Aktuelle Ziele behalten",
|
||||
"Keep": "Behalten",
|
||||
"Return": "Zurückgeben"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Απώλειες",
|
||||
"Casualties:": "Απώλειες:",
|
||||
"Casualties: {p0}": "Απώλειες: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Αντάλλαξε έναν στόχο από το χέρι σου με έναν νέο στόχο ή κράτησε το τρέχον χέρι σου.",
|
||||
"New objectives — choose one to keep": "Νέοι στόχοι — διάλεξε έναν να κρατήσεις",
|
||||
"Your objectives — choose one to return": "Οι στόχοι σου — διάλεξε έναν να επιστρέψεις",
|
||||
"Exchange objectives": "Ανταλλαγή στόχων",
|
||||
"Keep current objectives": "Κράτησε τους τρέχοντες στόχους",
|
||||
"Keep": "Κράτησε",
|
||||
"Return": "Επίστρεψε"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Casualties",
|
||||
"Casualties:": "Casualties:",
|
||||
"Casualties: {p0}": "Casualties: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Exchange one objective from your hand for one new objective, or keep your current hand.",
|
||||
"New objectives — choose one to keep": "New objectives — choose one to keep",
|
||||
"Your objectives — choose one to return": "Your objectives — choose one to return",
|
||||
"Exchange objectives": "Exchange objectives",
|
||||
"Keep current objectives": "Keep current objectives",
|
||||
"Keep": "Keep",
|
||||
"Return": "Return"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "تلفات",
|
||||
"Casualties:": "تلفات:",
|
||||
"Casualties: {p0}": "تلفات: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "یک هدف از دست خود را با یک هدف جدید عوض کنید، یا دست فعلی خود را نگه دارید.",
|
||||
"New objectives — choose one to keep": "هدفهای جدید — یکی را برای نگه داشتن انتخاب کنید",
|
||||
"Your objectives — choose one to return": "هدفهای شما — یکی را برای برگرداندن انتخاب کنید",
|
||||
"Exchange objectives": "تعویض هدفها",
|
||||
"Keep current objectives": "نگه داشتن هدفهای فعلی",
|
||||
"Keep": "نگه داشتن",
|
||||
"Return": "برگرداندن"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Pertes",
|
||||
"Casualties:": "Pertes:",
|
||||
"Casualties: {p0}": "Pertes: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Échangez un objectif de votre main contre un nouvel objectif, ou gardez votre main actuelle.",
|
||||
"New objectives — choose one to keep": "Nouveaux objectifs — choisissez-en un à garder",
|
||||
"Your objectives — choose one to return": "Vos objectifs — choisissez-en un à rendre",
|
||||
"Exchange objectives": "Échanger les objectifs",
|
||||
"Keep current objectives": "Garder les objectifs actuels",
|
||||
"Keep": "Garder",
|
||||
"Return": "Rendre"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "हताहत",
|
||||
"Casualties:": "हताहत:",
|
||||
"Casualties: {p0}": "हताहत: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "अपने हाथ का एक उद्देश्य किसी नए उद्देश्य से बदलें, या अपना मौजूदा हाथ रखें।",
|
||||
"New objectives — choose one to keep": "नए उद्देश्य — रखने के लिए एक चुनें",
|
||||
"Your objectives — choose one to return": "आपके उद्देश्य — लौटाने के लिए एक चुनें",
|
||||
"Exchange objectives": "उद्देश्य बदलें",
|
||||
"Keep current objectives": "मौजूदा उद्देश्य रखें",
|
||||
"Keep": "रखें",
|
||||
"Return": "लौटाएँ"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Perdite",
|
||||
"Casualties:": "Perdite:",
|
||||
"Casualties: {p0}": "Perdite: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Scambia un obiettivo della tua mano con un nuovo obiettivo, oppure mantieni la mano attuale.",
|
||||
"New objectives — choose one to keep": "Nuovi obiettivi — scegline uno da tenere",
|
||||
"Your objectives — choose one to return": "I tuoi obiettivi — scegline uno da restituire",
|
||||
"Exchange objectives": "Scambia obiettivi",
|
||||
"Keep current objectives": "Mantieni gli obiettivi attuali",
|
||||
"Keep": "Tieni",
|
||||
"Return": "Restituisci"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "사상자",
|
||||
"Casualties:": "사상자:",
|
||||
"Casualties: {p0}": "사상자: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "손에 든 목표 하나를 새 목표 하나와 교환하거나 현재 손패를 유지하세요.",
|
||||
"New objectives — choose one to keep": "새 목표 — 보관할 목표 하나 선택",
|
||||
"Your objectives — choose one to return": "내 목표 — 반환할 목표 하나 선택",
|
||||
"Exchange objectives": "목표 교환",
|
||||
"Keep current objectives": "현재 목표 유지",
|
||||
"Keep": "보관",
|
||||
"Return": "반환"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Verliezen",
|
||||
"Casualties:": "Verliezen:",
|
||||
"Casualties: {p0}": "Verliezen: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Ruil een doel uit je hand voor een nieuw doel, of behoud je huidige hand.",
|
||||
"New objectives — choose one to keep": "Nieuwe doelen — kies er één om te houden",
|
||||
"Your objectives — choose one to return": "Jouw doelen — kies er één om terug te geven",
|
||||
"Exchange objectives": "Doelen ruilen",
|
||||
"Keep current objectives": "Huidige doelen behouden",
|
||||
"Keep": "Houden",
|
||||
"Return": "Teruggeven"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Straty",
|
||||
"Casualties:": "Straty:",
|
||||
"Casualties: {p0}": "Straty: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Wymień jeden cel z ręki na nowy cel albo zachowaj obecną rękę.",
|
||||
"New objectives — choose one to keep": "Nowe cele — wybierz jeden do zachowania",
|
||||
"Your objectives — choose one to return": "Twoje cele — wybierz jeden do oddania",
|
||||
"Exchange objectives": "Wymień cele",
|
||||
"Keep current objectives": "Zachowaj obecne cele",
|
||||
"Keep": "Zachowaj",
|
||||
"Return": "Oddaj"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Baixas",
|
||||
"Casualties:": "Baixas:",
|
||||
"Casualties: {p0}": "Baixas: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Troque um objetivo da sua mão por um novo objetivo ou mantenha sua mão atual.",
|
||||
"New objectives — choose one to keep": "Novos objetivos — escolha um para manter",
|
||||
"Your objectives — choose one to return": "Seus objetivos — escolha um para devolver",
|
||||
"Exchange objectives": "Trocar objetivos",
|
||||
"Keep current objectives": "Manter objetivos atuais",
|
||||
"Keep": "Manter",
|
||||
"Return": "Devolver"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Pierderi",
|
||||
"Casualties:": "Pierderi:",
|
||||
"Casualties: {p0}": "Pierderi: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Schimbă un obiectiv din mână cu unul nou sau păstrează mâna actuală.",
|
||||
"New objectives — choose one to keep": "Obiective noi — alege unul de păstrat",
|
||||
"Your objectives — choose one to return": "Obiectivele tale — alege unul de returnat",
|
||||
"Exchange objectives": "Schimbă obiective",
|
||||
"Keep current objectives": "Păstrează obiectivele actuale",
|
||||
"Keep": "Păstrează",
|
||||
"Return": "Returnează"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Потери",
|
||||
"Casualties:": "Потери:",
|
||||
"Casualties: {p0}": "Потери: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Обменяйте одну цель с руки на новую или сохраните текущую руку.",
|
||||
"New objectives — choose one to keep": "Новые цели — выберите одну, чтобы оставить",
|
||||
"Your objectives — choose one to return": "Ваши цели — выберите одну, чтобы вернуть",
|
||||
"Exchange objectives": "Обменять цели",
|
||||
"Keep current objectives": "Сохранить текущие цели",
|
||||
"Keep": "Оставить",
|
||||
"Return": "Вернуть"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "Thương vong",
|
||||
"Casualties:": "Thương vong:",
|
||||
"Casualties: {p0}": "Thương vong: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "Đổi một mục tiêu trên tay lấy một mục tiêu mới, hoặc giữ nguyên bài trên tay.",
|
||||
"New objectives — choose one to keep": "Mục tiêu mới — chọn một để giữ",
|
||||
"Your objectives — choose one to return": "Mục tiêu của bạn — chọn một để trả lại",
|
||||
"Exchange objectives": "Đổi mục tiêu",
|
||||
"Keep current objectives": "Giữ mục tiêu hiện tại",
|
||||
"Keep": "Giữ",
|
||||
"Return": "Trả lại"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "伤亡",
|
||||
"Casualties:": "伤亡:",
|
||||
"Casualties: {p0}": "伤亡: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "用手中的一个目标交换一个新目标,或保留当前手牌。",
|
||||
"New objectives — choose one to keep": "新目标 — 选择一个保留",
|
||||
"Your objectives — choose one to return": "你的目标 — 选择一个归还",
|
||||
"Exchange objectives": "交换目标",
|
||||
"Keep current objectives": "保留当前目标",
|
||||
"Keep": "保留",
|
||||
"Return": "归还"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5281,5 +5281,12 @@
|
|||
"Casualties": "傷亡",
|
||||
"Casualties:": "傷亡:",
|
||||
"Casualties: {p0}": "傷亡: {p0}",
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}"
|
||||
"Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}": "Hit report: value {p0}; cancels {p1}; extra {p2}; casualties {p3}",
|
||||
"Exchange one objective from your hand for one new objective, or keep your current hand.": "用手中的一個目標交換一個新目標,或保留目前手牌。",
|
||||
"New objectives — choose one to keep": "新目標 — 選擇一個保留",
|
||||
"Your objectives — choose one to return": "你的目標 — 選擇一個歸還",
|
||||
"Exchange objectives": "交換目標",
|
||||
"Keep current objectives": "保留目前目標",
|
||||
"Keep": "保留",
|
||||
"Return": "歸還"
|
||||
}
|
||||
|
|
|
|||
50
web-client/src/new-goals.test.ts
Normal file
50
web-client/src/new-goals.test.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createRequire } from 'node:module';
|
||||
import { toggleDecisionSelection } from './decision-controls.ts';
|
||||
import type { View } from './types.ts';
|
||||
const engine = createRequire(import.meta.url)('../.engine/server.js');
|
||||
|
||||
for (const id of [31, 32]) test(`New Goals ${id}: explicit private exchange preserves engine rules`, async () => {
|
||||
const game = JSON.parse(await engine.init(2, [], {}, `new-goals-${id}`, {}));
|
||||
const seat = engine.currentPlayer(JSON.stringify(game));
|
||||
game.players[seat].action_cards = [id];
|
||||
game.players[seat].resources.culture_tokens = 5;
|
||||
// A second existing objective exercises replacing the return selection too.
|
||||
game.players[seat].objective_cards.push(game.objective_cards_left.pop());
|
||||
const before = [...game.players[seat].objective_cards];
|
||||
const move = (state: string, action: unknown) => engine.tryMove(state, JSON.stringify(action), seat);
|
||||
let state = move(JSON.stringify(game), { Playing: { ActionCard: id } });
|
||||
state = move(state, { Response: { Payment: [{ culture_tokens: 1 }] } });
|
||||
const visible = engine.stripSecret(state, seat);
|
||||
const decision = (JSON.parse(engine.webView(visible, seat)) as View).decision!;
|
||||
assert.equal(decision.objectiveExchange, true);
|
||||
const keeps = decision.options.flatMap((o, i) => o.exchangeRole === 'keep' ? [i] : []);
|
||||
const returns = decision.options.flatMap((o, i) => o.exchangeRole === 'return' ? [i] : []);
|
||||
assert.equal(keeps.length, 2);
|
||||
assert.equal(returns.length, before.length);
|
||||
assert.ok(decision.options.every(o => o.card?.kind === 'objective' && o.card.objectives.length === 2));
|
||||
const query = (indices: number[]) => JSON.parse(engine.webQuery(visible, seat, JSON.stringify({kind: 'decision', values: indices.map(i => decision.options[i].value), payments: []})));
|
||||
for (const indices of [[keeps[0]], keeps, returns, [keeps[0], keeps[0]], [keeps[0], ...returns]]) assert.throws(() => query(indices));
|
||||
let selected = toggleDecisionSelection(decision, [], keeps[0]);
|
||||
selected = toggleDecisionSelection(decision, selected, keeps[1]);
|
||||
assert.deepEqual(selected, [keeps[1]]);
|
||||
selected = toggleDecisionSelection(decision, selected, returns[0]);
|
||||
selected = toggleDecisionSelection(decision, selected, returns[1]);
|
||||
assert.deepEqual(selected, [keeps[1], returns[1]]);
|
||||
assert.deepEqual(toggleDecisionSelection(decision, selected, returns[1]), [keeps[1]]);
|
||||
const kept = JSON.parse(move(state, query([]).action));
|
||||
assert.deepEqual(kept.players[seat].objective_cards, before);
|
||||
const exchanged = JSON.parse(move(state, query(selected).action));
|
||||
const gained = (decision.options[keeps[1]].value as {ObjectiveCard: number}).ObjectiveCard;
|
||||
const returned = (decision.options[returns[1]].value as {ObjectiveCard: number}).ObjectiveCard;
|
||||
assert.deepEqual([...exchanged.players[seat].objective_cards].sort(), [...before.filter(c => c !== returned), gained].sort());
|
||||
for (const after of [kept, exchanged]) {
|
||||
assert.equal(after.players[seat].resources.culture_tokens, 4);
|
||||
assert.equal(after.actions_left, game.actions_left - 1);
|
||||
assert.ok(!(after.players[seat].action_cards ?? []).includes(id));
|
||||
}
|
||||
const other = 1 - seat;
|
||||
assert.equal(JSON.parse(engine.webView(engine.stripSecret(state, other), other)).decision, null);
|
||||
assert.ok(JSON.parse(engine.stripSecret(state, other)).players[seat].objective_cards.every((c: number) => c === 0));
|
||||
});
|
||||
|
|
@ -3787,6 +3787,8 @@ small {
|
|||
}
|
||||
.collection-tile-list {
|
||||
min-height: 0;
|
||||
/* Keep the open list in flow above the sticky confirmation on short phones. */
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.collection-tile-list > summary {
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -747,6 +747,7 @@ export interface Decision {
|
|||
} | null;
|
||||
} | null;
|
||||
advanceSelection?: boolean;
|
||||
objectiveExchange?: boolean;
|
||||
tacticsSelection?: boolean;
|
||||
opponentTactics?: 'played' | 'pending' | 'none' | null;
|
||||
advanceMode?: 'free' | 'paid' | 'borrow' | null;
|
||||
|
|
@ -765,6 +766,7 @@ export interface Decision {
|
|||
| { kind: 'unit'; player: number; unit: number; unitType: UnitView['type'] }
|
||||
| { kind: 'structure'; structure: string | { Building: string } | { Wonder: string } };
|
||||
terrain?: Terrain;
|
||||
exchangeRole?: 'keep' | 'return';
|
||||
owner?: { player: number; civilization: string; you: boolean };
|
||||
/** Public counts of the hand categories Spy can inspect, never card identities. */
|
||||
handCounts?: { action: number; objective: number; wonder: number };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue