forked from WikiDeck/wikideck
[ui-pvp] online duels render ui-duel's DuelBoard (placeholder kept only when the host sends no view)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import { engineAction, resultView, uiActions, viewFromPlayerView } from './adapt
|
|||||||
import { toUICard } from './cards.ts';
|
import { toUICard } from './cards.ts';
|
||||||
import { GameCard as GameCardFace } from './GameCard.tsx';
|
import { GameCard as GameCardFace } from './GameCard.tsx';
|
||||||
import { MatchBoard } from './MatchBoard.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 { inviteUrl, online, pvp, type DuelSeat, type DuelStatus, type LobbySeat, type LobbyStatus, type OpenLobby } from './online.ts';
|
||||||
import type { GameMode, ResultView, UIAction } from './types.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.'); }
|
} catch { setCopied('Select the link above and copy it.'); }
|
||||||
};
|
};
|
||||||
const opp = status?.players.find((_, i) => i !== seat?.seat)?.name ?? 'Opponent';
|
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'}`;
|
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') {
|
if (status?.phase === 'playing' || status?.phase === 'finished') {
|
||||||
const won = status.outcome && status.outcome.winner !== null && status.outcome.winner === seat?.seat;
|
const won = status.outcome && status.outcome.winner !== null && status.outcome.winner === seat?.seat;
|
||||||
return <section className="play-panel" aria-labelledby="duel-title">
|
return <section className="play-panel" aria-labelledby="duel-title">
|
||||||
|
|||||||
Reference in New Issue
Block a user