[ui-pvp] review notes: neutral 'victory' wording in the fallback recap; /recap/<id> is canonical (/battle/<id> kept as alias)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -50,11 +50,11 @@ function transferProblem(state: TestnetSnapshot, card: CardData, address: string
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
// Deep links (Night 2, ui-pvp): /play/invite/<code> opens Play with the invite; /battle/<id> is a recap page.
|
||||
// Deep links (Night 2, ui-pvp): /play/invite/<code> opens Play with the invite; /recap/<id> (or /battle/<id>) is a recap page.
|
||||
const [invite] = useState(() => inviteFromPath(location.pathname));
|
||||
const [battle, setBattle] = useState(() => matchIdFromPath(location.pathname));
|
||||
const [view, setView] = useState<View>(() => (invite ? 'Play' : 'Discover'));
|
||||
const openRecap = (id: string) => { history.pushState(null, '', `/battle/${encodeURIComponent(id)}`); setBattle(id); };
|
||||
const openRecap = (id: string) => { history.pushState(null, '', `/recap/${encodeURIComponent(id)}`); setBattle(id); };
|
||||
const closeRecap = () => { history.pushState(null, '', '/'); setBattle(''); };
|
||||
useEffect(() => {
|
||||
const pop = () => setBattle(matchIdFromPath(location.pathname));
|
||||
@@ -174,7 +174,7 @@ export default function App() {
|
||||
catch (e) { setError(message(e)); }
|
||||
};
|
||||
|
||||
// /battle/<id>: a standalone, shareable recap page (no hero or mining panel around it).
|
||||
// /recap/<id>: a standalone, shareable recap page (no hero or mining panel around it).
|
||||
if (battle) return <main className="recap-shell"><BattleRecap key={battle} matchId={battle} onExit={closeRecap} /></main>;
|
||||
return <div className="app-shell">
|
||||
<aside className="sidebar">
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
||||
import { ArrowLeft, LoaderCircle, Share2 } from 'lucide-react';
|
||||
import { fallbackRecap, parseMatchRecord, runs, type RecapDoc } from './model.ts';
|
||||
|
||||
/** /battle/<matchId> (also /recap/<matchId>, DUEL_DESIGN §8.3): encyclopedic recap of a finished match, replayed from the host's record. */
|
||||
/** /recap/<matchId> (DUEL_DESIGN §8.3; /battle/<matchId> is accepted as an alias): encyclopedic recap of a finished match, replayed from the host's record. */
|
||||
export function matchIdFromPath(path: string): string {
|
||||
const m = path.match(/^\/(?:battle|recap)\/([A-Za-z0-9_-]{1,128})\/?$/);
|
||||
return m ? m[1] : '';
|
||||
@@ -73,7 +73,7 @@ export function BattleRecap({ matchId, onExit }: { matchId: string; onExit: () =
|
||||
return () => { active = false; };
|
||||
}, [matchId]);
|
||||
const share = async () => {
|
||||
const url = `${location.origin}/battle/${encodeURIComponent(matchId)}`;
|
||||
const url = `${location.origin}/recap/${encodeURIComponent(matchId)}`;
|
||||
try {
|
||||
if (navigator.share) await navigator.share({ title: doc?.title ?? 'WikiDeck battle', url });
|
||||
else { await navigator.clipboard.writeText(url); setNote('Link copied.'); }
|
||||
|
||||
@@ -126,7 +126,7 @@ export function fallbackRecap(m: MatchRecord): RecapDoc {
|
||||
const title = namesake && year ? `${bare} (${year})` : bare;
|
||||
|
||||
const [a, b] = m.players;
|
||||
const ending = m.winner === null ? 'in a draw' : `in a decisive victory for ${m.players[m.winner]}`;
|
||||
const ending = m.winner === null ? 'in a draw' : `in a victory for ${m.players[m.winner]}`;
|
||||
let lead = `The **${bare}** was a WikiDeck engagement fought on ${date} between the forces of ${a} and ${b}.`;
|
||||
lead += m.turns ? ` It lasted ${spell(m.turns)} turns and ended ${ending}.` : ` It ended ${ending}.`;
|
||||
if (namesake) lead += cite(namesake);
|
||||
@@ -153,8 +153,8 @@ export function fallbackRecap(m: MatchRecord): RecapDoc {
|
||||
const casualties = (i: 0 | 1) => (!m.lost ? 'Unknown' : m.lost[i].length ? `${plural(m.lost[i].length, 'card')} destroyed: ${m.lost[i].map(c => c.title).join(', ')}` : 'None');
|
||||
const commander = (i: 0 | 1) => m.played?.[i].find(c => /figure/i.test(c.type ?? ''))?.title ?? 'None recorded';
|
||||
const sections = [{ heading: 'Course of the battle', paragraphs: course }, { heading: 'Aftermath', paragraphs: aftermath }].filter(x => x.paragraphs.length);
|
||||
return { matchId: m.matchId, url: `/battle/${m.matchId}`, masthead: 'WikiDeck', title, lead, sections, references, footer: FOOTER,
|
||||
infobox: { date, location: m.modeName ? `WikiDeck · ${m.modeName}` : 'WikiDeck', result: m.winner === null ? 'Draw' : `Decisive victory for ${m.players[m.winner]}`,
|
||||
return { matchId: m.matchId, url: `/recap/${m.matchId}`, masthead: 'WikiDeck', title, lead, sections, references, footer: FOOTER,
|
||||
infobox: { date, location: m.modeName ? `WikiDeck · ${m.modeName}` : 'WikiDeck', result: m.winner === null ? 'Draw' : `Victory for ${m.players[m.winner]}`,
|
||||
belligerents: [a, b], commanders: [commander(0), commander(1)], strength: [strength(0), strength(1)], casualties: [casualties(0), casualties(1)] } };
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ try {
|
||||
// 4. Battle recap at 360 and desktop.
|
||||
for (const [w, h, name] of [[360, 740, '6-recap-360'], [1280, 900, '7-recap-desktop']]) {
|
||||
const { ctx, page: p } = await page(browser, { width: w, height: h, owned: 44 });
|
||||
await p.goto(base + '/battle/m_smoke');
|
||||
await p.goto(base + (w === 360 ? '/recap/m_smoke' : '/battle/m_smoke'));
|
||||
await p.getByRole('heading', { level: 1, name: /^Battle of / }).waitFor();
|
||||
await p.getByRole('heading', { name: 'References' }).waitFor();
|
||||
assert.ok(await p.locator('.recap-refs li').count() >= 8);
|
||||
|
||||
@@ -33,7 +33,8 @@ test('recap: deterministic, named after the winner’s decisive non-Figure card,
|
||||
assert.deepEqual(a.infobox.commanders, [pool[0].title, pool[5].title]);
|
||||
assert.equal(a.masthead, 'WikiDeck');
|
||||
assert.match(a.footer, /game events/);
|
||||
assert.equal(a.infobox.result, 'Decisive victory for alice');
|
||||
assert.equal(a.infobox.result, 'Victory for alice');
|
||||
assert.equal(a.url, '/recap/m_7f3a');
|
||||
});
|
||||
|
||||
test('recap: References cite every card played, once each, with revision ids', () => {
|
||||
@@ -53,7 +54,7 @@ test('recap: References cite every card played, once each, with revision ids', (
|
||||
test('recap text: fixed templates only, no adjectives about the outcome or winks', () => {
|
||||
const doc = fallbackRecap(parseMatchRecord(record));
|
||||
const text = [doc.lead, ...doc.sections.flatMap(s => s.paragraphs)].join(' ');
|
||||
assert.doesNotMatch(text, /!|lol|brutal|humiliat|heroic|surprising|twist|killed/i);
|
||||
assert.doesNotMatch(text, /!|lol|brutal|humiliat|heroic|surprising|twist|killed|decisive|pyrrhic/i);
|
||||
assert.match(text, /\*\*Battle of [^*]+\*\* was a WikiDeck engagement fought on 18 November 2026 between the forces of alice and bob/);
|
||||
assert.match(text, /nine turns/);
|
||||
assert.match(text, /bob was reduced to zero Notability\./);
|
||||
|
||||
Reference in New Issue
Block a user