Merge pull request '[ui-pvp] Online duels render the DuelBoard (#65)' (#85) from night2/ui-pvp/board-wiring into night/2026-11-17

This commit is contained in:
2026-11-18 16:16:07 +00:00
+12
View File
@@ -5,6 +5,8 @@ import { engineAction, resultView, uiActions, viewFromPlayerView } from './adapt
import { toUICard } from './cards.ts';
import { GameCard as GameCardFace } from './GameCard.tsx';
import { MatchBoard } from './MatchBoard.tsx';
import { DuelBoard } from './duel/DuelBoard.tsx';
import type { DuelAction, LogEvent, PlayerView as DuelPlayerView } from './duel/contract.ts';
import { inviteUrl, online, pvp, type DuelSeat, type DuelStatus, type LobbySeat, type LobbyStatus, type OpenLobby } from './online.ts';
import type { GameMode, ResultView, UIAction } from './types.ts';
@@ -201,8 +203,18 @@ export function DuelOnlinePlay({ modeId, modeName, deck, entry, accountToken, on
} catch { setCopied('Select the link above and copy it.'); }
};
const opp = status?.players.find((_, i) => i !== seat?.seat)?.name ?? 'Opponent';
const me = (seat ? status?.players[seat.seat]?.name : undefined) ?? 'You';
const eyebrow = `${modeName.toUpperCase()} · ${entry.kind === 'quick' ? 'QUICK MATCH' : entry.kind === 'private' ? 'PRIVATE LOBBY' : 'INVITE'}`;
if ((status?.phase === 'playing' || status?.phase === 'finished') && status.state && typeof status.state === 'object') {
// ui-duel's board (#58) on duel-core's PlayerView; it sends multi-step declarations through `act`, awaiting each.
const view = status.state as DuelPlayerView;
const events = (view as { log?: unknown }).log;
return <DuelBoard view={view} legal={(status.legalActions ?? []) as DuelAction[]} onAct={a => act(a)}
opponentName={opp} playerName={me} error={error || undefined}
logEvents={Array.isArray(events) ? events as LogEvent[] : undefined}
onExit={() => void leave()} onRecap={status.phase === 'finished' && status.matchId ? () => onRecap(status.matchId!) : undefined} />;
}
if (status?.phase === 'playing' || status?.phase === 'finished') {
const won = status.outcome && status.outcome.winner !== null && status.outcome.winner === seat?.seat;
return <section className="play-panel" aria-labelledby="duel-title">