From 0875573cd702d211a95379f072796c8660b3fc06 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 22:01:28 -0500 Subject: [PATCH] [ui-pvp] PvP-first Play: owned-card eligibility, deck picker, quick match, invites, ladder, battle recap page - src/game/collection/: collection model (GET /api/game/collection, local fallback), 40-card eligibility with the 4-per-article copy limit, "23 / 40 cards. Mine to play" gate, constructed deck picker. No loaners, starters or borrowed decks (BRIEF decisions 1-2). - PlaySection: PvP hub with quick match, private lobby + invite link, join by link, ladder; bot match slot waits for ui-duel's board. - online.ts / OnlinePlay.tsx: duel PvP client against host-pvp's routes (idToken in body, Bearer seat token, ?v= polling with 204), validated responses. - Leaderboards: Elo ladder with W/L fallback. - src/game/recap/: /battle/ (and /recap/) standalone page rendering duel-design's RecapDoc shape; deterministic template fallback over real match data until #69 merges. - App: /play/invite/ and /battle/ deep links; session.idToken(). - tests/ui-pvp-*.test.ts, tests/e2e/ui-pvp-smoke.mjs (Playwright, stubbed API). Co-Authored-By: Claude Opus 5.5 --- src/App.tsx | 19 ++- src/auth/session.ts | 3 + src/game/Leaderboards.tsx | 20 +++ src/game/OnlinePlay.tsx | 104 ++++++++++++- src/game/PlaySection.tsx | 190 +++++++++++------------ src/game/collection/CollectionScreen.tsx | 69 ++++++++ src/game/collection/collection.ts | 106 +++++++++++++ src/game/collection/duelModes.ts | 21 +++ src/game/collection/pvp.css | 37 +++++ src/game/collection/useCollection.ts | 33 ++++ src/game/online.ts | 110 +++++++++++++ src/game/recap/BattleRecap.tsx | 92 +++++++++++ src/game/recap/model.ts | 169 ++++++++++++++++++++ src/game/recap/recap.css | 28 ++++ tests/e2e/ui-pvp-smoke.mjs | 88 +++++++++++ tests/ui-pvp-collection.test.ts | 99 ++++++++++++ tests/ui-pvp-recap.test.ts | 95 ++++++++++++ 17 files changed, 1181 insertions(+), 102 deletions(-) create mode 100644 src/game/collection/CollectionScreen.tsx create mode 100644 src/game/collection/collection.ts create mode 100644 src/game/collection/duelModes.ts create mode 100644 src/game/collection/pvp.css create mode 100644 src/game/collection/useCollection.ts create mode 100644 src/game/recap/BattleRecap.tsx create mode 100644 src/game/recap/model.ts create mode 100644 src/game/recap/recap.css create mode 100644 tests/e2e/ui-pvp-smoke.mjs create mode 100644 tests/ui-pvp-collection.test.ts create mode 100644 tests/ui-pvp-recap.test.ts diff --git a/src/App.tsx b/src/App.tsx index e302ace..9f5936b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,6 +15,9 @@ import { TradeDesk } from './TradeDesk.tsx'; import { IS_MAINNET, NETWORK_GENESIS_TIME, NETWORK_LABEL } from '../shared/network.ts'; import { StateClient } from '../shared/rpc-client.ts'; import { PlaySection } from './game/PlaySection.tsx'; +import { inviteFromPath } from './game/online.ts'; +import { BattleRecap, matchIdFromPath } from './game/recap/BattleRecap.tsx'; +import './game/recap/recap.css'; import { isNativeApp } from './native.ts'; import { Landing } from './Landing.tsx'; import './App.css'; @@ -47,7 +50,17 @@ function transferProblem(state: TestnetSnapshot, card: CardData, address: string } export default function App() { - const [view, setView] = useState('Discover'); + // Deep links (Night 2, ui-pvp): /play/invite/ opens Play with the invite; /battle/ is a recap page. + const [invite] = useState(() => inviteFromPath(location.pathname)); + const [battle, setBattle] = useState(() => matchIdFromPath(location.pathname)); + const [view, setView] = useState(() => (invite ? 'Play' : 'Discover')); + const openRecap = (id: string) => { history.pushState(null, '', `/battle/${encodeURIComponent(id)}`); setBattle(id); }; + const closeRecap = () => { history.pushState(null, '', '/'); setBattle(''); }; + useEffect(() => { + const pop = () => setBattle(matchIdFromPath(location.pathname)); + window.addEventListener('popstate', pop); + return () => window.removeEventListener('popstate', pop); + }, []); const [wallet, setWallet] = useState(); const [snapshot, setSnapshot] = useState(); const [rpcAvailable, setRpcAvailable] = useState(false); @@ -161,6 +174,8 @@ export default function App() { catch (e) { setError(message(e)); } }; + // /battle/: a standalone, shareable recap page (no hero or mining panel around it). + if (battle) return
; return