뱅!·고스톱·스플렌더·바퀴벌레 포커·구십구 소리·애니메이션, 게임 문서에 소리·움직임, E2E에서 무제한 확인

- 모두 view 변화(기록·이전 view 비교)에 반응해서 컴퓨터·다른 사람 행동에도 소리와 움직임이 나옴, 처음 렌더·다시 보기는 건너뜀
- 뱅!: 총소리·개틀링·인디언·결투·판정 카드·다이너마이트·감옥·맥주·쓰러짐 배너
- 고스톱: 패 내기 "탁", 뒤집기, 먹기, 피 뺏기, 뻑·따닥·쪽·싹쓸이·폭탄·흔들기 배너, N고, 판 끝(마지막 판 승패 소리는 결과 창 하나만)
- 스플렌더: 보석·카드·귀족이 날아가고 보석 소리, 마지막 라운드 배너
- 바퀴벌레 포커: 건네기·판정 배너·앞마당으로 날아감·위험 경고음
- 구십구: 카드가 합계 다이얼로, 90 이상 두근, 바로 99 배너, 방향 바뀜, 목숨·탈락
- E2E: 구십구·바퀴벌레 포커를 무제한으로 진행하고 타이머가 안 보이는지 확인

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 13:31:14 +09:00
parent ac37a6a6d8
commit 4fa4c69725
14 changed files with 1268 additions and 125 deletions

View File

@@ -1,12 +1,13 @@
/** 고스톱 / 맞고 화면 (docs/games/gostop.md §9). Points are room-only play points. */
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
import type { BakKind, CardView, GostopOptions, GostopView, HandCardView, OutcomeView, SeatView, TurnTag } from '@bg/games/gostop';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, Sheet } from '../../components/ui';
import { TurnTimer } from '../../components/TurnTimer';
import { HwatuCard, type HwatuInfo } from '../../components/cards/HwatuCard';
import { ChipIcon } from '../../components/cards/Chips';
import { haptic, sounds } from '../../lib/feedback';
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import { bump, cssEsc, flyFrom, flyGhost, fxEl, reducedMotion, seatEl, useBanner, type BannerTone } from '../card-fx';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
@@ -152,10 +153,6 @@ const CSS = `
background: #dc2626; color: #fff; pointer-events: none; }
.gs-hcard .tag.shake { background: #7c3aed; }
.gs-hint { margin: 0; text-align: center; font-size: .9rem; color: var(--text-sub); }
.gs-flash { position: fixed; left: 50%; top: 36%; transform: translate(-50%, -50%); z-index: 30; pointer-events: none; text-align: center;
font-size: 3rem; font-weight: 900; color: #fde047; text-shadow: 0 3px 10px rgba(0,0,0,.7); animation: gs-pop .35s ease-out; white-space: nowrap; }
.gs-flash small { display: block; font-size: 1.1rem; color: #fff; }
@keyframes gs-pop { from { transform: translate(-50%, -50%) scale(.5); opacity: 0 } to { transform: translate(-50%, -50%) scale(1); opacity: 1 } }
.gs-big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gs-big .btn { min-height: 76px; font-size: 1.3rem; flex-direction: column; gap: 2px; line-height: 1.2; }
.gs-big .btn small { font-size: .85rem; font-weight: 600; opacity: .95; }
@@ -177,7 +174,6 @@ const CSS = `
.gs-me { padding: 6px 4px; }
.gs-hand { gap: 4px; }
.gs-hcard { border-width: 2px; }
.gs-flash { font-size: 2.4rem; }
}
`;
@@ -197,9 +193,14 @@ function Card({ c, size = 'sm', className, style }: { c: CardView | null; size?:
function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
const [open, setOpen] = useState(false);
const groups = (['gwang', 'yeol', 'tti', 'pi'] as const).filter((k) => seat.captured[k].length > 0);
if (groups.length === 0) return <span className="small muted">먹은 패 없음</span>;
if (groups.length === 0)
return (
<span className="small muted" data-fx-cap={seat.id}>
먹은 패 없음
</span>
);
return (
<button type="button" className="gs-cap" aria-expanded={open} onClick={() => setOpen(!open)} aria-label={`${label} 먹은 패: ${groups.map((k) => `${KIND_LABEL[k]} ${seat.captured[k].length}장`).join(', ')}. 눌러서 ${open ? '접기' : '펼치기'}`}>
<button type="button" className="gs-cap" data-fx-cap={seat.id} aria-expanded={open} onClick={() => setOpen(!open)} aria-label={`${label} 먹은 패: ${groups.map((k) => `${KIND_LABEL[k]} ${seat.captured[k].length}장`).join(', ')}. 눌러서 ${open ? '접기' : '펼치기'}`}>
{groups.map((k) => (
<span key={k} className="gs-pile">
<b>
@@ -207,7 +208,9 @@ function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
</b>
<span className="gs-pile-cards">
{seat.captured[k].map((c) => (
<HwatuCard key={c.key} card={c as HwatuInfo} size="sm" />
<span key={c.key} data-gs-cap={c.key} style={{ display: 'inline-flex' }}>
<HwatuCard card={c as HwatuInfo} size="sm" />
</span>
))}
</span>
</span>
@@ -260,7 +263,7 @@ function SeatBox({ seat, v, players, me, deadline }: { seat: SeatView; v: Gostop
const u = userOf(players, seat.id);
const active = actorOf(v) === seat.id;
return (
<li className={`gs-seat${active ? ' turn' : ''}${!seat.participant && v.step !== 'sell' ? ' out' : ''}`} aria-label={`${u.nickname}, 방 점수 ${signed(seat.total)}${seat.isDealer ? ', 선' : ''}${seat.participant ? `, 지금 ${seat.score.total}점, 손패 ${seat.handCount}장` : ''}`}>
<li className={`gs-seat${active ? ' turn anim-glow' : ''}${!seat.participant && v.step !== 'sell' ? ' out' : ''}`} data-fx-seat={seat.id} aria-label={`${u.nickname}, 방 점수 ${signed(seat.total)}${seat.isDealer ? ', 선' : ''}${seat.participant ? `, 지금 ${seat.score.total}점, 손패 ${seat.handCount}장` : ''}`}>
<div className="gs-head">
<Avatar user={u} size={26} />
<span className="nm">
@@ -308,7 +311,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
const pf = v.pendingFlip;
return (
<div className="gs-table" role="region" aria-label="바닥">
<ul className="gs-floor" aria-label="바닥 패(월별)">
<ul className="gs-floor" data-fx="gs-floor" aria-label="바닥 패(월별)">
{months.map((m) => {
const g = v.floor.find((x) => x.month === m);
const cls = `gs-slot${g ? ' has' : ''}${g && g.cards.length === 3 ? (g.natural ? ' ppeok natural' : ' ppeok') : ''}`;
@@ -316,14 +319,16 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
? `${m}월 ${g.cards.length}장${g.cards.length === 3 ? (g.natural ? ', 처음 깔린 3장' : `, ${nick(players, g.ppeokBy)}님이 싼 뻑`) : ''}: ${g.cards.map((c) => c.name).join(', ')}`
: `${m}월 없음`;
return (
<li key={m} className={cls} aria-label={label}>
<li key={m} className={cls} data-gs-month={m} aria-label={label}>
<span className="m" aria-hidden>
{m}월
</span>
{g && (
<span className="gs-slot-cards">
{g.cards.map((c) => (
<Card key={c.key} c={c} size={narrow ? 'sm' : 'md'} className={glow.has(c.id) ? 'gs-glow' : undefined} />
<span key={c.key} className={glow.has(c.id) ? 'gs-glow' : undefined} data-gs-floor={c.key} style={{ display: 'inline-flex' }}>
<HwatuCard card={c as HwatuInfo} size={narrow ? 'sm' : 'md'} />
</span>
))}
</span>
)}
@@ -333,7 +338,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
</ul>
<div className="gs-side">
<div className="gs-deck">
<div aria-label={`더미 ${v.deckCount}장`} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }}>
<div data-fx="gs-deck" aria-label={`더미 ${v.deckCount}장`} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }}>
<HwatuCard card={null} size={narrow ? 'sm' : 'md'} />
<strong>{v.deckCount}장</strong>
</div>
@@ -351,7 +356,9 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
{pf && (
<div aria-label={`뒤집은 패 ${pf.flipped.name}`} style={{ textAlign: 'center' }}>
<div className="small">뒤집은 패</div>
<Card c={pf.flipped} size="sm" className="gs-glow" />
<span className="gs-glow" data-fx="gs-pflip" style={{ display: 'inline-flex' }}>
<HwatuCard card={pf.flipped as HwatuInfo} size="sm" />
</span>
</div>
)}
</div>
@@ -423,8 +430,8 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
setAsk(null);
}, [v.turn, v.step, v.roundNo, v.lastTurn?.seq]);
const hand = v.myHand ?? [];
const send = (a: object) => {
sounds.stone();
const send = (a: { card: number | 'dummy'; target?: number; shake?: boolean; bomb?: boolean }) => {
rememberPlay(a.card);
act({ type: 'play', ...a });
setLifted(null);
setAsk(null);
@@ -446,7 +453,7 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
const floorCards = (ids: number[]) => v.floor.flatMap((g) => g.cards).filter((c) => ids.includes(c.id));
return (
<>
<div className="gs-hand" role="group" aria-label="내 손패">
<div className="gs-hand" data-fx="gs-hand" role="group" aria-label="내 손패">
{hand.map((h) => {
const match = hints && h.matches.length > 0;
const tag = h.canBomb ? '폭탄' : h.canShake ? '흔들기' : null;
@@ -456,6 +463,7 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
key={h.card.key}
type="button"
className="gs-hcard"
data-gs-hand={h.card.key}
data-match={match || undefined}
data-lifted={lifted === h.card.id || undefined}
disabled={!canPlay}
@@ -540,7 +548,7 @@ function MyArea(props: BoardProps<GostopView> & { onFocusCard: (h: HandCardView
const active = actorOf(v) === me;
if (v.phase !== 'playing') return null;
return (
<div className={`gs-me${active ? ' turn' : ''}`} aria-label="내 자리">
<div className={`gs-me${active ? ' turn anim-glow' : ''}`} data-fx-seat={me} aria-label="내 자리">
<div className="gs-head">
<Avatar user={userOf(players, me)} size={26} />
<span className="nm">나 · 합계 {signed(seat.total)}</span>
@@ -703,7 +711,7 @@ function RoundResult({ view: v, me, players, act, pending }: BoardProps<GostopVi
const seat = v.seats.find((s) => s.id === me);
const nextMult = v.rules.nagariMultiplier === 'x2' ? Math.min(2 ** v.nagariStreak, v.rules.nagariMaxMultiplier) : 1;
return (
<section className="gs-panel gs-res" aria-label={`${v.roundNo}판 결과`} aria-live="polite">
<section className="gs-panel gs-res" data-fx="gs-result" aria-label={`${v.roundNo}판 결과`} aria-live="polite">
<h2 style={{ margin: 0 }}>
{v.roundNo}판 결과 · {outcomeTitle(o, players, me)}
</h2>
@@ -777,13 +785,336 @@ function RoundResult({ view: v, me, players, act, pending }: BoardProps<GostopVi
);
}
// ---------------------------------------------------------------- motion + sound
/** 고스톱 sounds on top of the shared palette (synthesized, no files). */
const gsSfx = {
/** "탁!" — a hwatu card slapped on the floor. */
slap: (gain = 1, delay = 0) => {
noise(70, 0.3 * gain, delay, 'lowpass', 900);
noise(22, 0.12 * gain, delay, 'highpass', 3200);
tone(120, 90, 'sine', 0.22 * gain, delay, { slideTo: 60 });
},
/** Cards taken into the pile ("착착"). */
gather: (n: number) => {
for (let i = 0; i < Math.min(n, 4); i++) noise(45, 0.12, i * 60, 'bandpass', 1700 + i * 200, 1);
},
/** 쪽 */
kiss: () => {
tone(1100, 70, 'sine', 0.14, 0, { slideTo: 2300 });
noise(25, 0.08, 55, 'highpass', 5000);
},
/** 뻑 — a dull, deflating thud. */
ppeok: () => {
noise(140, 0.22, 0, 'lowpass', 500);
tone(320, 280, 'sawtooth', 0.06, 0, { slideTo: 90 });
},
/** 따닥 — two quick slaps. */
ttadak: () => {
gsSfx.slap(0.9);
gsSfx.slap(1, 110);
tone(988, 90, 'triangle', 0.08, 200);
},
/** 싹쓸이 — a broom sweep, then the pile. */
sweep: () => {
noise(260, 0.12, 0, 'bandpass', 1200, 0.5);
sfx.collect();
},
/** 폭탄 */
boom: () => {
noise(450, 0.35, 0, 'lowpass', 280);
tone(85, 420, 'sine', 0.3, 0, { slideTo: 38 });
},
/** 흔들기 — cards rattled in the hand. */
rattle: () => {
for (let i = 0; i < 6; i++) noise(35, 0.12, i * 60, 'bandpass', 2300 + (i % 2) * 700, 3);
},
/** 고 — rising, one step higher per 고. */
go: (n: number) => {
const up = Math.min(n, 5) * 60;
[523, 659, 784].forEach((f, i) => tone(f + up, 110, 'square', 0.06, i * 70));
},
nagari: () => [440, 370, 311].forEach((f, i) => tone(f, 200, 'triangle', 0.12, i * 160)),
};
/** Where my last played card was (its button is gone once the view arrives), so the floor card flies from there. */
let myPlayRect: DOMRect | null = null;
function rememberPlay(card: number | 'dummy'): void {
myPlayRect = card === 'dummy' ? null : (document.querySelector(`.gs-hcard[data-gs-hand$="c${card}"]`)?.getBoundingClientRect() ?? null);
}
const later = (ms: number, f: () => void) => (ms > 0 ? setTimeout(f, ms) : f());
const byAttr = (attr: string, key: string | number): Element | null => document.querySelector(`[${attr}="${cssEsc(String(key))}"]`);
const slotEl = (month: number) => (month > 0 ? byAttr('data-gs-month', month) : null);
const capEl = (id: string) => byAttr('data-fx-cap', id) ?? seatEl(id);
const CAP_KINDS = ['gwang', 'yeol', 'tti', 'pi'] as const;
/** A card turned face up (Web Animations, composite add, so it can run together with a fly-in). */
function flipIn(el: Element | null | undefined, delay = 0): void {
if (!el || reducedMotion() || typeof (el as HTMLElement).animate !== 'function') return;
(el as HTMLElement).animate(
[{ transform: 'perspective(600px) rotateY(90deg)' }, { transform: 'perspective(600px) rotateY(-12deg)', offset: 0.6 }, { transform: 'perspective(600px) rotateY(0deg)' }],
{ duration: 380, delay, easing: 'ease', fill: 'backwards', composite: 'add' },
);
}
function capOwners(v: GostopView): Map<string, string> {
const m = new Map<string, string>();
for (const s of v.seats) for (const k of CAP_KINDS) for (const c of s.captured[k]) m.set(c.key, s.id);
return m;
}
const TAG_ORDER: TurnTag[] = ['samPpeok', 'yeonPpeok', 'firstPpeok', 'bomb', 'ttadak', 'jaPpeok', 'ppeokEat', 'ppeok', 'jjok', 'sseul', 'shake', 'bonus', 'bonusFlip'];
const TAG_TONE: Partial<Record<TurnTag, BannerTone>> = {
samPpeok: 'red', yeonPpeok: 'red', firstPpeok: 'red', ppeok: 'red', bomb: 'red',
ttadak: 'gold', jaPpeok: 'gold', ppeokEat: 'gold', jjok: 'gold', sseul: 'green', shake: 'blue', bonus: 'blue', bonusFlip: 'blue',
};
/** Sound (and a shake) for the most important tag of a turn. */
function tagFx(tag: TurnTag | undefined, actor: string | null): void {
switch (tag) {
case 'samPpeok':
gsSfx.ppeok();
later(250, sfx.fanfare);
break;
case 'yeonPpeok':
case 'firstPpeok':
gsSfx.ppeok();
later(280, sfx.good);
break;
case 'ppeok':
gsSfx.ppeok();
bump(fxEl('gs-floor'), 'shake');
break;
case 'bomb':
gsSfx.boom();
bump(fxEl('gs-floor'), 'shake');
break;
case 'ttadak':
gsSfx.ttadak();
break;
case 'jaPpeok':
case 'ppeokEat':
sfx.good();
break;
case 'jjok':
gsSfx.kiss();
break;
case 'sseul':
gsSfx.sweep();
break;
case 'shake':
gsSfx.rattle();
if (actor) bump(seatEl(actor), 'shake');
break;
case 'bonus':
case 'bonusFlip':
sfx.pop();
break;
default:
sfx.capture();
}
}
/**
* Sounds + motion for every change of the table — mine, the other players' and the bots' — by diffing the previous
* view: deal, card played (탁), deck card flipped, cards taken into a pile, 피 taken from another pile, 뻑·쪽·따닥·
* 싹쓸이·폭탄·흔들기 banners, 고, 광 팔기 and the round result. Nothing on the first render (join / reload / replay),
* except the first deal when mounted right at the start of the game.
*/
function useGostopFx(v: GostopView, me: string | null, players: Record<string, PublicUser>, showBanner: ReturnType<typeof useBanner>[1]) {
const prev = useRef<GostopView | null>(null);
const origin = (id: string | null): Element | DOMRect | null =>
!id ? null : id === me ? (myPlayRect ?? fxEl('gs-hand') ?? seatEl(id)) : seatEl(id);
const deal = () => {
const deck = fxEl('gs-deck');
sfx.shuffle();
later(300, () => sfx.deal(8, 55));
document.querySelectorAll('[data-gs-floor]').forEach((el, i) => flyFrom(el, deck, { delay: 300 + i * 45, rotate: 8 }));
const mine = document.querySelectorAll('[data-gs-hand]');
mine.forEach((el, i) => flyFrom(el, deck, { delay: 300 + i * 40, rotate: 10 }));
for (const s of v.seats) {
if (s.handCount === 0 || (s.id === me && mine.length > 0)) continue;
flyGhost(deck, seatEl(s.id), { kind: 'hwatu', count: 3, gap: 90, delay: 300 });
}
};
useLayoutEffect(() => {
const p = prev.current;
prev.current = v;
if (!p) {
// Mounted right at the start of the game (nothing played yet): show the deal once.
if (v.roundNo === 1 && v.phase === 'playing' && !v.lastTurn && !v.sell?.decisions.length) deal();
return;
}
if (p === v) return;
// A new round, or the same round dealt again (총통 다시 돌리기).
if (v.roundNo !== p.roundNo || (v.phase === 'playing' && p.phase === 'playing' && v.deckCount > p.deckCount)) {
myPlayRect = null;
if (v.phase === 'playing') deal();
return;
}
const deck = fxEl('gs-deck');
const lt = v.lastTurn;
const newTurn = !!lt && lt.seq !== (p.lastTurn?.seq ?? 0);
const pendingNew = !!v.pendingFlip && !p.pendingFlip;
// The flip that needed a choice: the played card and the flip were already shown with the choice.
const resumed = newTurn && !!p.pendingFlip;
const actor = newTurn ? lt!.player : (v.pendingFlip?.player ?? p.turn);
let bannerShown = false;
if (newTurn || pendingNew) {
const fresh = newTurn && !resumed;
const flippedKeys = new Set(fresh ? lt!.flipped.map((c) => c.key) : []);
const before = new Set(p.floor.flatMap((g) => g.cards.map((c) => c.key)));
const onFloor = new Set<string>();
let played = false;
let flipped = false;
for (const g of v.floor)
for (const c of g.cards) {
onFloor.add(c.key);
if (before.has(c.key)) continue;
const el = byAttr('data-gs-floor', c.key);
if (flippedKeys.has(c.key)) {
flyFrom(el, deck, { delay: 380, ms: 300, rotate: 0, scale: 0.8 });
flipIn(el, 380);
flipped = true;
} else {
flyFrom(el, origin(actor), { ms: 340, rotate: -14 });
played = true;
}
}
if (fresh) {
// Cards that were taken right away never stay on the floor: a copy flies to their month.
for (const c of lt!.played) {
played = true;
if (!onFloor.has(c.key) && c.month > 0) flyGhost(origin(actor), slotEl(c.month), { kind: 'hwatu', ms: 340 });
}
for (const c of lt!.flipped) {
flipped = true;
if (!onFloor.has(c.key) && c.month > 0) flyGhost(deck, slotEl(c.month), { kind: 'hwatu', delay: 380, ms: 300 });
}
// 보너스패: the player takes one more card from the deck.
if (lt!.tags.includes('bonus') && actor !== me) flyGhost(deck, seatEl(actor!), { kind: 'hwatu', delay: 300 });
}
if (pendingNew) {
const el = fxEl('gs-pflip');
flyFrom(el, deck, { delay: 380, ms: 300, rotate: 0, scale: 0.8 });
flipIn(el, 380);
flipped = true;
played = true;
}
const bomb = fresh && lt!.tags.includes('bomb');
if (played) later(260, () => gsSfx.slap(bomb ? 1.4 : 1));
if (flipped) {
later(380, sfx.cardFlip);
later(640, () => gsSfx.slap(0.6));
}
// Cards that reached a pile: from the floor (their month), the deck or hand (bonus cards), or another pile (피 뺏기).
const capAt = resumed ? 120 : 720;
const owners = capOwners(p);
const robbed = new Set<string>();
let got = 0;
for (const s of v.seats)
for (const k of CAP_KINDS)
for (const c of s.captured[k]) {
const was = owners.get(c.key);
if (was === s.id) continue;
const el = byAttr('data-gs-cap', c.key);
if (was) {
flyFrom(el, capEl(was), { delay: capAt + 250, ms: 420, scale: 0.8, rotate: 0 });
robbed.add(was);
} else {
flyFrom(el, slotEl(c.month) ?? (flippedKeys.has(c.key) ? deck : origin(actor)), { delay: capAt, ms: 400, scale: 0.9, rotate: 0 });
got++;
}
}
if (got) later(capAt + 40, () => gsSfx.gather(got));
if (robbed.size) {
later(capAt + 250, sfx.whoosh);
for (const id of robbed) later(capAt + 250, () => bump(seatEl(id), 'shake'));
}
if (newTurn) {
const f = flashText(v, players);
if (f) {
const top = TAG_ORDER.find((x) => lt!.tags.includes(x));
later(resumed ? 150 : 600, () => {
showBanner(f.big, (top && TAG_TONE[top]) ?? 'blue', f.small);
tagFx(top, actor);
});
bannerShown = true;
}
}
if (actor === me) myPlayRect = null;
}
// My new hand cards during a round (보너스패 draw).
if (v.myHand && p.myHand) {
const had = new Set(p.myHand.map((h) => h.card.key));
v.myHand.filter((h) => !had.has(h.card.key)).forEach((h, i) => flyFrom(byAttr('data-gs-hand', h.card.key), deck, { delay: 300 + i * 60, rotate: 10 }));
}
// 고
for (const s of v.seats) {
const b = p.seats.find((x) => x.id === s.id);
if (!b || s.goCount <= b.goCount) continue;
showBanner(`${s.goCount}고!`, 'red', s.id === me ? undefined : `${nick(players, s.id)}님`);
gsSfx.go(s.goCount);
bump(seatEl(s.id));
bannerShown = true;
}
// 광팔기: a player sits out (and shows the cards they sell).
for (const d of v.sell?.decisions.slice(p.sell?.decisions.length ?? 0) ?? []) {
if (!d.sell) {
sfx.select();
continue;
}
const n = v.seats.find((s) => s.id === d.player)?.seller?.shown.length ?? 0;
showBanner(n ? '광 팔기!' : '죽기', 'blue', `${nick(players, d.player)}님${n ? ` · 광 ${n}장` : ''}`);
if (n) sfx.chips(Math.min(n, 4));
else sfx.whoosh();
bump(seatEl(d.player));
bannerShown = true;
}
// Round result: 스톱 / 총통 / 삼뻑 / 나가리.
const o = v.outcome;
if (o && !p.outcome) {
const at = bannerShown ? 1000 : 0;
const who = o.winner === me ? '내가 이겼어요' : `${nick(players, o.winner)}님이 이겼어요`;
const nextMult = v.rules.nagariMultiplier === 'x2' ? Math.min(2 ** v.nagariStreak, v.rules.nagariMaxMultiplier) : 1;
const mySeat = v.seats.find((s) => s.id === me);
later(at, () => {
if (o.type === 'nagari') showBanner('나가리', 'dark', nextMult > 1 ? `다음 판 x${nextMult}` : undefined);
else showBanner(o.type === 'chongtong' ? '총통!' : o.type === 'samppeok' ? '삼뻑!' : '스톱!', o.type === 'samppeok' ? 'red' : 'gold', who);
// The last round: the result dialog already plays the win/lose sound.
if (o.type === 'nagari') gsSfx.nagari();
else if (v.phase === 'finished' && mySeat) return;
else if (o.winner === me) sounds.win();
else if (mySeat?.participant) sounds.lose();
else sfx.fanfare();
});
if (o.winner) {
const to = seatEl(o.winner) ?? fxEl('gs-result');
o.payments.forEach((pay, i) => {
if (pay.amount > 0) flyGhost(seatEl(pay.from) ?? fxEl('gs-result'), to, { kind: 'chip', count: 3, gap: 70, delay: at + 250 + i * 120 });
});
if (o.payments.some((pay) => pay.amount > 0)) later(at + 500, () => sfx.chips(4));
}
}
}, [v]); // eslint-disable-line react-hooks/exhaustive-deps
}
// ---------------------------------------------------------------- board
function GostopBoard(props: BoardProps<GostopView>) {
const { view: v, me, players } = props;
const narrow = useNarrow();
const [focus, setFocus] = useState<HandCardView | null>(null);
const [flash, setFlash] = useState<{ big: string; small: string } | null>(null);
const [announce, setAnnounce] = useState('');
const mine = isMyTurn(v, me);
const prevMine = useRef(false);
@@ -796,10 +1127,6 @@ function GostopBoard(props: BoardProps<GostopView>) {
`${nick(players, t.player)}님: ${t.played.map((c) => c.name).join(', ')}${t.played.length ? ' 냄, ' : ''}${t.flipped.map((c) => c.name).join(', ')} 뒤집음, ${t.captured.length}장 먹음${f ? `. ${f.big}` : ''}`,
);
}
setFlash(f);
if (!f) return undefined;
const tm = setTimeout(() => setFlash(null), 1300);
return () => clearTimeout(tm);
}, [seq]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
if (mine && !prevMine.current && v.phase === 'playing') {
@@ -811,10 +1138,11 @@ function GostopBoard(props: BoardProps<GostopView>) {
}, [mine]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
if (v.outcome && v.phase !== 'playing') {
if (v.outcome.winner === me) sounds.win();
setAnnounce(`${v.roundNo}판 결과: ${outcomeTitle(v.outcome, players, me)}`);
}
}, [v.roundNo, v.phase]); // eslint-disable-line react-hooks/exhaustive-deps
const [banner, showBanner] = useBanner();
useGostopFx(v, me, players, showBanner);
const myIdx = v.seats.findIndex((s) => s.id === me);
const others = myIdx < 0 ? v.seats : [...v.seats.slice(myIdx + 1), ...v.seats.slice(0, myIdx)];
const glow = new Set<number>(v.rules.hints && focus ? focus.matches : []);
@@ -831,12 +1159,7 @@ function GostopBoard(props: BoardProps<GostopView>) {
<RoundResult {...props} />
<MyArea {...props} onFocusCard={setFocus} />
<Decisions {...props} />
{flash && v.phase === 'playing' && (
<div className="gs-flash" aria-hidden>
{flash.big}
<small>{flash.small}</small>
</div>
)}
{banner}
<p className="sr-only" aria-live="polite">
{announce}
</p>