From a2573129a5db29d92b800fc7c68236af89a3da0f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 23:25:29 -0500 Subject: [PATCH] Play: wire the real shared/game engine (DESIGN v1 Edit War) Replace the mock with an adapter over shared/game/index.ts: Topics with stats and hidden Portals, home-stat icons and on-topic hints, queued plays with undo, interleaved reveal log, engine deck validation, loaner starter decks, interim NFT derivation (cost-capped). Lobby reads the modes API (self + peers) and links to peer hosts; the account chip uses the SSO hook; the floating account button hides during a match. MatchView.engine / UIAction.engine expose engine state for ui-b's bots. Co-Authored-By: Claude Opus 5.5 --- src/game/DeckBuilder.tsx | 17 ++--- src/game/GameCard.tsx | 22 ++++-- src/game/MatchScreen.tsx | 30 +++++--- src/game/PlaySection.tsx | 90 ++++++++++++---------- src/game/Results.tsx | 2 +- src/game/Tutorial.tsx | 42 ++++++----- src/game/adapter.ts | 120 +++++++++++++++++++++++++++--- src/game/bots.ts | 6 +- src/game/cards.ts | 73 ++++++++---------- src/game/mock/engine.ts | 156 --------------------------------------- src/game/play.css | 10 +++ src/game/rulesText.ts | 40 ++++++++++ src/game/types.ts | 72 ++++++++---------- src/game/useAccount.ts | 9 +-- src/game/useModes.ts | 67 +++++++++++------ tests/ui-play.test.ts | 101 +++++++++++++++---------- 16 files changed, 456 insertions(+), 401 deletions(-) delete mode 100644 src/game/mock/engine.ts create mode 100644 src/game/rulesText.ts diff --git a/src/game/DeckBuilder.tsx b/src/game/DeckBuilder.tsx index fb170c4..07aedc6 100644 --- a/src/game/DeckBuilder.tsx +++ b/src/game/DeckBuilder.tsx @@ -2,15 +2,12 @@ import { useMemo, useState } from 'react'; import { Check, RotateCcw, Trash2 } from 'lucide-react'; import { GameCard } from './GameCard.tsx'; import { starterDeck } from './cards.ts'; -import type { Ruleset, UICard } from './types.ts'; +import { validateDeck, type Ruleset } from '../../shared/game/index.ts'; +import type { UICard } from './types.ts'; export function deckProblem(deck: UICard[], ruleset: Ruleset): string { if (deck.length !== ruleset.deckSize) return `A deck needs exactly ${ruleset.deckSize} cards (${deck.length} now).`; - const counts = new Map(); - for (const c of deck) counts.set(c.pageId, (counts.get(c.pageId) ?? 0) + 1); - const over = [...counts].find(([, n]) => n > ruleset.maxCopies); - if (over) return `At most ${ruleset.maxCopies} copies of the same article.`; - return ''; + return validateDeck(ruleset, deck.map(c => c.game))[0] ?? ''; } /** Soft advice (DESIGN.md s8): warn, never block, when the early curve is thin. */ @@ -19,8 +16,8 @@ export function deckWarning(deck: UICard[]): string { return cheap < 4 ? `Only ${cheap} card${cheap === 1 ? '' : 's'} cost 2 or less. Aim for at least 4 so you have early plays.` : ''; } -export function DeckBuilder({ pool, deck, ruleset, onSave, onCancel }: { - pool: UICard[]; deck: UICard[]; ruleset: Ruleset; onSave: (deck: UICard[]) => void; onCancel: () => void; +export function DeckBuilder({ pool, deck, ruleset, modeName, onSave, onCancel }: { + modeName: string; pool: UICard[]; deck: UICard[]; ruleset: Ruleset; onSave: (deck: UICard[]) => void; onCancel: () => void; }) { const [draft, setDraft] = useState(deck); const [filter, setFilter] = useState<'all' | 'starter' | 'nft'>('all'); @@ -37,7 +34,7 @@ export function DeckBuilder({ pool, deck, ruleset, onSave, onCancel }: { const full = draft.length >= ruleset.deckSize; return
-
DECK BUILDER · {ruleset.name.toUpperCase()}
+
DECK BUILDER · {modeName.toUpperCase()}

Your deck {draft.length} / {ruleset.deckSize}

Tap a card to add it or take it out. Loaner cards are free previews, not NFTs; nothing you do here moves a card on-chain.

{curve.map((n, i) =>
{i + 1}{i === 5 ? '+' : ''}{n}
)}
@@ -58,7 +55,7 @@ export function DeckBuilder({ pool, deck, ruleset, onSave, onCancel }: { {problem ?

{problem}

: warning &&

{warning}

}
- + diff --git a/src/game/GameCard.tsx b/src/game/GameCard.tsx index 03410b8..961a116 100644 --- a/src/game/GameCard.tsx +++ b/src/game/GameCard.tsx @@ -1,13 +1,23 @@ -import { BookOpen, Landmark, Leaf, Orbit, Palette, Users, Zap } from 'lucide-react'; -import type { UICard } from './types.ts'; +import { BookOpen, ChevronDown, ChevronUp, Eye, Globe2, Landmark, Leaf, Library, Orbit, Palette, Users, Zap } from 'lucide-react'; +import type { Stat, UICard } from './types.ts'; +import { STAT_LABEL } from './rulesText.ts'; const ICONS: Record = { Space: Orbit, Nature: Leaf, People: Users, Science: BookOpen, History: Landmark, Culture: Palette }; export const CategoryIcon = ({ category, size = 14 }: { category: string; size?: number }) => { const Icon = ICONS[category] ?? Palette; return