/** 젝스님트 화면 (docs/games/six-nimmt.md §9). Penalty points (소머리) are play points of this room only. */ import { useEffect, useRef, useState, type ReactNode } from 'react'; import type { LogEntry, Marker, Pending, SixHandCard, SixNimmtOptions, SixNimmtView } from '@bg/games/six-nimmt'; import { bulls as bullsOfCard, type Card, type Preview, type Step } from '@bg/games/six-nimmt/rules'; import type { PublicUser } from '@bg/shared/lite'; import { Avatar, ConfirmSheet } from '../../components/ui'; import { TurnTimer } from '../../components/TurnTimer'; import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback'; import { fxMs } from '../../lib/motion'; import type { BoardProps, GameUI, OptionsProps } from '../types'; import { helpNow } from './help'; import { quickStart } from './quick'; const nick = (players: Record, id: string) => players[id]?.nickname ?? '알 수 없음'; const userOf = (players: Record, id: string): PublicUser => players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' }; const who = (players: Record, me: string | null, p: string) => (p === me ? '나' : nick(players, p)); const reducedMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches; const ROW_NAMES = ['1번 줄', '2번 줄', '3번 줄', '4번 줄']; /** Sounds on top of the shared palette (site volume applies). */ const sxSound = { /** A card put on a row. */ place: () => { noise(60, 0.14, 0, 'bandpass', 1400, 0.9); tone(260, 50, 'triangle', 0.08); }, /** "음매": lower and longer the more cows were taken. */ moo: (n: number) => { const ms = Math.min(900, 380 + n * 40); const f = Math.max(110, 230 - n * 8); tone(f, ms, 'sawtooth', 0.06, 0, { slideTo: f * 0.72 }); tone(f * 1.5, ms * 0.8, 'sine', 0.05, 30, { slideTo: f * 1.05 }); }, /** The fan card / cow moving. */ hop: () => tone(520, 160, 'sine', 0.08, 0, { slideTo: 980 }), }; // ---------------------------------------------------------------- cards const toneOf = (b: number) => (b >= 7 ? 'b7' : b >= 5 ? 'b5' : b >= 3 ? 'b3' : b >= 2 ? 'b2' : 'b1'); const bullText = (b: number) => (b > 1 ? `🐮${b}` : '🐮'); function NumCard({ n, size = 'row', flipped, cls = '', label }: { n: Card; size?: 'row' | 'hand' | 'mini'; flipped?: number; cls?: string; label?: string }) { const b = bullsOfCard(n); return ( {bullText(b)} {flipped ?? n} {flipped !== undefined && ( 원래 {n} )} ); } function markerLabel(m: Marker | null, row: number): string | null { if (!m || m.row !== row) return null; if (m.kind === 'evenOdd') return m.parity === 'even' ? '짝수만' : '홀수만'; if (m.kind === 'mountain') return `산 오르기(작은 수)${m.dir === 'up' ? ' ▲' : ' ▼'}`; return null; } function MarkerIcon({ m, row }: { m: Marker | null; row: number }) { if (!m || m.row !== row || m.kind === 'cow') return null; const text = m.kind === 'evenOdd' ? (m.parity === 'even' ? '짝' : '홀') : m.dir === 'up' ? '⛰▲' : '⛰▼'; return ( {text} ); } // ---------------------------------------------------------------- reveal playback interface Playback { /** Rows to draw (the live rows when nothing is being replayed). */ rows: Card[][]; marker: Marker | null; /** Step being shown (its row glows, takes show a banner). */ step: Step | null; /** Cards of the revealed turn still waiting, in order (shown above the rows). */ waiting: { player: string; card: Card; value: number; flip: boolean }[]; /** True while the drawing is behind the view. */ busy: boolean; } /** * The view already has the whole turn placed; the board replays it one card at a time (0.45 s each, hurried when far * behind). A board that opens mid-game shows the current rows without replaying. */ function usePlayback(v: SixNimmtView): Playback { const rv = v.reveal; const [pos, setPos] = useState(() => ({ id: rv?.id ?? 0, shown: rv?.steps.length ?? 0 })); const live = (): Playback => ({ rows: v.rows.map((r) => r.cards.map((c) => c.n)), marker: v.marker, step: null, waiting: v.queue.map((q) => ({ ...q })), busy: false }); useEffect(() => { if (!rv) return; if (reducedMotion()) { if (pos.id !== rv.id || pos.shown !== rv.steps.length) setPos({ id: rv.id, shown: rv.steps.length }); return; } if (pos.id !== rv.id) { setPos({ id: rv.id, shown: -1 }); sfx.cardFlip(); return; } if (pos.shown >= rv.steps.length) return; const behind = rv.steps.length - pos.shown; const t = setTimeout(() => setPos((p) => ({ ...p, shown: p.shown + 1 })), fxMs(pos.shown < 0 ? 650 : behind > 4 ? 220 : 450)); return () => clearTimeout(t); }, [rv?.id, rv?.steps.length, pos.id, pos.shown]); // eslint-disable-line react-hooks/exhaustive-deps // Sound of the step just shown. useEffect(() => { if (!rv || pos.id !== rv.id || pos.shown < 0) return; const st = rv.steps[pos.shown]; if (!st) return; if (st.t === 'place') { if (st.took.length) { sxSound.moo(st.bulls); haptic(40); } else sxSound.place(); } else if (st.t === 'cow' && st.took.length) sxSound.moo(st.bulls); else sxSound.hop(); }, [pos.id, pos.shown]); // eslint-disable-line react-hooks/exhaustive-deps // A new reveal is drawn from its start even before the effect above has caught up. const cur = !rv ? pos : pos.id === rv.id ? pos : { id: rv.id, shown: reducedMotion() ? rv.steps.length : -1 }; if (!rv || cur.shown >= rv.steps.length) return live(); const placed = new Set(rv.steps.slice(0, Math.max(0, cur.shown + 1)).filter((s) => s.t === 'place').map((s) => (s as { card: Card }).card)); const waiting = rv.plays.filter((p) => !placed.has(p.card)); if (cur.shown < 0) return { rows: rv.before.rows, marker: rv.before.marker, step: null, waiting, busy: true }; const st = rv.steps[cur.shown]!; return { rows: st.rows, marker: st.marker, step: st, waiting, busy: true }; } // ---------------------------------------------------------------- rows function Rows({ v, pb, me, players, act, pending, overlay }: { v: SixNimmtView; pb: Playback; me: string | null; players: Record; act: (a: unknown) => void; pending: boolean; overlay?: ReactNode }) { const pd = v.pending; const mine = !pb.busy && v.phase === 'choose' && pd && pd.player === me; const fewest = mine && pd!.kind === 'takeRow' ? recommendRow(v) : -1; const st = pb.step; const glowRow = st ? (st.t === 'place' ? st.row : st.t === 'cow' ? st.to : st.to) : -1; return (
{pb.rows.map((r, i) => { const cow = pb.marker?.kind === 'cow' && pb.marker.row === i; const slots = r.length + (cow ? 1 : 0); const rb = r.reduce((t, c) => t + bullsOfCard(c), 0); const ml = markerLabel(pb.marker, i); const taking = st && st.t === 'place' && st.row === i && st.took.length > 0; const choicesHere = mine && pd!.kind === 'place' ? pd!.choices.filter((c) => c.row === i) : []; const placeL = choicesHere.find((c) => c.side === 'L'); const placeR = choicesHere.find((c) => c.side === 'R'); return (
= 5 ? ' full' : ''}`} aria-label={`${ROW_NAMES[i]}: ${r.join(', ')}${cow ? ', 소' : ''} · 소머리 ${rb}개${ml ? ` · ${ml}` : ''}${slots >= 5 ? ' · 다음 카드가 가져가요' : ''}`}>
{i + 1} 🐮{rb}
{placeL && ( )} {r.map((c, k) => ( ))} {cow && ( 🐄 )} {placeR && ( )} {Array.from({ length: Math.max(0, 6 - slots - (placeL ? 1 : 0) - (placeR ? 1 : 0)) }, (_, k) => ( {slots + k === 5 ? '6' : ''} ))}
{mine && pd!.kind === 'takeRow' && ( )}
); })} {st && ((st.t === 'place' && st.took.length > 0) || (st.t === 'cow' && st.took.length > 0)) && (
{who(players, me, st.player)} +🐮{st.bulls} {st.t === 'cow' ? '(소가 뛰어서 한 줄 더!)' : st.why === 'low' ? '(너무 작은 카드)' : '(6번째 카드)'}
)} {overlay &&
{overlay}
}
); } /** Fewest bulls, then the largest end card (the same row the timeout takes). */ function recommendRow(v: SixNimmtView): number { let best = 0; v.rows.forEach((r, i) => { const b = v.rows[best]!; if (r.bulls < b.bulls || (r.bulls === b.bulls && r.cards.at(-1)!.n > b.cards.at(-1)!.n)) best = i; }); return best; } // ---------------------------------------------------------------- players strip / revealed cards function Strip({ v, me, players, active, deadline }: { v: SixNimmtView; me: string | null; players: Record; active: string[]; deadline: number | null }) { const playing = v.phase !== 'finished'; return (
{v.seats.map((p) => { const pv = v.players[p]!; const on = playing && active.includes(p); const state = pv.left ? '나감' : pv.away ? '자리 비움' : v.phase === 'select' ? (pv.picked ? '골랐어요' : '고르는 중') : v.phase === 'choose' && v.pending?.player === p ? '줄 고르는 중' : v.phase === 'draft' && v.draft?.at === p ? '카드 가져가는 중' : ''; return (
{who(players, me, p)} {v.phase === 'select' && pv.picked && ( ✔ )}
{pv.total} 점 {pv.roundBulls > 0 && +🐮{pv.roundBulls}} {v.options.fanCard === 'flipDigits' && pv.flipLeft && 🔄}
{state &&
{state}
} {on && p === me && deadline && ( )}
); })}
); } function Revealed({ v, pb, me, players }: { v: SixNimmtView; pb: Playback; me: string | null; players: Record }) { if (!pb.waiting.length) return null; const pd = !pb.busy ? v.pending : null; return (
공개된 카드
{pb.waiting.map((p) => (
{who(players, me, p.player)}
))}
); } // ---------------------------------------------------------------- hand / draft function previewText(p: Preview | undefined): string { if (!p) return ''; if ('low' in p) return `⬇ 너무 작음`; if (p.takes > 0) return `⚠ 가져감 🐮${p.takes}`; return `${p.row + 1}번 줄 ${p.side === 'L' ? '왼쪽' : `${p.pos}번째`}${'tie' in p && p.tie ? '(고름)' : ''}`; } function Hand({ v, act, pending }: { v: SixNimmtView; act: (a: unknown) => void; pending: boolean }) { const my = v.my!; const [pick, setPick] = useState(null); const [flip, setFlip] = useState(false); const sel = my.selected; useEffect(() => { setPick(null); setFlip(false); }, [v.round, v.turn]); const open = v.phase === 'select'; const canFlipNow = v.options.fanCard === 'flipDigits' && v.players[v.me!]!.flipLeft; const chosen = pick ?? sel?.card ?? null; const chosenCard = my.hand.find((h) => h.n === chosen); const useFlip = flip && !!chosenCard?.flipped; const send = (n: Card, f: boolean) => { sfx.cardPlay(); act({ type: 'SELECT', card: n, ...(f ? { flip: true } : {}) }); setPick(null); }; const same = sel && chosen === sel.card && sel.flip === useFlip; const tap = (h: SixHandCard) => { if (!open || pending) return; if (pick === h.n) send(h.n, flip && !!h.flipped); else { sfx.select(); setPick(h.n); } }; return (
{open && (

{sel ? `낸 카드: ${sel.card}${sel.flip ? '(뒤집기)' : ''} · 모두 내기 전에는 다른 카드를 눌러 바꿀 수 있어요.` : '카드를 누르면 올라와요. 한 번 더 누르거나 [이 카드 내기]로 내요.'} 카드 아래 표시는 지금 줄 기준이에요. 다른 사람 카드에 따라 달라져요.

)}
{my.hand.map((h) => { const up = chosen === h.n; const pv = flip && h.flipped ? h.flipped.preview : h.preview; return ( ); })}
{open && (
{canFlipNow && ( )}
)}
); } function Draft({ v, me, players, act, pending }: { v: SixNimmtView; me: string | null; players: Record; act: (a: unknown) => void; pending: boolean }) { const d = v.draft!; const mine = d.at === me; const myCount = me && v.my ? v.my.hand.length : 0; return (

{mine ? '내 차례예요. 펼쳐진 카드에서 한 장을 가져가세요' : `${nick(players, d.at)}님이 카드를 고르는 중이에요`}

각자 10장이 될 때까지 차례로 한 장씩 가져가요. 남은 4장이 줄의 첫 카드가 돼요.{me && v.seats.includes(me) ? ` 내 카드 ${myCount}/10장.` : ''}

{d.pool.map((n) => ( ))}
{v.my && v.my.hand.length > 0 && (
내 카드
{v.my.hand.map((h) => ( ))}
)}
); } // ---------------------------------------------------------------- round result / final function RoundResult({ v, me, players, onClose }: { v: SixNimmtView; me: string | null; players: Record; onClose: () => void }) { const lr = v.lastRound!; const end = v.options.endMode === 'score' ? v.options.endScore : null; const max = Math.max(end ?? 0, ...v.seats.map((p) => v.players[p]!.total), 1); return (
{lr.round}라운드 결과
    {v.seats.map((p) => { const total = v.phase === 'finished' ? v.players[p]!.total : v.players[p]!.total; return (
  • {who(players, me, p)} {end && } +{lr.gained[p] ?? 0} → {total}
  • ); })}
{end &&

누군가 {end}점 이상이 되면 그 라운드 끝에 게임이 끝나요.

}
); } function FinalTable({ v, me, players }: { v: SixNimmtView; me: string | null; players: Record }) { const r = v.result!; const rounds = Math.max(...v.seats.map((p) => v.roundScores[p]!.length)); return (

최종 결과

{r.summary}

{Array.from({ length: rounds }, (_, i) => ( ))} {r.ranking.map((row) => ( {Array.from({ length: rounds }, (_, i) => ( ))} ))}
순위 이름{i + 1}R벌점
{row.left ? '-' : `${row.rank}등`} {who(players, me, row.player)}{v.roundScores[row.player]![i] ?? ''} {row.total}
{v.bestTake && v.bestTake.bulls > 0 && (

가장 크게 가져간 한 번: {who(players, me, v.bestTake.player)} · {v.bestTake.round}라운드에 한 번에 소머리 {v.bestTake.bulls}개!

)}
); } // ---------------------------------------------------------------- board function Board({ view: v, me, players, act, pending, active, deadline }: BoardProps) { const pb = usePlayback(v); const [roundShown, setRoundShown] = useState(v.lastRound?.round ?? 0); const [roundOpen, setRoundOpen] = useState(false); const prevTurn = useRef(v.turnSeq); const prevPicked = useRef(0); const [announce, setAnnounce] = useState(''); // Round result window: once the replay of the last turn is done, for 5 seconds (closable). useEffect(() => { if (!v.lastRound || v.lastRound.round === roundShown || pb.busy) return; setRoundShown(v.lastRound.round); setRoundOpen(true); const t = setTimeout(() => setRoundOpen(false), 5000); return () => clearTimeout(t); }, [v.lastRound?.round, pb.busy]); // eslint-disable-line react-hooks/exhaustive-deps // Someone picked a card: a soft tap. const pickedN = v.seats.filter((p) => v.players[p]!.picked).length; useEffect(() => { if (pickedN > prevPicked.current) sfx.chip(); prevPicked.current = pickedN; }, [pickedN]); useEffect(() => { if (v.turnSeq === prevTurn.current) return; prevTurn.current = v.turnSeq; if (isMyTurn(v, me)) { haptic(40); if (document.visibilityState === 'hidden') sounds.myTurn(); else tone(880, 70, 'triangle', 0.06); } }, [v.turnSeq]); // eslint-disable-line react-hooks/exhaustive-deps // Screen readers: the latest takes. const lastLog = v.log.at(-1)?.n ?? 0; const prevLog = useRef(lastLog); useEffect(() => { if (lastLog <= prevLog.current) return; const added = v.log.filter((e) => e.n > prevLog.current); prevLog.current = lastLog; const text = added.map((e) => logText(e, me, players)).filter(Boolean).slice(-3).join(' '); if (text) setAnnounce(text); }, [lastLog]); // eslint-disable-line react-hooks/exhaustive-deps const seated = !!me && v.seats.includes(me) && !v.players[me]!.left; const pd = v.pending; return (
{v.phase === 'finished' ? '게임 끝' : v.phase === 'draft' ? `${v.round}라운드 · 카드 골라 가기` : `${v.round}라운드 · ${v.turn}/10번째 카드`} {v.options.endMode === 'score' ? `${v.options.endScore}점이 넘으면 끝` : `${v.options.rounds}라운드까지`} {v.options.fanCard !== 'none' ? ` · ${FAN_KO[v.options.fanCard]}` : ''} {v.options.placement === 'both' ? ' · 양쪽 끝' : ''}
{v.result && } {v.phase === 'draft' && v.draft ? ( ) : ( <> {!pb.busy && v.phase === 'choose' && pd && (
{pd.player === me ? pd.kind === 'takeRow' ? `너무 작은 카드예요(${pd.play.value})! 가져갈 줄을 고르세요` : `${pd.play.value}을(를) 놓을 자리가 두 곳이에요. 반짝이는 자리를 골라 주세요` : `${nick(players, pd.player)}님이 ${pd.kind === 'takeRow' ? '가져갈 줄을' : '놓을 자리를'} 고르는 중…`}
)} setRoundOpen(false)} /> : null} /> {seated && v.my && v.phase !== 'finished' && } )}

{announce}

); } const FAN_KO: Record = { none: '특별 카드 없음', evenOdd: '짝홀', mountain: '산 오르기', jumpingCow: '점프하는 소', flipDigits: '숫자 뒤집기' }; function logText(e: LogEntry, me: string | null, players: Record): string { switch (e.t) { case 'take': return `${who(players, me, e.player)} ${ROW_NAMES[e.row]} ${e.cards.length}장 가져감 +🐮${e.bulls}${e.why === 'low' ? '(너무 작은 카드)' : e.why === 'cow' ? '(점프하는 소)' : ''}`; case 'round': return `${e.round}라운드 끝`; case 'flip': return `${who(players, me, e.player)} 숫자 뒤집기: ${e.card} → ${e.value}`; case 'timeout': return `${who(players, me, e.player)} 시간 초과(자동)`; case 'left': return `${who(players, me, e.player)} 나감`; } } // ---------------------------------------------------------------- side panel function Tracker({ v, me, players }: { v: SixNimmtView; me: string | null; players: Record }) { if (!v.seen) return null; const seen = new Set(v.seen); const mine = new Set(v.my?.hand.map((h) => h.n) ?? []); return (
나온 카드 표 ({v.seen.length}/{v.deckMax})
{Array.from({ length: v.deckMax }, (_, i) => i + 1).map((n) => ( {n} ))}
{v.options.deck === 'all' &&

104장 중 이번 라운드에 안 쓰는 카드가 섞여 있어요.

} {v.known && (
{v.seats .filter((p) => p !== me) .map((p) => (
{nick(players, p)}의 남은 카드: {v.known![p]!.join(', ') || '없음'}
))}
)}
); } function Side({ view: v, me, players, act }: BoardProps) { const [ask, setAsk] = useState(false); const rounds = Math.max(0, ...v.seats.map((p) => v.roundScores[p]!.length)); const playing = v.phase !== 'finished'; return ( <>

점수표(벌점)

{Array.from({ length: rounds }, (_, i) => ( ))} {playing && } {v.seats.map((p) => ( {Array.from({ length: rounds }, (_, i) => ( ))} {playing && } ))}
이름{i + 1}R지금합
{who(players, me, p)}{v.roundScores[p]![i] ?? ''}{v.players[p]!.roundBulls ? `+${v.players[p]!.roundBulls}` : ''} {v.players[p]!.total}
{v.log.length > 0 && (

기록

    {[...v.log] .reverse() .slice(0, 30) .map((e) => (
  • {logText(e, me, players)}
  • ))}
)} {playing && me && v.seats.includes(me) && !v.players[me]!.left && ( )} {ask && ( act({ type: 'LEAVE' })} onClose={() => setAsk(false)} /> )} ); } // ---------------------------------------------------------------- status function isMyTurn(v: SixNimmtView, me: string | null): boolean { if (!me || v.phase === 'finished' || !v.players[me] || v.players[me]!.left) return false; if (v.phase === 'draft') return v.draft?.at === me; if (v.phase === 'select') return !v.players[me]!.picked; return v.pending?.player === me; } function pendingText(pd: Pending): string { return pd.kind === 'takeRow' ? '가져갈 줄을' : '카드를 놓을 자리를'; } function statusText(v: SixNimmtView, me: string | null, players: Record): string { if (v.phase === 'finished') return v.result?.summary ?? '게임이 끝났어요'; if (me && v.players[me]?.left) return '나갔어요. 구경하는 중이에요'; const seated = !!me && v.seats.includes(me); if (v.phase === 'draft') return isMyTurn(v, me) ? '내 차례예요. 펼쳐진 카드에서 한 장을 가져가세요' : `${nick(players, v.draft!.at)}님이 카드를 고르는 중이에요`; if (v.phase === 'select') { if (!seated) return '모두 낼 카드를 몰래 고르는 중이에요'; return isMyTurn(v, me) ? '내 차례예요. 낼 카드를 한 장 골라 주세요' : '다른 사람이 고르기를 기다려요'; } const pd = v.pending!; return pd.player === me ? `내 차례예요. ${pendingText(pd)} 골라 주세요` : `${nick(players, pd.player)}님이 ${pendingText(pd)} 고르는 중이에요`; } // ---------------------------------------------------------------- options function Seg({ value, options, onChange, label, disabled }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string; disabled?: boolean }) { return (
{options.map(([k, l]) => ( ))}
); } function Field({ label, children, help }: { label: string; children: ReactNode; help?: string }) { return (
{label} {children} {help && {help}}
); } function Options({ value: o, onChange }: OptionsProps) { const set = (patch: Partial) => onChange({ ...o, ...patch }); return (
set({ deck })} /> set({ placement, ...(placement === 'both' ? { fanCard: 'none' as const } : {}) })} /> set({ lowCard })} /> set({ fanCard })} /> set({ endMode })} /> {o.endMode === 'score' ? ( [n, `${n}점`] as [typeof n, string])} onChange={(endScore) => set({ endScore })} /> ) : ( [n, `${n}라운드`] as [typeof n, string])} onChange={(rounds) => set({ rounds })} /> )} set({ cardTracker })} /> set({ turnSeconds })} />
); } const FAN_HELP: Record, string> = { evenOdd: '짝홀 카드가 있는 줄에는 그 면(짝/홀)과 같은 카드만 놓여요. 누가 줄을 가져가면 옮겨 가요.', mountain: '산 오르기 줄은 끝 카드보다 작은 수를 붙여요(내림차순). 누가 줄을 가져가면 한 줄씩 움직여요.', jumpingCow: '소가 있는 줄에 카드가 놓이면 소는 끝 카드가 가장 작은 다른 줄로 뛰어가요. 소도 한 칸을 차지해요.', flipDigits: '라운드에 한 번, 카드 숫자를 뒤집어 낼 수 있어요(31 → 13). 놓인 뒤에는 원래 숫자예요.', }; function optionsSummary(o: SixNimmtOptions): string { return [ o.deck === 'all' ? '104장' : o.deck === 'tactics' ? '인원×10+4장' : '펼쳐 골라 가기', o.placement === 'both' ? '양쪽 끝' : null, o.lowCard === 'fewest' ? '작은 카드 자동' : null, o.fanCard !== 'none' ? FAN_KO[o.fanCard] : null, o.endMode === 'score' ? `${o.endScore}점에 끝` : `${o.rounds}라운드`, o.cardTracker ? null : '카드 표 없음', o.turnSeconds === null ? '시간 제한 없음' : `${o.turnSeconds}초`, ] .filter(Boolean) .join(' · '); } // ---------------------------------------------------------------- rules function Rules({ options }: { options?: SixNimmtOptions }) { const o: SixNimmtOptions = { deck: 'all', placement: 'right', lowCard: 'choose', fanCard: 'none', endMode: 'score', endScore: 66, rounds: 3, cardTracker: true, turnSeconds: 30, ...(options ?? {}) }; return (

1부터 104까지 숫자 카드로 해요. 카드마다 소머리가 그려져 있고 이것이 벌점이에요(보통 1개, 5로 끝나면 2개, 10의 배수 3개, 11의 배수 5개, 55는 7개). 벌점이 적은 사람이 이겨요.

각자 10장을 받고, 판에는 줄 4개가 한 장씩으로 시작해요. 매번 모두 손패에서 한 장을 몰래 동시에 고르고, 모두 고르면 한꺼번에 공개해요.

공개된 카드는 작은 수부터 한 장씩 줄에 붙어요. 내 카드보다 끝 카드가 작은 줄 중 차이가 가장 작은 줄 끝에 붙어요. 예를 들어 끝 카드가 41, 42일 때 45는 42 다음이에요.

내 카드가 그 줄의 여섯 번째 카드가 되면 앞의 다섯 장을 가져가고(소머리만큼 벌점), 내 카드가 그 줄의 새 첫 카드가 돼요.

내 카드가 모든 줄의 끝 카드보다 작으면 {o.lowCard === 'choose' ? '원하는 줄 하나를 골라 통째로 가져가고' : '소머리가 가장 적은 줄을 자동으로 가져가고'}, 내 카드가 그 줄의 새 첫 카드가 돼요.

10장을 다 내면 라운드가 끝나고 가져간 소머리를 더해요.{' '} {o.endMode === 'score' ? `누군가 ${o.endScore}점 이상이 되면 그 라운드 끝에 게임이 끝나요(20라운드가 지나도 끝).` : `${o.rounds}라운드를 하고 끝나요.`} 벌점이 같으면 함께 이겨요.

{o.deck !== 'all' && (

{o.deck === 'pro' ? '프로 변형' : '전술 변형'}: 인원×10+4장(1부터)만 써요. {o.deck === 'pro' ? ' 모든 카드를 펼쳐 놓고 시작하는 사람부터 차례로 한 장씩 가져가 10장을 만들어요. 남은 4장이 작은 수부터 줄의 첫 카드예요.' : ' 섞어서 나눠요.'}

)} {o.placement === 'both' && (

양쪽 끝: 줄 왼쪽에는 첫 카드보다 작은 카드를 붙일 수 있어요. 오른쪽·왼쪽 중 차이가 가장 작은 자리에 놓이고, 차이가 같은 자리가 둘이면 직접 골라요.

)} {o.fanCard !== 'none' && (

{FAN_KO[o.fanCard]}: {FAN_HELP[o.fanCard]} {o.fanCard === 'jumpingCow' && ' 소가 뛰어간 줄이 여섯 칸이 되면 소를 뛰게 한 사람이 가장 큰 카드만 남기고 그 줄도 가져가요.'} {o.fanCard === 'flipDigits' && ' 한 자리 수는 0을 붙여 뒤집어요(7 → 70). 100 이상은 뒤집을 수 없어요.'}

)}

{o.cardTracker ? '오른쪽 [나온 카드 표]에서 이번 라운드에 나온 카드를 볼 수 있어요. ' : '나온 카드 표는 꺼져 있어요(원작처럼 기억으로). '} {o.turnSeconds === null ? '이 방은 시간 제한이 없어요.' : `${o.turnSeconds}초 안에 고르지 않으면 지금 줄 기준으로 가장 안전한 카드가 자동으로 나가요.`}

원작: 볼프강 크라머 「6 nimmt!」(AMIGO). 30주년판 특별 카드 아이디어: Guillaume Lefebvre, Daniela Bustos, Frank Heeren, Martin Profanter. 카드 그림과 규칙 문장은 이 사이트에서 새로 만들었어요.

); } // ---------------------------------------------------------------- styles const CSS = ` .sx-wrap { width: 100%; display: flex; flex-direction: column; gap: 10px; /* Card width: the 4 rows + the hand share the play height left after the bars, hints and buttons. */ --sx-c: clamp(64px, (var(--play-h) - 400px) / 7, 140px); } @media (min-width: 1100px) { .sx-wrap { flex: 1 1 auto; min-height: 0; } .sx-wrap > * { flex: none; } .sx-wrap > .sx-rows { flex: 1 0 auto; justify-content: center; } } .game-main:has(> .sx-wrap) { justify-content: flex-start; } .sx-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 8px 14px; } .sx-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: thin; } @media (min-width: 720px) { .sx-strip { flex-wrap: wrap; overflow: visible; } } .sx-player { position: relative; flex: 0 0 auto; min-width: 96px; max-width: 150px; background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: 4px 8px; } .sx-player.on { border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 35%, transparent); } .sx-player.me { background: var(--primary-soft); } .sx-player.gone { opacity: .55; } .sx-pl-top { display: flex; align-items: center; gap: 4px; min-width: 0; } .sx-pl-name { font-weight: 700; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; } .sx-back { display: inline-flex; width: 18px; height: 24px; border-radius: 4px; background: #2f4f86; color: #fff; font-size: .7rem; align-items: center; justify-content: center; border: 1px solid #1d3461; } .sx-pl-score { display: flex; align-items: baseline; gap: 3px; font-size: .85rem; } .sx-pl-score b { font-size: 1.05rem; font-variant-numeric: tabular-nums; } .sx-plus { color: var(--danger); font-weight: 700; } .sx-pl-state { font-size: .75rem; color: var(--text-sub); white-space: nowrap; } .sx-pl-timer { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); } .sx-player.timed { padding-right: 40px; } .sx-rows { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--felt); border-radius: 16px; padding: 8px; } .sx-row { width: 100%; max-width: calc(var(--sx-c) * 6 + 96px); display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 4px; align-items: center; border-radius: 10px; padding: 2px; transition: background .2s; } .sx-row.glow { background: rgba(255, 255, 255, .16); } .sx-row.take { animation: sx-shake .45s ease both; background: rgba(239, 68, 68, .35); } @keyframes sx-shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } } .sx-rowhead { display: flex; flex-direction: column; align-items: center; gap: 1px; color: #fff; font-size: .72rem; line-height: 1.1; } .sx-rowhead b { font-size: 1rem; } .sx-rowbulls { white-space: nowrap; } .sx-mark { border-radius: 6px; padding: 1px 3px; font-weight: 900; font-size: .72rem; background: #fff; color: #1c1e21; white-space: nowrap; } .sx-mark.mountain { background: #d9f99d; } .sx-slots { display: grid; grid-template-columns: repeat(6, minmax(0, var(--sx-c))); gap: 4px; } .sx-takebtn { grid-column: 2; justify-self: start; min-height: 40px; } @media (min-width: 720px) { .sx-row:has(.sx-takebtn) { max-width: calc(var(--sx-c) * 6 + 296px); grid-template-columns: 30px minmax(0, 1fr) auto; } .sx-row .sx-takebtn { grid-column: 3; } } .sx-card { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; border: 2px solid #3b3f46; color: #1c1e21; background: #fff; font-weight: 900; user-select: none; box-sizing: border-box; } .sx-card.row { width: 100%; aspect-ratio: 5 / 7; } .sx-card.hand { width: 100%; aspect-ratio: 5 / 7; } .sx-card.mini { width: 40px; height: 54px; } .sx-card.b2 { background: #cfe6ff; } .sx-card.b3 { background: #fff0a3; } .sx-card.b5 { background: #ffc98f; } .sx-card.b7 { background: #ff9d9d; border-color: #9b1c1c; } .sx-card.cow { background: #f1f5f9; border-style: dashed; } .sx-card.new { animation: sx-in .35s ease-out both; box-shadow: 0 0 0 3px var(--focus); } @keyframes sx-in { from { transform: translateY(-14px) scale(1.15); opacity: .3; } } .sx-bulls { position: absolute; top: 2px; left: 0; right: 0; text-align: center; font-size: clamp(.62rem, calc(var(--sx-c) * .15), .95rem); font-weight: 700; line-height: 1; } .sx-n { font-size: clamp(.95rem, min(4.2vw, calc(var(--sx-c) * .37)), 2.6rem); line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; } .sx-card.mini .sx-n { font-size: 1.05rem; } .sx-card.mini .sx-bulls { font-size: .55rem; } .sx-orig { position: absolute; bottom: 2px; font-size: .55rem; font-weight: 700; color: #334155; } .sx-empty { aspect-ratio: 5 / 7; border-radius: 8px; border: 2px dashed rgba(255, 255, 255, .28); display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .5); font-weight: 900; } .sx-empty.sixth { border-color: rgba(248, 113, 113, .7); background: rgba(248, 113, 113, .16); color: #fecaca; } .sx-spot { aspect-ratio: 5 / 7; border-radius: 8px; border: 3px solid var(--focus); background: rgba(245, 158, 11, .25); color: #fff; font-weight: 900; font-size: .75rem; cursor: pointer; animation: sx-pulse 1s ease-in-out infinite; padding: 0; } @keyframes sx-pulse { 50% { background: rgba(245, 158, 11, .55); } } .sx-banner { border-radius: 12px; padding: 8px 12px; font-weight: 800; text-align: center; background: var(--warning-soft); color: var(--text); } .sx-banner.mine { background: var(--danger-soft); border: 2px solid var(--danger); } .sx-banner.take { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--danger); color: #fff; font-size: 1.05rem; box-shadow: var(--shadow); white-space: nowrap; animation: sx-pop .3s ease-out both; pointer-events: none; z-index: 2; } @keyframes sx-pop { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } } .sx-reveal { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 12px; padding: 6px 10px; border: 1px solid var(--border); overflow-x: auto; } .sx-reveal-label { white-space: nowrap; } .sx-reveal-cards { display: flex; gap: 6px; flex-wrap: nowrap; } .sx-rv { display: flex; flex-direction: column; align-items: center; gap: 1px; animation: sx-flip .4s ease-out both; } .sx-rv.pend .sx-card { box-shadow: 0 0 0 3px var(--danger); } @keyframes sx-flip { from { transform: rotateY(90deg); } } .sx-rv-name { font-size: .7rem; max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .sx-hand-wrap { display: flex; flex-direction: column; gap: 6px; } .sx-hint { margin: 0; } .sx-hand { display: grid; grid-template-columns: repeat(10, minmax(0, calc(var(--sx-c) + 8px))); gap: 6px; justify-content: center; padding-top: 12px; } @media (max-width: 720px) { .sx-hand { grid-template-columns: repeat(5, minmax(0, 64px)); } } .sx-hcard { all: unset; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: 10px; transition: transform .15s; min-width: 0; } .sx-hcard:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; } .sx-hcard:disabled { cursor: default; } .sx-hcard.up { transform: translateY(-10px); } .sx-hcard.up .sx-card { box-shadow: 0 0 0 3px var(--primary); } .sx-hcard.sent .sx-card { outline: 3px dashed var(--success); outline-offset: 1px; } .sx-pv { font-size: .68rem; line-height: 1.15; text-align: center; color: var(--text-sub); min-height: 2.3em; word-break: keep-all; } .sx-pv.warn { color: var(--danger); font-weight: 800; } .sx-hand-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; } .sx-send { min-width: 220px; flex: 1 1 220px; max-width: 420px; } .sx-flip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); } .sx-draft { display: flex; flex-direction: column; gap: 8px; padding: 12px; } .sx-draft h3 { margin: 0; font-size: 1.05rem; } .sx-pool { display: flex; flex-wrap: wrap; gap: 5px; } .sx-poolbtn { all: unset; cursor: pointer; border-radius: 8px; } .sx-poolbtn:focus-visible { outline: 3px solid var(--focus); } .sx-poolbtn:disabled { cursor: default; opacity: .85; } .sx-poolbtn:not(:disabled):hover .sx-card { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--primary); } .sx-mine { display: flex; flex-direction: column; gap: 4px; overflow-x: auto; } .sx-overlay { position: absolute; inset: 8px; display: flex; align-items: flex-start; justify-content: center; z-index: 3; pointer-events: none; } .sx-overlay > * { pointer-events: auto; width: min(100%, 520px); box-shadow: var(--shadow); } .sx-round { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; border: 2px solid var(--primary); } .sx-round-head { display: flex; justify-content: space-between; align-items: center; } .sx-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; } .sx-bars li { display: grid; grid-template-columns: minmax(0, 90px) 1fr auto; gap: 8px; align-items: center; font-size: .85rem; } .sx-bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .sx-bar { position: relative; height: 12px; border-radius: 6px; background: var(--border); } .sx-bar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--warning); } .sx-bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--danger); } .sx-bar-num { white-space: nowrap; font-variant-numeric: tabular-nums; } .sx-final { padding: 12px; display: flex; flex-direction: column; gap: 8px; } .sx-final h3, .sx-scores h3, .sx-logbox h3 { margin: 0; font-size: 1rem; } .sx-table-wrap { overflow-x: auto; } .sx-table { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; } .sx-table th, .sx-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; } .sx-table tr.win td { background: var(--success-soft); } .sx-td-name { text-align: left !important; max-width: 110px; overflow: hidden; text-overflow: ellipsis; } .sx-scores, .sx-logbox { padding: 12px; display: flex; flex-direction: column; gap: 6px; } .sx-log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; font-size: .85rem; } .sx-log li.take { color: var(--danger); } .sx-log li.round { font-weight: 800; } .sx-tracker { padding: 10px 12px; } .sx-tracker summary { cursor: pointer; font-weight: 700; } .sx-grid { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 2px; margin: 8px 0; } .sx-cell { font-size: .68rem; text-align: center; border-radius: 4px; padding: 2px 0; color: #1c1e21; background: #fff; border: 1px solid #c8c8c8; font-variant-numeric: tabular-nums; } .sx-cell.b2 { background: #cfe6ff; } .sx-cell.b3 { background: #fff0a3; } .sx-cell.b5 { background: #ffc98f; } .sx-cell.b7 { background: #ff9d9d; } .sx-cell.seen { opacity: .25; text-decoration: line-through; } .sx-cell.mine { outline: 2px solid var(--primary); font-weight: 900; } @media (max-width: 400px) { .sx-rows { padding: 5px; gap: 4px; } .sx-row { grid-template-columns: 24px minmax(0, 1fr); gap: 2px; } .sx-slots { gap: 3px; } .sx-rowhead { font-size: .62rem; } .sx-card { border-width: 1.5px; border-radius: 6px; } } `; const ui: GameUI = { Board, Side, statusText, isMyTurn, Options, optionsSummary, Rules, quickStart, helpNow, }; export default ui;