forked from WikiDeck/wikideck
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 <noreply@anthropic.com>
52 lines
4.7 KiB
TypeScript
52 lines
4.7 KiB
TypeScript
import { useState } from 'react';
|
||
import { ArrowLeft, ArrowRight, Check } from 'lucide-react';
|
||
import { GameCard, StatIcon } from './GameCard.tsx';
|
||
import { starterDeck } from './cards.ts';
|
||
import type { Stat } from './types.ts';
|
||
|
||
const demo = starterDeck();
|
||
const pick = (cost: number) => demo.find(c => c.cost === cost) ?? demo[0];
|
||
const TOPICS: [string, Stat, string][] = [['Current Events', 'attention', '9 – 5'], ['Archive', 'depth', '4 – 7'], ['Translations', 'reach', '6 – 3']];
|
||
const STEPS = [
|
||
{ title: 'Win two of three Topics', show: 'lanes',
|
||
body: 'The board has three Topics (lanes). After turn 6, whoever has more power in a Topic leads it. Lead two Topics to win. If that’s tied, total power decides.' },
|
||
{ title: 'Every card shows a few things', show: 'card',
|
||
body: 'Top left is cost: the energy it takes to play. Top right is power. The small icon is the card’s home stat, and the word at the bottom is its keyword. Tap any card on the board to read what it does.' },
|
||
{ title: 'Play on-topic for a bonus', show: 'stats',
|
||
body: 'Each Topic is judged on one Wikipedia stat: Attention (readers), Depth (article length) or Reach (languages). A card whose home stat matches gets extra power there. The lane says “On-topic +N” when you pick a matching card.' },
|
||
{ title: 'Energy grows each turn', show: 'energy',
|
||
body: 'You get 1 energy on turn 1, 2 on turn 2, up to 6. You can carry 1 unspent energy to the next turn. Famous articles cost more, but they aren’t more efficient: it’s a trade-off.' },
|
||
{ title: 'Tap a card, then tap a Topic', show: 'play',
|
||
body: 'Tap a card in your hand to pick it up, then tap a Topic to queue it there. Tap a queued card to take it back. Each Topic holds 3 of your cards. Press End turn when you’re done.' },
|
||
{ title: 'Reveals take turns', show: 'reveal',
|
||
body: 'Both players plan in secret. Then the cards reveal one at a time, alternating, starting with whoever has initiative (it swaps every turn). Some keywords care about what’s already there, so order matters.' },
|
||
{ title: 'Portals change the rules', show: 'portal',
|
||
body: 'Each Topic hides a Portal that reveals on turn 2, 3 or 4. Portals bend that Topic’s rules, for example “Only 2 cards per player fit here.” Tap a Topic to read its Portal.' },
|
||
];
|
||
|
||
export function Tutorial({ onDone }: { onDone: () => void }) {
|
||
const [i, setI] = useState(0);
|
||
const step = STEPS[i];
|
||
return <section className="play-panel tutorial" aria-labelledby="tutorial-title">
|
||
<div className="section-eyebrow">HOW TO PLAY · {i + 1} / {STEPS.length}</div>
|
||
<h2 id="tutorial-title">{step.title}</h2>
|
||
<div className="tutorial-visual" aria-hidden="true">
|
||
{step.show === 'lanes' && <div className="tut-lanes">{TOPICS.map(([n, stat, score], k) => <div key={n} className={k === 1 ? 'lost' : 'won'}><StatIcon stat={stat} size={14} /><span>{n}</span><b>{score}</b></div>)}</div>}
|
||
{step.show === 'card' && <div className="tut-card"><GameCard card={pick(3)} /><ul><li><b>{pick(3).cost}</b> cost</li><li><b>{pick(3).power}</b> power</li><li><StatIcon stat={pick(3).home} /> home stat</li><li><b>{pick(3).keyword?.name}</b> keyword</li></ul></div>}
|
||
{step.show === 'stats' && <div className="tut-lanes">{TOPICS.map(([, stat]) => <div key={stat} className={stat === 'depth' ? 'won' : ''}><StatIcon stat={stat} size={18} /><span>{stat[0].toUpperCase() + stat.slice(1)}</span>{stat === 'depth' && <b>+1</b>}</div>)}</div>}
|
||
{step.show === 'energy' && <div className="tut-energy">{[1, 2, 3, 4, 5, 6].map(n => <span key={n} style={{ height: `${n * 10 + 10}px` }}>{n}</span>)}</div>}
|
||
{step.show === 'play' && <div className="tut-card"><GameCard card={pick(1)} selected /><ArrowRight size={22} /><div className="tut-lane-target">Archive<small>On-topic +1</small></div></div>}
|
||
{step.show === 'reveal' && <div className="tut-card"><div className="tut-facedown">1</div><div className="tut-facedown">2</div><div className="tut-facedown">3</div><ArrowRight size={22} /><GameCard card={pick(4)} size="deck" /></div>}
|
||
{step.show === 'portal' && <div className="tut-lane-target portal">Stub<small>Only 2 cards per player fit here.</small></div>}
|
||
</div>
|
||
<p>{step.body}</p>
|
||
<div className="play-actions">
|
||
<button className="button outline" onClick={() => setI(i - 1)} disabled={i === 0}><ArrowLeft size={16} /> Back</button>
|
||
{i < STEPS.length - 1
|
||
? <button className="button dark" onClick={() => setI(i + 1)}>Next <ArrowRight size={16} /></button>
|
||
: <button className="button dark" onClick={onDone}><Check size={16} /> Got it</button>}
|
||
</div>
|
||
<button className="text-button skip" onClick={onDone}>Skip tutorial</button>
|
||
</section>;
|
||
}
|