diff --git a/src/game/OnlinePlay.tsx b/src/game/OnlinePlay.tsx index bac1ca1..b459257 100644 --- a/src/game/OnlinePlay.tsx +++ b/src/game/OnlinePlay.tsx @@ -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 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