카드 게임 시간 무제한(우노·뱅!·달무티·고스톱·도둑잡기·포커·바퀴벌레 포커·99), 공통 카드 움직임(card-fx), 우노·달무티·도둑잡기·포커 소리·애니메이션
- 무제한(null): 차례 시계·타임아웃 없음, 자리 비움만 짧은 시계, 연결 끊김은 방 유예 뒤 자동 행동 그대로 - 포커는 리바이 고르는 시간도 무제한 가능, 고스톱은 고·스톱 선택 시간도 무제한 가능, 뱅!은 반응 시간·캐릭터 고르기도 - card-fx: 날아가는 카드·칩(ghost), 제자리 날아오기, 배너, view 변화 감지 훅(처음 렌더·다시 보기는 건너뜀) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
/** 포커 화면 (docs/games/poker.md §9). Chips are room-only play points. */
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import type { BetActionType, LegalBetView, PokerMode, PokerOptions, PokerView, SeatView, Side, ViewCard } from '@bg/games/poker';
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import type { BetActionType, LegalBetView, LogEntry, PokerMode, PokerOptions, PokerView, SeatView, Side, ViewCard } from '@bg/games/poker';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { PlayingCard } from '../../components/cards/PlayingCard';
|
||||
import { Chips, PlayChipNotice, formatChips } 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, useChange } from '../card-fx';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -119,7 +120,7 @@ function SeatCards({ seat, v, me }: { seat: SeatView; v: PokerView; me: string |
|
||||
if (!cards.length) return null;
|
||||
const best = new Set(sd?.best ?? []);
|
||||
return (
|
||||
<div style={{ display: 'flex', flexWrap: 'nowrap', justifyContent: 'center' }}>
|
||||
<div style={{ display: 'flex', flexWrap: 'nowrap', justifyContent: 'center' }} data-fx="seat-cards">
|
||||
{cards.map((x, i) => (
|
||||
<PlayingCard
|
||||
key={x.key}
|
||||
@@ -148,8 +149,9 @@ function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v:
|
||||
if (seat.boss) marks.push(['보스', '#fb923c', '보스(먼저 베팅)']);
|
||||
return (
|
||||
<div
|
||||
className={`pk-seat${waiting ? ' turn' : ''}${seat.id === me ? ' me' : ''}${won ? ' win' : ''}${out ? ' out' : ''}`}
|
||||
className={`pk-seat${waiting ? ' turn anim-glow' : ''}${seat.id === me ? ' me' : ''}${won ? ' win' : ''}${out ? ' out' : ''}`}
|
||||
style={{ '--x': `${x}%`, '--y': `${y}%` } as React.CSSProperties}
|
||||
data-fx-seat={seat.id}
|
||||
aria-label={`${u.nickname} ${formatChips(seat.stack)}${marks.length ? `, ${marks.map((m) => m[2]).join(', ')}` : ''}${badges.length ? `, ${badges.map((b) => b[0]).join(', ')}` : ''}`}
|
||||
>
|
||||
<div className="row" style={{ gap: 5, flexWrap: 'nowrap' }}>
|
||||
@@ -195,15 +197,15 @@ function CenterInfo({ v, players }: { v: PokerView; players: Record<string, Publ
|
||||
const limit = v.options.endCondition === 'hands' ? `/${v.options.handLimit}` : '';
|
||||
const penalty = v.penalties.reduce((a, p) => a + p.amount, 0);
|
||||
return (
|
||||
<div className="pk-center">
|
||||
<div className="pk-center" data-fx="poker-center">
|
||||
{v.streetName && <div className="pk-badge" style={{ background: '#fde047', color: '#422006', fontSize: '0.95rem', padding: '2px 12px' }}>{v.streetName}</div>}
|
||||
{isCommunity(v.mode) && (
|
||||
<div className="pk-board" aria-label="공용 카드">
|
||||
<div className="pk-board" aria-label="공용 카드" data-fx="poker-board">
|
||||
{Array.from({ length: 5 }, (_, i) => (v.board[i] ? <PlayingCard key={v.board[i]} card={v.board[i]!} size="md" /> : <span key={`e${i}`} className="pk-slot" aria-hidden />))}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: '0.95rem', opacity: 0.9 }}>모인 칩</div>
|
||||
<div style={{ fontSize: '2.2rem', fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite">
|
||||
<div style={{ fontSize: '2.2rem', fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite" data-fx="poker-pot">
|
||||
{formatChips(v.pot)}
|
||||
</div>
|
||||
{v.pots.length > 1 && (
|
||||
@@ -239,6 +241,8 @@ function PokerBoard({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
const prevWaiting = useRef(false);
|
||||
const mine = isMyTurn(v, me);
|
||||
const showKey = `${v.handNo}-${v.handPhase}`;
|
||||
const [banner, showBanner] = useBanner();
|
||||
usePokerFx(v, me, players, showBanner);
|
||||
|
||||
useEffect(() => {
|
||||
if (mine && !prevWaiting.current) {
|
||||
@@ -270,10 +274,259 @@ function PokerBoard({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{banner}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- sounds + motion (2026-10-13)
|
||||
|
||||
/** 포커 sounds on top of the shared palette (synthesized, no files). */
|
||||
const pokerSfx = {
|
||||
/** 체크: two knuckle knocks on the felt. */
|
||||
knock: (delay = 0) => {
|
||||
for (const d of [0, 120]) {
|
||||
tone(190, 60, 'sine', 0.22, delay + d, { slideTo: 120 });
|
||||
noise(35, 0.1, delay + d, 'lowpass', 700);
|
||||
}
|
||||
},
|
||||
/** 다이/폴드: cards slid away to the muck. */
|
||||
fold: (delay = 0) => {
|
||||
noise(220, 0.09, delay, 'bandpass', 800, 0.6);
|
||||
tone(330, 160, 'triangle', 0.05, delay + 40, { slideTo: 200 });
|
||||
},
|
||||
/** 올인: a big push of chips with a low swell. */
|
||||
allIn: (delay = 0) => {
|
||||
for (let i = 0; i < 7; i++) sfx.chip(delay + i * 45);
|
||||
tone(140, 360, 'sawtooth', 0.05, delay, { slideTo: 280 });
|
||||
tone(70, 300, 'sine', 0.14, delay);
|
||||
},
|
||||
/** 하이·로우·스윙 선언 공개. */
|
||||
declare: (delay = 0) => tone(660, 120, 'triangle', 0.1, delay, { slideTo: 990 }),
|
||||
};
|
||||
|
||||
const later = (ms: number, f: () => void) => (ms > 0 ? setTimeout(f, ms) : f());
|
||||
|
||||
/** Card turned over in place (WAAPI so React's own style/transform stays). */
|
||||
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: 420, delay, easing: 'ease', fill: 'backwards', composite: 'add' },
|
||||
);
|
||||
}
|
||||
|
||||
/** The card elements of a seat on the table (forehead, hole, choice, up — same order as SeatCards). */
|
||||
const seatCardEls = (id: string): Element[] => [...(seatEl(id)?.querySelector('[data-fx="seat-cards"]')?.children ?? [])];
|
||||
const myCardEl = (slot: string) => document.querySelector(`[data-fx="poker-mine"] [data-slot="${cssEsc(slot)}"]`);
|
||||
const cardCount = (s: SeatView) => (s.forehead !== undefined ? 1 : 0) + s.hole.length + s.choiceCount + s.up.length;
|
||||
/** My visible card slots (ids where I can see them) — a new id means a card just came to me. */
|
||||
function mySlots(v: PokerView, me: string | null): string[] {
|
||||
const seat = v.seats.find((s) => s.id === me);
|
||||
if (!seat) return [];
|
||||
const out: string[] = [];
|
||||
seat.hole.forEach((c, i) => out.push(c ?? `h${i}`));
|
||||
seat.up.forEach((c, i) => out.push(c ?? `u${i}`));
|
||||
if (v.my.choice) out.push(...v.my.choice);
|
||||
return out;
|
||||
}
|
||||
const sameEntry = (a: LogEntry, b: LogEntry) => a.hand === b.hand && a.by === b.by && a.msg === b.msg;
|
||||
/** Entries appended to the (sliding, last-30) log since `prev`; null when the two don't line up (resync/jump). */
|
||||
function newLogEntries(prev: readonly LogEntry[], next: readonly LogEntry[]): LogEntry[] | null {
|
||||
for (let d = 0; d <= next.length; d++) {
|
||||
const keep = next.length - d;
|
||||
if (keep > prev.length) continue;
|
||||
if (keep === 0) return prev.length === 0 ? [...next] : null;
|
||||
let ok = true;
|
||||
for (let i = 0; i < keep && ok; i++) ok = sameEntry(next[i]!, prev[prev.length - keep + i]!);
|
||||
if (ok) return next.slice(keep);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const BET_RE = /^(삥|콜|따당|쿼터|하프|풀|레이즈|벳|올인) (\d+) 칩/;
|
||||
const DRAW_RE = /(\d)장 바꿈|박스\((\d)장\)/;
|
||||
|
||||
/**
|
||||
* Sounds + motion for every change of the table, mine or anyone else's (log entries and view diffs since the last
|
||||
* view). Nothing on the first render (join, reload, replay jump).
|
||||
*/
|
||||
function usePokerFx(v: PokerView, me: string | null, players: Record<string, PublicUser>, showBanner: ReturnType<typeof useBanner>[1]) {
|
||||
const prev = useRef<PokerView | null>(null);
|
||||
const chipN = (amount: number) => Math.max(1, Math.min(6, Math.round(Math.log2(1 + amount / Math.max(1, v.baseUnit)))));
|
||||
const center = () => fxEl('poker-center');
|
||||
const pot = () => fxEl('poker-pot');
|
||||
|
||||
/** New hand (or the very first one on mount): antes/blinds to the pot, then cards from the middle to everyone. */
|
||||
const deal = (p: PokerView | null) => {
|
||||
sfx.shuffle();
|
||||
const inHand = v.seats.filter((s) => s.inHand && s.status !== 'left');
|
||||
inHand.forEach((s, i) => {
|
||||
if (s.handBet > 0) flyGhost(seatEl(s.id), pot(), { kind: 'chip', count: Math.min(3, chipN(s.handBet)), delay: i * 50 });
|
||||
});
|
||||
if (v.pot > 0) later(150, () => sfx.chips(3));
|
||||
const per = Math.max(0, ...inHand.map(cardCount));
|
||||
later(320, () => sfx.deal(Math.min(8, per * Math.max(1, inHand.length)), 55));
|
||||
inHand.forEach((s, i) => {
|
||||
if (s.id !== me) flyGhost(center(), seatEl(s.id), { count: Math.min(4, cardCount(s)), gap: 90, delay: 320 + i * 60 });
|
||||
});
|
||||
const known = new Set(p ? mySlots(p, me) : []);
|
||||
mySlots(v, me)
|
||||
.filter((k) => !known.has(k))
|
||||
.forEach((k, i) => flyFrom(myCardEl(k), center(), { delay: 320 + i * 80, rotate: 10 }));
|
||||
if (v.seats.find((s) => s.id === me)?.forehead !== undefined) flyFrom(myCardEl('f'), center(), { delay: 320, rotate: -10 });
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const p = prev.current;
|
||||
prev.current = v;
|
||||
if (!p || p === v) return;
|
||||
const newHand = v.handNo !== p.handNo && v.handNo > 0;
|
||||
let t = 0;
|
||||
if (newHand) {
|
||||
deal(p);
|
||||
t = 600;
|
||||
} else if (v.handNo > 0) {
|
||||
// Cards dealt during the hand (7포커 streets, 인디언 2nd card …) and community cards.
|
||||
let dealt = 0;
|
||||
v.seats.forEach((s) => {
|
||||
const before = p.seats.find((x) => x.id === s.id);
|
||||
const k = before ? cardCount(s) - cardCount(before) : 0;
|
||||
if (k > 0 && s.id !== me) flyGhost(center(), seatEl(s.id), { count: Math.min(4, k), gap: 90, delay: dealt * 70 });
|
||||
if (k > 0) dealt += k;
|
||||
});
|
||||
const known = new Set(mySlots(p, me));
|
||||
const mine = mySlots(v, me).filter((k) => !known.has(k));
|
||||
mine.forEach((k, i) => flyFrom(myCardEl(k), center(), { delay: i * 80, rotate: 10 }));
|
||||
if (dealt > 0) sfx.deal(Math.min(8, dealt), 60);
|
||||
const boardEl = fxEl('poker-board');
|
||||
for (let i = p.board.length; i < v.board.length; i++) {
|
||||
const at = (i - p.board.length) * 140;
|
||||
flipIn(boardEl?.children[i], at);
|
||||
later(at, sfx.cardFlip);
|
||||
}
|
||||
if (v.board.length > p.board.length) t = (v.board.length - p.board.length) * 140;
|
||||
// Showdown: hidden cards are turned over seat by seat.
|
||||
if (v.showdown && !p.showdown) {
|
||||
let n = 0;
|
||||
for (const e of v.showdown) {
|
||||
const s = v.seats.find((x) => x.id === e.id);
|
||||
if (!s || s.id === me) continue;
|
||||
const els = seatCardEls(s.id);
|
||||
const off = s.forehead !== undefined ? 1 : 0;
|
||||
const at = t + n * 160;
|
||||
for (let i = 0; i < s.hole.length; i++) flipIn(els[off + i], at + i * 40);
|
||||
later(at, sfx.cardFlip);
|
||||
n++;
|
||||
}
|
||||
t += n * 160 + 100;
|
||||
}
|
||||
// 인디언: my own forehead card is shown at the end of the hand.
|
||||
const myNow = v.seats.find((s) => s.id === me);
|
||||
const myBefore = p.seats.find((s) => s.id === me);
|
||||
if (myNow?.forehead && myBefore && !myBefore.forehead) {
|
||||
flipIn(myCardEl('f'), t);
|
||||
later(t, sfx.cardFlip);
|
||||
t += 160;
|
||||
}
|
||||
}
|
||||
|
||||
const fresh = newLogEntries(p.log, v.log);
|
||||
if (!fresh || fresh.length > 12) return;
|
||||
for (const e of fresh) {
|
||||
const at = t;
|
||||
const by = e.by;
|
||||
const msg = e.msg;
|
||||
if (!by) {
|
||||
if (msg.includes('오픈 카드를 공개')) {
|
||||
v.seats.forEach((s, i) => {
|
||||
if (!s.up.length) return;
|
||||
const els = seatCardEls(s.id);
|
||||
flipIn(els[els.length - 1], at + i * 70);
|
||||
});
|
||||
later(at, sfx.cardFlip);
|
||||
later(at + 140, sfx.cardFlip);
|
||||
t += 200;
|
||||
} else if (msg.includes('섞')) {
|
||||
later(at, sfx.shuffle);
|
||||
} else if (msg.includes('기본 단위가')) {
|
||||
later(at, sfx.good);
|
||||
bump(pot());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const bet = BET_RE.exec(msg);
|
||||
if (bet) {
|
||||
const amount = Number(bet[2]);
|
||||
const n = chipN(amount);
|
||||
flyGhost(seatEl(by), pot(), { kind: 'chip', count: n, gap: 60, delay: at });
|
||||
if (msg.includes('올인')) {
|
||||
later(at, () => pokerSfx.allIn());
|
||||
later(at, () => showBanner('올인!', 'red', by === me ? undefined : `${nick(players, by)}님`));
|
||||
bump(seatEl(by), 'shake');
|
||||
} else later(at, () => sfx.chips(Math.min(5, n + 1)));
|
||||
t += 140;
|
||||
} else if (msg === '체크') {
|
||||
later(at, () => pokerSfx.knock());
|
||||
t += 120;
|
||||
} else if (msg === '다이' || msg === '폴드' || msg.includes('나가서 다이')) {
|
||||
const s = v.seats.find((x) => x.id === by);
|
||||
flyGhost(seatEl(by), center(), { count: Math.min(3, s ? Math.max(1, cardCount(s)) : 2), gap: 50, delay: at });
|
||||
later(at, () => pokerSfx.fold());
|
||||
t += 130;
|
||||
} else if (DRAW_RE.test(msg)) {
|
||||
const m = DRAW_RE.exec(msg)!;
|
||||
const k = Number(m[1] ?? m[2]);
|
||||
flyGhost(seatEl(by), center(), { count: k, gap: 60, delay: at });
|
||||
if (by !== me) flyGhost(center(), seatEl(by), { count: k, gap: 70, delay: at + 300 });
|
||||
later(at, () => sfx.cardDeal());
|
||||
later(at + 300, () => sfx.draw(Math.min(4, k)));
|
||||
t += 150;
|
||||
} else if (msg.endsWith('패스')) {
|
||||
later(at, () => pokerSfx.knock());
|
||||
t += 120;
|
||||
} else if (msg.startsWith('선언:')) {
|
||||
later(at, () => pokerSfx.declare());
|
||||
bump(seatEl(by));
|
||||
t += 120;
|
||||
} else if (msg.includes('벌칙')) {
|
||||
flyGhost(seatEl(by), pot(), { kind: 'chip', count: 4, gap: 50, delay: at });
|
||||
later(at, sfx.alarm);
|
||||
bump(seatEl(by), 'shake');
|
||||
t += 200;
|
||||
} else if (msg.includes('가져갔어요')) {
|
||||
flyGhost(pot(), seatEl(by), { kind: 'chip', count: 6, gap: 55, delay: at + 150 });
|
||||
later(at + 300, sfx.collect);
|
||||
later(at + 500, () => bump(seatEl(by)));
|
||||
t += 250;
|
||||
} else if (msg.includes('다시 받았어요')) {
|
||||
flyGhost(center(), seatEl(by), { kind: 'coin', count: 5, gap: 60, delay: at });
|
||||
later(at, sfx.coin);
|
||||
t += 150;
|
||||
} else if (msg.includes('자리 비움')) {
|
||||
later(at, sfx.tick);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Pot amount pops when it grows (after the chips arrive).
|
||||
useChange(v.pot, (now, before) => {
|
||||
if (now > before) later(380, () => bump(pot()));
|
||||
});
|
||||
|
||||
// Mounted right at the start of the game (nothing played yet): show the deal once.
|
||||
const started = useRef(false);
|
||||
useLayoutEffect(() => {
|
||||
if (started.current) return;
|
||||
started.current = true;
|
||||
if (v.handNo === 1 && v.handPhase !== 'handEnd' && !v.log.some((e) => e.by !== null)) deal(null);
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}
|
||||
|
||||
function resultLine(v: PokerView, players: Record<string, PublicUser>): string {
|
||||
if (!v.awards) return '';
|
||||
const won = new Map<string, number>();
|
||||
@@ -369,21 +622,21 @@ function MyCards({ v, seat }: { v: PokerView; seat: SeatView }) {
|
||||
const sd = v.showdown?.find((e) => e.id === seat.id);
|
||||
const best = new Set(sd?.best ?? []);
|
||||
return (
|
||||
<div className="pk-mine" aria-label="내 카드">
|
||||
<div className="pk-mine" aria-label="내 카드" data-fx="poker-mine">
|
||||
{seat.forehead !== undefined && (
|
||||
<div className="stack" style={{ gap: 2, alignItems: 'center' }}>
|
||||
<div className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot="f">
|
||||
<PlayingCard card={seat.forehead} size="lg" title={seat.forehead ? undefined : '내 이마 카드(나만 못 봐요)'} />
|
||||
<span className="small muted">이마</span>
|
||||
</div>
|
||||
)}
|
||||
{seat.hole.map((c, i) => (
|
||||
<div key={`h${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }}>
|
||||
<div key={`h${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot={c ?? `h${i}`}>
|
||||
<PlayingCard card={c} size="lg" highlight={!!c && best.has(c)} />
|
||||
{(isSevenMode(v.mode) || v.mode === 'indian') && <span className="small muted">{v.mode === 'indian' ? '손' : '나만 봄'}</span>}
|
||||
</div>
|
||||
))}
|
||||
{seat.up.map((c, i) => (
|
||||
<div key={`u${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }}>
|
||||
<div key={`u${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot={c ?? `u${i}`}>
|
||||
<PlayingCard card={c} size="lg" highlight={!!c && best.has(c)} />
|
||||
<span className="small muted">공개</span>
|
||||
</div>
|
||||
@@ -397,6 +650,7 @@ function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unkno
|
||||
const [discard, setDiscard] = useState<string | null>(null);
|
||||
const [open, setOpen] = useState<string | null>(null);
|
||||
const tap = (c: string) => {
|
||||
sfx.select();
|
||||
if (!discard) setDiscard(c);
|
||||
else if (c === discard) {
|
||||
setDiscard(null);
|
||||
@@ -410,9 +664,9 @@ function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unkno
|
||||
<br />
|
||||
<span className="small muted">버린 카드는 아무에게도 보이지 않아요. 남는 2장은 나만 봐요.</span>
|
||||
</p>
|
||||
<div className="pk-mine">
|
||||
<div className="pk-mine" data-fx="poker-mine">
|
||||
{cards.map((c) => (
|
||||
<span key={c} className={c === discard ? 'pk-x' : undefined}>
|
||||
<span key={c} className={c === discard ? 'pk-x' : undefined} data-slot={c}>
|
||||
<PlayingCard card={c} size="lg" selected={c === open} dimmed={c === discard} onClick={() => tap(c)} title={c === discard ? '버릴 카드(다시 누르면 취소)' : c === open ? '보여 줄 카드' : undefined} />
|
||||
</span>
|
||||
))}
|
||||
@@ -457,7 +711,11 @@ function DrawPicker({ v, hole, act, pending }: { v: PokerView; hole: string[]; a
|
||||
</p>
|
||||
<div className="pk-mine">
|
||||
{hole.map((c) => (
|
||||
<PlayingCard key={c} card={c} size="lg" selected={sel.includes(c)} onClick={() => setSel((s) => (s.includes(c) ? s.filter((x) => x !== c) : [...s, c]))} />
|
||||
<PlayingCard key={c} card={c} size="lg" selected={sel.includes(c)} onClick={() => {
|
||||
sfx.select();
|
||||
setSel((s) => (s.includes(c) ? s.filter((x) => x !== c) : [...s, c]));
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{tooMany && <p className="field-error" style={{ margin: 0, textAlign: 'center' }}>{limit}장까지만 바꿀 수 있어요.</p>}
|
||||
@@ -812,7 +1070,7 @@ function statusText(v: PokerView, me: string | null, players: Record<string, Pub
|
||||
|
||||
// ---------------------------------------------------------------- options
|
||||
|
||||
function Seg<T extends string | number>({ value, options, onChange }: { value: T; options: [T, string][]; onChange: (v: T) => void }) {
|
||||
function Seg<T extends string | number | null>({ value, options, onChange }: { value: T; options: [T, string][]; onChange: (v: T) => void }) {
|
||||
return (
|
||||
<div className="segmented">
|
||||
{options.map(([k, l]) => (
|
||||
@@ -868,7 +1126,7 @@ function Options({ value: o, onChange }: OptionsProps<PokerOptions>) {
|
||||
{o.endCondition === 'hands' && <Seg value={o.handLimit} options={[[10, '10판'], [20, '20판'], [30, '30판'], [50, '50판']]} onChange={(handLimit) => set({ handLimit })} />}
|
||||
</Field>
|
||||
<Field label="행동 제한 시간">
|
||||
<Seg value={o.turnSeconds} options={[[15, '15초'], [20, '20초'], [30, '30초'], [60, '60초']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
<Seg value={o.turnSeconds} options={[[15, '15초'], [20, '20초'], [30, '30초'], [60, '60초'], [null, '무제한']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
</Field>
|
||||
{o.mode === 'indian' && (
|
||||
<Field label="인디언 포커">
|
||||
@@ -888,6 +1146,11 @@ function Options({ value: o, onChange }: OptionsProps<PokerOptions>) {
|
||||
<Seg value={o.rebuy} options={[['off', '안 함(탈락)'], ['limited', '횟수 제한'], ['unlimited', '무제한']]} onChange={(rebuy) => set({ rebuy })} />
|
||||
{o.rebuy === 'limited' && <Seg value={o.rebuyLimit} options={[[1, '1번'], [2, '2번'], [3, '3번']]} onChange={(rebuyLimit) => set({ rebuyLimit })} />}
|
||||
</Field>
|
||||
{o.rebuy !== 'off' && (
|
||||
<Field label="리바이 고르는 시간">
|
||||
<Seg value={o.rebuySeconds} options={[[10, '10초'], [15, '15초'], [30, '30초'], [null, '무제한']]} onChange={(rebuySeconds) => set({ rebuySeconds })} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label="기본 칩 2배로 올리기">
|
||||
<Seg value={o.blindUpEvery} options={[[0, '안 올림'], [5, '5판마다'], [10, '10판마다'], [15, '15판마다']]} onChange={(blindUpEvery) => set({ blindUpEvery })} />
|
||||
</Field>
|
||||
@@ -933,7 +1196,7 @@ function Options({ value: o, onChange }: OptionsProps<PokerOptions>) {
|
||||
|
||||
function optionsSummary(o: PokerOptions): string {
|
||||
const bet = o.betting === 'auto' ? '' : o.betting === 'korean' ? '한국식' : o.betting === 'noLimit' ? '노리밋' : '팟리밋';
|
||||
return [MODE_KO[o.mode], bet, `시작 ${o.startingChips.toLocaleString('ko-KR')}칩`, `기본 ${o.baseUnit}칩`, o.endCondition === 'hands' ? `${o.handLimit}판` : '최후의 1인', `${o.turnSeconds}초`]
|
||||
return [MODE_KO[o.mode], bet, `시작 ${o.startingChips.toLocaleString('ko-KR')}칩`, `기본 ${o.baseUnit}칩`, o.endCondition === 'hands' ? `${o.handLimit}판` : '최후의 1인', o.turnSeconds === null ? '시간 무제한' : `${o.turnSeconds}초`]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
}
|
||||
@@ -974,7 +1237,11 @@ function Rules({ options }: { options?: PokerOptions }) {
|
||||
{o?.rebuy === 'off' ? '탈락하고 구경해요.' : '칩을 다시 받을지 고를 수 있어요. 다시 받은 만큼 최종 점수에서 빠져요.'}{' '}
|
||||
{o?.endCondition === 'lastStanding' ? '칩을 가진 사람이 한 명 남으면 끝나요.' : '정해진 판 수가 끝나면 (마지막 칩 − 시작 칩 × 다시 받은 횟수)로 순위를 정해요.'}
|
||||
</p>
|
||||
<p>시간 안에 고르지 않으면 걸린 칩이 없을 때는 체크, 있을 때는 포기로 처리돼요. 두 번 연속 시간을 넘기면 '자리 비움'이 되고 제한 시간이 짧아져요.</p>
|
||||
{o?.turnSeconds === null ? (
|
||||
<p>시간 제한은 없어요. 연결이 끊긴 채 오래 돌아오지 않으면 걸린 칩이 없을 때는 체크, 있을 때는 포기로 자동 처리돼요. 이렇게 두 번 연속 넘어가면 '자리 비움'이 되고 짧은 제한 시간이 생겨요.</p>
|
||||
) : (
|
||||
<p>시간 안에 고르지 않으면 걸린 칩이 없을 때는 체크, 있을 때는 포기로 처리돼요. 두 번 연속 시간을 넘기면 '자리 비움'이 되고 제한 시간이 짧아져요.</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user