Add an enlarged public sheet beneath each player, available while actions are pending. Only faction identity and table rules mode enter the reader; it sends no action and receives no private player data. Basic/Advanced preview explicitly leaves the table mode unchanged. Native mode control, keyboard scrolling, Escape/focus restoration and internal links use existing dialog components. The internal gallery covers all twelve factions with bundled Homeworld artwork. Share every faction's Basic and Advanced paragraphs with the main reference. Replace Richese's generic placeholder, centralize Ecaz/Moritani guidance from settled contracts, correct CHOAM Auditor/Baliset/Jubba availability and align the Fremen/Ecaz Sietch Tabr exception. Full printed text, unresolved powers and combined-rule acceptance remain explicit. No new rule, AI strategy or gate. Four focused tests cover all12 identities, shared paragraphs, artwork files, internal links, mode separation, gallery defaults and per-viewer busy controls. The first busy-control assertion falsely matched CSS disabled variants; it now checks actual disabled attributes. All16 related focused cases pass. Independent review caught missing Moritani optionality and stale Fremen exception text; those were fixed and final review found no material issue. Auditor limits and full actual-card cancellation cost were checked against the existing contract. Types, lint, all 5000 offline tests and production build pass on stable source. No API/auth/persistence changes; HTTP tests were not repeated. Browser QA reused the existing two-player Basic auction without game actions. Both own and opposing inspectors work; Enter opens, Escape closes and returns focus, reopening resets Basic, and Advanced preview explicitly preserves the Basic table. ArrowDown scrolls the focused long sheet. At390px, dialog359x828, scroll client/width342 without horizontal overflow,16px text and44px controls. Gallery334px fits without overflow; Richese, Ecaz and Moritani selection and Advanced paragraphs render, faction change resets Basic and bundled art loads. Internal help and Advanced Moritani links expand their topics. Back and refresh preserve four hand cards and the pending minimum bid2; normal viewport restored. Screenshot capture timed out; full visual/screen-reader acceptance remains open. All 1539 opening games, 3259 saved seats and auxiliary rows remain identical, including the QA room. SQLite integrity and foreign keys pass. No new games, server restart, migration, reset or recurring automation. Private evidence: 20260921-faction-sheets. Verified source tree: 6b738958f30fc381d3e9eb26398239bbd88f1d4281f8ff5ff2bb3b3259494a93
81 lines
4.9 KiB
TypeScript
81 lines
4.9 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import Image from 'next/image';
|
|
import Link from 'next/link';
|
|
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
import { Eye, X } from 'lucide-react';
|
|
import { FACTIONS, faction, type FactionId } from '@/game/catalog';
|
|
import { FACTION_RULES } from '@/game/faction-reference';
|
|
import { HOMEWORLD_CARDS } from '@/game/homeworld-cards';
|
|
import { Button } from './ui/button';
|
|
import { Dialog, DialogClose, DialogDescription, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from './ui/dialog';
|
|
|
|
/** Static public reference only: no player, holdings, hidden choices or action callback. */
|
|
export function FactionSheet({ factionId, advanced }: { factionId: FactionId; advanced: boolean }) {
|
|
const house = faction(factionId);
|
|
const rules = FACTION_RULES[factionId];
|
|
const world = HOMEWORLD_CARDS.find(card => card.faction === factionId)!;
|
|
return <article className="faction-sheet" aria-label={`${house.name} faction sheet`} style={{ borderTopColor: house.color }}>
|
|
<header>
|
|
<p className="faction-sheet-label">Faction sheet · {advanced ? 'Advanced' : 'Basic'}</p>
|
|
<h3>{house.name}</h3>
|
|
<p>{house.title}</p>
|
|
</header>
|
|
<Image src={`/art/homeworlds/${world.id}-v1.png`} alt="" width={1536} height={768} unoptimized loading="lazy" className="faction-sheet-art" />
|
|
<section aria-label={`${house.name} Basic powers and alliances`}>
|
|
<h4>Basic powers and alliances</h4>
|
|
<ol>{rules.basic.map(text => <li key={text}>{text}</li>)}</ol>
|
|
</section>
|
|
{advanced && <section aria-label={`${house.name} Advanced powers`}>
|
|
<h4>Advanced powers</h4>
|
|
<p>Use these with the Basic powers above and the Advanced game rules.</p>
|
|
<ol>{rules.advanced.map(text => <li key={text}>{text}</li>)}</ol>
|
|
</section>}
|
|
<footer>
|
|
<p>The rules and game are still being completed. This sheet describes faction powers; table controls show the choices currently available. Optional modules can add or change powers.</p>
|
|
<Link href={`/rules?topic=faction-${factionId}#faction-${factionId}`}>Full {house.name} reference</Link>
|
|
{advanced && <Link href={`/rules?topic=advanced-${factionId}#advanced-${factionId}`}>Advanced {house.name} reference</Link>}
|
|
</footer>
|
|
</article>;
|
|
}
|
|
|
|
function FactionSheetReader({ factionId, tableAdvanced }: { factionId: FactionId; tableAdvanced?: boolean }) {
|
|
const [advanced, setAdvanced] = useState(tableAdvanced ?? false);
|
|
return <div className="faction-sheet-reader">
|
|
{tableAdvanced !== undefined && <p className="force-notice">This table uses <strong>{tableAdvanced ? 'Advanced' : 'Basic'} rules</strong>.{advanced !== tableAdvanced && ' You are previewing the other rules mode; the table has not changed.'}</p>}
|
|
<label className="faction-sheet-toggle"><input type="checkbox" checked={advanced} onChange={event => setAdvanced(event.target.checked)} /> Include Advanced powers</label>
|
|
<FactionSheet factionId={factionId} advanced={advanced} />
|
|
</div>;
|
|
}
|
|
|
|
export function FactionInspector({ factionId, advanced }: { factionId: FactionId; advanced: boolean }) {
|
|
const house = faction(factionId);
|
|
return <Dialog>
|
|
<DialogTrigger render={<Button variant="outline" className="min-h-11 min-w-11 motion-reduce:transition-none" />} aria-label={`Inspect faction: ${house.name}`}>
|
|
<Eye aria-hidden="true" />Inspect faction
|
|
</DialogTrigger>
|
|
<DialogPortal>
|
|
<DialogOverlay className="bg-black/75 motion-reduce:animate-none motion-reduce:transition-none" />
|
|
<DialogPrimitive.Popup className="force-dialog">
|
|
<div className="force-dialog-header"><span>Public faction sheet</span><DialogClose render={<Button variant="outline" className="min-h-11 min-w-11" />}><X aria-hidden="true" />Close</DialogClose></div>
|
|
{/* oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- The long faction sheet scrolls independently and needs keyboard access. */}
|
|
<section className="force-dialog-scroll" aria-label="Faction sheet details" tabIndex={0}>
|
|
<DialogTitle>{house.name} faction sheet</DialogTitle>
|
|
<DialogDescription>Read public faction powers and alliance guidance without changing the game.</DialogDescription>
|
|
<FactionSheetReader key={`${factionId}:${advanced}`} factionId={factionId} tableAdvanced={advanced} />
|
|
<Link className="faction-sheet-help" href="/rules?topic=faction-sheets#faction-sheets">Faction sheet help</Link>
|
|
</section>
|
|
</DialogPrimitive.Popup>
|
|
</DialogPortal>
|
|
</Dialog>;
|
|
}
|
|
|
|
export function FactionSheetGallery() {
|
|
const [selected, setSelected] = useState<FactionId>('atreides');
|
|
return <section className="force-reference" aria-label="Faction sheet gallery">
|
|
<label>Faction sheet<select value={selected} onChange={event => setSelected(event.target.value as FactionId)}>{FACTIONS.map(house => <option key={house.id} value={house.id}>{house.name}</option>)}</select></label>
|
|
<FactionSheetReader key={selected} factionId={selected} />
|
|
</section>;
|
|
}
|