diff --git a/src/game/OnlinePlay.tsx b/src/game/OnlinePlay.tsx index ae41c52..5695129 100644 --- a/src/game/OnlinePlay.tsx +++ b/src/game/OnlinePlay.tsx @@ -186,7 +186,12 @@ export function DuelOnlinePlay({ modeId, modeName, deck, entry, accountToken, on if (seat && status && !done) await pvp.resign(seat).catch(() => {}); onExit(); }; - const act = (a: unknown) => { if (seat) pvp.act(seat, a).then(apply, e => { setError(message(e)); void poll(); }); }; + /** Resolves once the host accepts the action and rejects on error, so ui-duel's board can send a declaration sequence (#58). */ + const act = async (a: unknown): Promise => { + if (!seat) throw new Error('Not seated.'); + try { apply(await pvp.act(seat, a)); } + catch (e) { setError(message(e)); void poll(); throw e; } + }; const invite = seat?.invite ?? status?.invite; const link = invite ? inviteUrl(invite) : ''; const copy = async () => { @@ -203,7 +208,7 @@ export function DuelOnlinePlay({ modeId, modeName, deck, entry, accountToken, on return
{eyebrow}

{status.phase === 'finished' ? (status.outcome?.winner === null ? 'Draw' : won ? 'Victory' : 'Defeat') : `vs ${opp}`}

- {status.phase === 'playing' && } + {status.phase === 'playing' && { act(a).catch(() => {}); }} opponent={opp} />} {error &&

{error}

}
diff --git a/src/game/collection/collection.ts b/src/game/collection/collection.ts index ee55880..9bc7125 100644 --- a/src/game/collection/collection.ts +++ b/src/game/collection/collection.ts @@ -10,6 +10,8 @@ export const DEFAULT_COPY_LIMIT = 4; export type CollectionCard = { tokenId: string; pageId: number; title: string; revisionId?: number; url?: string; imageUrl?: string; extract?: string; category?: string; height?: number; + /** Server-derived, frozen duel profile (ownership adds it for ui-duel's bot match, #58). Passed through untouched. */ + duel?: unknown; }; export type Collection = { deckSize: number; copyLimit: number; cards: CollectionCard[]; @@ -37,7 +39,7 @@ export function parseCollection(v: unknown): Collection { seen.add(tokenId); cards.push({ tokenId, pageId, title: str(c.title, 200) || `Page ${pageId}`, revisionId: int(c.revisionId, 1), url: httpUrl(c.url), imageUrl: httpUrl(c.imageUrl ?? c.image), extract: str(c.extract, 600) || undefined, - category: str(c.category, 40) || undefined, height: int(c.height) }); + category: str(c.category, 40) || undefined, height: int(c.height), ...(c.duel && typeof c.duel === 'object' ? { duel: c.duel } : {}) }); } return { deckSize: int(o.deckSize, 1, 200) ?? DEFAULT_DECK_SIZE, copyLimit: int(o.copyLimit, 1, 200) ?? DEFAULT_COPY_LIMIT, cards, source: 'server' }; }