새 게임 블랙잭: 딜러(하우스) 상대 1~7명·놀이용 칩. 공식 규칙(6벌 S17·블랙잭 3:2·A/10 peek·아무 두 장 더블·DAS·4손패 스플릿·에이스 한 장)을 기본값으로, 한국 하우스 룰(5·6카드 찰리, 7-7-7 보너스 3:1, 배당 6:5·2:1·1:1, H17, 더블 9~11·10~11, 에이스 자유 히트·다시 스플릿, 레이트 서렌더, 인슈어런스)을 방 설정으로
- 엔진 packages/games/src/blackjack/(options·types·rules·index·bot): 베팅→인슈어런스→플레이→딜러→결과 단계 상태 기계, 비공개는 딜러 홀 카드와 슈뿐(재셔플마다 카드 id 유일), 칩은 하우스 상대로 정산 - 컴퓨터: 기본 전략(S17 차트) + 레벨 1~60(쉬움은 딜러 흉내·인슈어런스 가끔, 어려움은 차트대로·인슈어런스 거절) - 웹 apps/web/src/games/blackjack/: 초록 테이블·손패·단계별 버튼·방 설정 변형, 30초 요약·도움말, 표준 카드 아트 재사용 - 등록: GAMES·BOT_STRATEGIES·BOT_GAMES·CATALOG·GAME_UI·GAME_ICON·게임 탭, 문서(games/blackjack.md·README·로드맵·결정 사항), e2e/games.e2e.ts - 검증: 엔진·봇 테스트, 무작위 플레이(여러 옵션) JSON 왕복·정보 누출 없음, 전체 테스트 2,611개·타입 검사·웹 빌드 통과, bun e2e/games.e2e.ts blackjack 통과 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
68
apps/web/src/games/blackjack/help.ts
Normal file
68
apps/web/src/games/blackjack/help.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/** 블랙잭 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view. */
|
||||
import type { BlackjackView, SeatView } from '@bg/games/blackjack';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
|
||||
const nm = (players: Record<string, PublicUser>, id: string | null | undefined) => `${(id && players[id]?.nickname) || '다른 사람'}님`;
|
||||
const chips = (n: number) => `${n.toLocaleString('ko-KR')} 칩`;
|
||||
|
||||
function handsLeftLine(v: BlackjackView): string {
|
||||
if (v.handLimit === null) return '칩이 가장 많은 한 사람이 남을 때까지 해요.';
|
||||
return `모두 ${v.handLimit}판 중 ${Math.min(v.handsPlayed + 1, v.handLimit)}판째예요.`;
|
||||
}
|
||||
|
||||
function mySeat(v: BlackjackView): SeatView | undefined {
|
||||
return v.me ? v.seats.find((s) => s.id === v.me) : undefined;
|
||||
}
|
||||
|
||||
export function helpNow(v: BlackjackView, me: string | null, players: Record<string, PublicUser>): string {
|
||||
const goal = '딜러보다 21에 가깝게 만들면 이겨요. 21을 넘기면(버스트) 바로 져요.';
|
||||
if (v.phase === 'finished') {
|
||||
return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n결과 창에서 [한 판 더]를 누르면 다시 할 수 있어요.';
|
||||
}
|
||||
|
||||
const seat = mySeat(v);
|
||||
const dealerUp = v.dealer.cards[0] ? `딜러가 보여 준 카드 합은 ${v.dealer.total}이에요.` : '';
|
||||
|
||||
// Spectator or someone who is sitting out this hand.
|
||||
if (!seat || !seat.hands) {
|
||||
if (v.phase === 'betting') return `모두 베팅하는 중이에요.\n${goal} ${handsLeftLine(v)}`;
|
||||
if (v.phase === 'playing' && v.turn) return `${nm(players, v.turn)} 차례예요. ${dealerUp}\n${goal}`;
|
||||
if (v.phase === 'handEnd') return `이번 판 결과가 나왔어요. ${dealerUp}\n잠시 뒤 다음 판으로 넘어가요.`;
|
||||
return `${goal} ${handsLeftLine(v)}`;
|
||||
}
|
||||
|
||||
if (v.phase === 'betting') {
|
||||
if (!seat.betLocked && v.betRange) {
|
||||
return `베팅할 차례예요. 내 칩은 ${chips(seat.chips)}.\n${chips(v.betRange.min)}부터 ${chips(v.betRange.max)}까지 ${v.betRange.step.toLocaleString('ko-KR')} 칩 단위로 걸고 [베팅]을 눌러요. ${goal}`;
|
||||
}
|
||||
return `베팅을 걸었어요(${chips(seat.bet)}). 다른 사람이 걸면 카드를 나눠 줘요.`;
|
||||
}
|
||||
|
||||
if (v.phase === 'insurance') {
|
||||
if (v.insuranceOpen) {
|
||||
return `딜러가 A를 보여 줬어요. 인슈어런스를 걸지 고르는 중이에요.\n걸면 베팅의 절반(${chips(v.insuranceMax)})을 내고, 딜러가 블랙잭이면 2:1로 돌려받아요. 아니면 잃어요. 보통은 안 거는 게 유리해요.`;
|
||||
}
|
||||
return '인슈어런스를 골랐어요. 다른 사람을 기다려요.';
|
||||
}
|
||||
|
||||
if (v.phase === 'handEnd') {
|
||||
const net = seat.net ?? 0;
|
||||
const outcome = net > 0 ? `${chips(net)}을 땄어요!` : net < 0 ? `${chips(-net)}을 잃었어요.` : '비겼어요(그대로).';
|
||||
return `이번 판 결과: ${outcome} 지금 내 칩은 ${chips(seat.chips)}.\n잠시 뒤 다음 판으로 넘어가요. [다음 판]을 누르면 바로 넘어가요.`;
|
||||
}
|
||||
|
||||
// playing
|
||||
if (v.turn !== v.me || !v.my) {
|
||||
return `${nm(players, v.turn)} 차례예요. ${dealerUp}\n내 패는 그대로 두고 기다려요.`;
|
||||
}
|
||||
const h = seat.hands[seat.active];
|
||||
const my = v.my;
|
||||
const lines = [`내 차례예요. 지금 내 ${seat.hands.length > 1 ? `${seat.active + 1}번째 손패 ` : ''}합은 ${h?.total ?? 0}${h?.soft ? '(소프트)' : ''}이에요. ${dealerUp}`];
|
||||
const acts: string[] = ['[히트]로 한 장 더 받거나 [스탠드]로 멈춰요'];
|
||||
if (my.canDouble) acts.push('[더블]은 베팅을 두 배로 걸고 딱 한 장만 받아요');
|
||||
if (my.canSplit) acts.push('[스플릿]은 같은 숫자 두 장을 두 손패로 나눠요(베팅 한 번 더)');
|
||||
if (my.canSurrender) acts.push('[서렌더]는 베팅 절반만 잃고 이 판을 포기해요');
|
||||
lines.push(acts.join('. ') + '.');
|
||||
if ((h?.total ?? 0) >= 17 && !h?.soft) lines.push('17 이상이면 보통 멈춰요. 더 받으면 버스트 위험이 커요.');
|
||||
return lines.join('\n');
|
||||
}
|
||||
389
apps/web/src/games/blackjack/index.tsx
Normal file
389
apps/web/src/games/blackjack/index.tsx
Normal file
@@ -0,0 +1,389 @@
|
||||
/** 블랙잭 화면 (docs/games/blackjack.md §9). Standard-deck art reuses components/cards/PlayingCard. */
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import type { BlackjackOptions, BlackjackView, HandView, SeatView } from '@bg/games/blackjack';
|
||||
import { baseCard } from '@bg/games/blackjack';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { PLAYING_CARD_CREDIT, PlayingCard } from '../../components/cards/PlayingCard';
|
||||
import { Chips, PlayChipNotice, formatChips } from '../../components/cards/Chips';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
|
||||
const nick = (players: Record<string, PublicUser>, id: string) => players[id]?.nickname ?? '알 수 없음';
|
||||
|
||||
function isMyTurn(v: BlackjackView, me: string | null): boolean {
|
||||
if (!me || v.me !== me) return false;
|
||||
const seat = v.seats.find((s) => s.id === me);
|
||||
if (!seat) return false;
|
||||
switch (v.phase) {
|
||||
case 'betting':
|
||||
return !seat.betLocked && !!v.betRange;
|
||||
case 'insurance':
|
||||
return v.insuranceOpen;
|
||||
case 'playing':
|
||||
return v.turn === me && !!v.my;
|
||||
case 'handEnd':
|
||||
return !!seat.hands && !seat.ready;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function statusText(v: BlackjackView, me: string | null, players: Record<string, PublicUser>): string {
|
||||
switch (v.phase) {
|
||||
case 'betting':
|
||||
return isMyTurn(v, me) ? '베팅하세요' : '베팅을 기다려요';
|
||||
case 'insurance':
|
||||
return v.insuranceOpen ? '인슈어런스를 고르세요' : '인슈어런스 선택을 기다려요';
|
||||
case 'playing':
|
||||
return v.turn === me ? '내 차례예요' : v.turn ? `${nick(players, v.turn)}님 차례예요` : '딜러 차례예요';
|
||||
case 'handEnd':
|
||||
return '이번 판 결과';
|
||||
case 'finished':
|
||||
return v.result?.summary ?? '게임이 끝났어요';
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- hand rendering
|
||||
|
||||
const HAND_KO: Record<HandView['status'], string> = {
|
||||
playing: '',
|
||||
stand: '',
|
||||
bust: '버스트',
|
||||
blackjack: '블랙잭!',
|
||||
charlie: '찰리!',
|
||||
surrender: '서렌더',
|
||||
};
|
||||
const OUTCOME_KO: Record<NonNullable<HandView['outcome']>, string> = {
|
||||
win: '승', lose: '패', push: '푸시', blackjack: '블랙잭', bonus: '보너스',
|
||||
};
|
||||
|
||||
function totalLabel(h: HandView): string {
|
||||
if (h.status === 'bust') return `${h.total} 버스트`;
|
||||
return h.soft ? `${h.total - 10}/${h.total}` : `${h.total}`;
|
||||
}
|
||||
|
||||
function CardRow({ cards, size = 'md' }: { cards: (string | null)[]; size?: 'sm' | 'md' }) {
|
||||
return (
|
||||
<div style={{ display: 'flex', gap: 4 }}>
|
||||
{cards.map((c, i) => (
|
||||
<PlayingCard key={i} card={c ? baseCard(c) : null} size={size} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HandBox({ h, active }: { h: HandView; active: boolean }) {
|
||||
const tag = h.outcome ? OUTCOME_KO[h.outcome] : HAND_KO[h.status];
|
||||
const color = h.outcome === 'win' || h.outcome === 'blackjack' || h.outcome === 'bonus' ? '#16a34a' : h.outcome === 'lose' || h.status === 'bust' ? '#dc2626' : h.outcome === 'push' ? '#6b7280' : '#b45309';
|
||||
return (
|
||||
<div style={{ padding: 6, borderRadius: 10, border: active ? '2px solid #f59e0b' : '2px solid transparent', background: active ? 'rgba(245,158,11,0.12)' : 'transparent' }}>
|
||||
<CardRow cards={h.cards} size="sm" />
|
||||
<div className="small" style={{ display: 'flex', gap: 6, alignItems: 'center', marginTop: 2 }}>
|
||||
<strong style={{ fontVariantNumeric: 'tabular-nums' }}>{totalLabel(h)}</strong>
|
||||
<span className="muted">{formatChips(h.bet)}{h.doubled ? ' ×2' : ''}</span>
|
||||
{tag && <strong style={{ color }}>{tag}</strong>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SeatHands({ seat, me, players, isTurn }: { seat: SeatView; me: string | null; players: Record<string, PublicUser>; isTurn: boolean }) {
|
||||
return (
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<div className="small" style={{ fontWeight: 800, marginBottom: 2 }}>
|
||||
{seat.id === me ? '나' : nick(players, seat.id)}
|
||||
{seat.net !== null && seat.net !== 0 && <span style={{ color: seat.net > 0 ? '#16a34a' : '#dc2626', marginLeft: 6 }}>{seat.net > 0 ? '+' : ''}{formatChips(seat.net)}</span>}
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8, justifyContent: 'center', flexWrap: 'wrap' }}>
|
||||
{seat.hands!.map((h, i) => (
|
||||
<HandBox key={i} h={h} active={isTurn && i === seat.active} />
|
||||
))}
|
||||
</div>
|
||||
<div className="small muted">{formatChips(seat.chips)}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- board
|
||||
|
||||
function Board({ view: v, me, players }: BoardProps<BlackjackView>) {
|
||||
const d = v.dealer;
|
||||
const dealerTotal = d.revealed ? (d.bust ? `${d.total} 버스트` : d.blackjack ? '블랙잭' : `${d.total}`) : `${d.total} +?`;
|
||||
const dealt = v.seats.filter((s) => s.hands);
|
||||
return (
|
||||
<div style={{ background: 'radial-gradient(circle at 50% 0%, #0f6b3d, #0a4f2d)', borderRadius: 16, padding: 16, color: '#fff' }}>
|
||||
<div style={{ textAlign: 'center', marginBottom: 12 }}>
|
||||
<div className="small" style={{ fontWeight: 800, opacity: 0.85 }}>딜러 · {dealerTotal}</div>
|
||||
<div style={{ display: 'flex', gap: 4, justifyContent: 'center', marginTop: 4, minHeight: 90 }}>
|
||||
{d.cards.length ? d.cards.map((c, i) => <PlayingCard key={i} card={c ? baseCard(c) : null} size="md" />) : <span className="small" style={{ opacity: 0.7, alignSelf: 'center' }}>베팅을 기다려요</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 16, justifyContent: 'center', flexWrap: 'wrap' }}>
|
||||
{dealt.length ? (
|
||||
dealt.map((seat) => <SeatHands key={seat.id} seat={seat} me={me} players={players} isTurn={v.phase === 'playing' && v.turn === seat.id} />)
|
||||
) : (
|
||||
<span className="small" style={{ opacity: 0.8 }}>모두 베팅하는 중이에요…</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- side (controls)
|
||||
|
||||
function BetControls({ v, act, pending }: { v: BlackjackView; act: (a: unknown) => void; pending: boolean }) {
|
||||
const range = v.betRange!;
|
||||
const [amount, setAmount] = useState(range.min);
|
||||
const amt = Math.min(range.max, Math.max(range.min, Math.round(amount / range.step) * range.step));
|
||||
const step = (d: number) => setAmount((a) => Math.min(range.max, Math.max(range.min, a + d * range.step)));
|
||||
return (
|
||||
<div className="stack" style={{ gap: 8 }}>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<button type="button" className="btn btn-secondary" disabled={pending || amt <= range.min} onClick={() => step(-1)} aria-label="베팅 줄이기">−</button>
|
||||
<strong style={{ minWidth: 90, textAlign: 'center', fontVariantNumeric: 'tabular-nums' }}>{formatChips(amt)}</strong>
|
||||
<button type="button" className="btn btn-secondary" disabled={pending || amt >= range.max} onClick={() => step(1)} aria-label="베팅 늘리기">+</button>
|
||||
</div>
|
||||
<button type="button" className="btn btn-primary btn-block" disabled={pending} onClick={() => act({ type: 'bet', amount: amt })}>
|
||||
{formatChips(amt)} 베팅
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ActionButtons({ v, act, pending }: { v: BlackjackView; act: (a: unknown) => void; pending: boolean }) {
|
||||
const my = v.my!;
|
||||
const btn = (label: string, type: string, on: boolean, primary = false) =>
|
||||
on ? (
|
||||
<button key={type} type="button" className={`btn ${primary ? 'btn-primary' : 'btn-secondary'}`} style={{ flex: 1, minWidth: 72 }} disabled={pending} onClick={() => act({ type })}>
|
||||
{label}
|
||||
</button>
|
||||
) : null;
|
||||
return (
|
||||
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
|
||||
{btn('히트', 'hit', my.canHit, true)}
|
||||
{btn('스탠드', 'stand', my.canStand)}
|
||||
{btn('더블', 'double', my.canDouble)}
|
||||
{btn('스플릿', 'split', my.canSplit)}
|
||||
{btn('서렌더', 'surrender', my.canSurrender)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Side({ view: v, me, players, act, pending, deadline }: BoardProps<BlackjackView>) {
|
||||
const seat = me ? v.seats.find((s) => s.id === me) : undefined;
|
||||
const mine = isMyTurn(v, me);
|
||||
return (
|
||||
<div className="stack" style={{ gap: 12 }}>
|
||||
{seat && (
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<Chips n={seat.chips} strong />
|
||||
{mine && <TurnTimer deadline={deadline} totalMs={v.deadlineTotalMs} mine size={28} />}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{v.phase === 'betting' && seat && (mine ? <BetControls v={v} act={act} pending={pending} /> : seat.betLocked ? <p className="small muted">베팅함: {formatChips(seat.bet)} · 다른 사람을 기다려요</p> : <p className="small muted">이번 판은 쉬어요</p>)}
|
||||
|
||||
{v.phase === 'insurance' && (v.insuranceOpen ? (
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<p className="small">딜러가 A를 보여 줬어요. 인슈어런스를 걸까요?</p>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<button type="button" className="btn btn-primary" style={{ flex: 1 }} disabled={pending} onClick={() => act({ type: 'insurance', take: true })}>
|
||||
걸기 ({formatChips(v.insuranceMax)})
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" style={{ flex: 1 }} disabled={pending} onClick={() => act({ type: 'insurance', take: false })}>
|
||||
안 함
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="small muted">인슈어런스 선택을 기다려요</p>
|
||||
))}
|
||||
|
||||
{v.phase === 'playing' && (mine ? <ActionButtons v={v} act={act} pending={pending} /> : <p className="small muted">{v.turn ? `${nick(players, v.turn)}님 차례예요` : '딜러가 카드를 받고 있어요'}</p>)}
|
||||
|
||||
{v.phase === 'handEnd' && seat?.hands && (
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<p className="small">
|
||||
이번 판 {seat.net === null || seat.net === 0 ? '비겼어요' : seat.net > 0 ? `+${formatChips(seat.net)} 땄어요` : `${formatChips(seat.net)} 잃었어요`}.
|
||||
</p>
|
||||
<button type="button" className="btn btn-primary btn-block" disabled={pending || seat.ready} onClick={() => act({ type: 'ready' })}>
|
||||
{seat.ready ? '다음 판을 기다려요…' : '다음 판'}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SeatList v={v} me={me} players={players} />
|
||||
|
||||
{seat && <PlayChipNotice />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SeatList({ v, me, players }: { v: BlackjackView; me: string | null; players: Record<string, PublicUser> }) {
|
||||
return (
|
||||
<ul className="stack" style={{ gap: 4, listStyle: 'none', padding: 0, margin: 0 }}>
|
||||
{v.seats.map((s) => (
|
||||
<li key={s.id} style={{ display: 'flex', justifyContent: 'space-between', opacity: s.status === 'out' || s.status === 'left' ? 0.5 : 1 }}>
|
||||
<span className="small" style={{ fontWeight: v.turn === s.id ? 800 : 500 }}>
|
||||
{s.id === me ? '나' : nick(players, s.id)}
|
||||
{s.status === 'out' && ' (칩 소진)'}
|
||||
{s.status === 'left' && ' (나감)'}
|
||||
</span>
|
||||
<span className="small muted">{formatChips(s.chips)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- options (room settings)
|
||||
|
||||
function Seg<T extends string | number | boolean | null>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
|
||||
return (
|
||||
<div className="segmented" role="group" aria-label={label}>
|
||||
{options.map(([k, l]) => (
|
||||
<button key={String(k)} type="button" aria-pressed={value === k} onClick={() => onChange(k)}>
|
||||
{l}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Field({ label, children, help }: { label: string; children: ReactNode; help?: string }) {
|
||||
return (
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<strong>{label}</strong>
|
||||
{children}
|
||||
{help && <span className="small muted">{help}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const onOff: [boolean, string][] = [
|
||||
[false, '끄기'],
|
||||
[true, '켜기'],
|
||||
];
|
||||
|
||||
function Options({ value: o, onChange }: OptionsProps<BlackjackOptions>) {
|
||||
const set = (patch: Partial<BlackjackOptions>) => onChange({ ...o, ...patch });
|
||||
return (
|
||||
<div className="stack" style={{ gap: 16 }}>
|
||||
<Field label="덱 수">
|
||||
<Seg label="덱 수" value={o.decks} options={[[1, '1벌'], [2, '2벌'], [4, '4벌'], [6, '6벌'], [8, '8벌']]} onChange={(decks) => set({ decks })} />
|
||||
</Field>
|
||||
<Field label="딜러 소프트 17" help={o.dealerSoft17 === 'stand' ? '딜러는 소프트 17에서 멈춰요(S17·공식).' : '딜러는 소프트 17에서 한 장 더 받아요(H17).'}>
|
||||
<Seg label="딜러 소프트 17" value={o.dealerSoft17} options={[['stand', '스탠드(S17)'], ['hit', '히트(H17)']]} onChange={(dealerSoft17) => set({ dealerSoft17 })} />
|
||||
</Field>
|
||||
<Field label="블랙잭 배당">
|
||||
<Seg label="블랙잭 배당" value={o.blackjackPayout} options={[['3:2', '3:2'], ['6:5', '6:5'], ['2:1', '2:1'], ['1:1', '1:1']]} onChange={(blackjackPayout) => set({ blackjackPayout })} />
|
||||
</Field>
|
||||
<Field label="더블다운">
|
||||
<Seg label="더블다운" value={o.doubleRule} options={[['any', '아무 두 장'], ['9to11', '9~11'], ['10to11', '10~11'], ['none', '안 함']]} onChange={(doubleRule) => set({ doubleRule })} />
|
||||
</Field>
|
||||
<Field label="스플릿 후 더블(DAS)">
|
||||
<Seg label="스플릿 후 더블" value={o.doubleAfterSplit} options={onOff} onChange={(doubleAfterSplit) => set({ doubleAfterSplit })} />
|
||||
</Field>
|
||||
<Field label="스플릿 최대 손패 수">
|
||||
<Seg label="스플릿 최대 손패 수" value={o.splitMaxHands} options={[[2, '2개'], [3, '3개'], [4, '4개']]} onChange={(splitMaxHands) => set({ splitMaxHands })} />
|
||||
</Field>
|
||||
<Field label="에이스 스플릿" help={o.hitSplitAces ? '에이스를 나눈 뒤에도 자유롭게 받을 수 있어요.' : '에이스를 나누면 각각 한 장만 받아요(공식).'}>
|
||||
<Seg label="에이스 스플릿 후" value={o.hitSplitAces} options={[[false, '한 장만'], [true, '자유 히트']]} onChange={(hitSplitAces) => set({ hitSplitAces })} />
|
||||
</Field>
|
||||
<Field label="에이스 다시 스플릿">
|
||||
<Seg label="에이스 다시 스플릿" value={o.resplitAces} options={onOff} onChange={(resplitAces) => set({ resplitAces })} />
|
||||
</Field>
|
||||
<Field label="서렌더" help={o.surrender === 'late' ? '딜러 블랙잭 확인 뒤 베팅 절반만 잃고 포기할 수 있어요.' : '서렌더가 없어요.'}>
|
||||
<Seg label="서렌더" value={o.surrender} options={[['none', '없음'], ['late', '레이트']]} onChange={(surrender) => set({ surrender })} />
|
||||
</Field>
|
||||
<Field label="인슈어런스(딜러 A일 때)">
|
||||
<Seg label="인슈어런스" value={o.insurance} options={onOff} onChange={(insurance) => set({ insurance })} />
|
||||
</Field>
|
||||
<Field label="(하우스 룰) 카드 찰리" help={o.charlie === 'off' ? '' : `${o.charlie === 'five' ? '5' : '6'}장까지 버스트하지 않으면 자동으로 이겨요.`}>
|
||||
<Seg label="카드 찰리" value={o.charlie} options={[['off', '없음'], ['six', '6장'], ['five', '5장']]} onChange={(charlie) => set({ charlie })} />
|
||||
</Field>
|
||||
<Field label="(하우스 룰) 7-7-7 보너스" help="7 세 장(21)이면 3:1로 받아요.">
|
||||
<Seg label="7-7-7 보너스" value={o.sevenTriple} options={onOff} onChange={(sevenTriple) => set({ sevenTriple })} />
|
||||
</Field>
|
||||
<Field label="시작 칩">
|
||||
<Seg label="시작 칩" value={o.startingChips} options={[[500, '500'], [1000, '1,000'], [2000, '2,000'], [5000, '5,000']]} onChange={(startingChips) => set({ startingChips })} />
|
||||
</Field>
|
||||
<Field label="최소 베팅(단위)">
|
||||
<Seg label="최소 베팅" value={o.minBet} options={[[10, '10'], [20, '20'], [50, '50'], [100, '100']]} onChange={(minBet) => set({ minBet })} />
|
||||
</Field>
|
||||
<Field label="게임 종료">
|
||||
<Seg label="게임 종료" value={o.endCondition} options={[['hands', '정해진 판 수'], ['lastStanding', '최후 1인']]} onChange={(endCondition) => set({ endCondition })} />
|
||||
</Field>
|
||||
{o.endCondition === 'hands' && (
|
||||
<Field label="판 수">
|
||||
<Seg label="판 수" value={o.handLimit} options={[[5, '5판'], [10, '10판'], [20, '20판'], [30, '30판']]} onChange={(handLimit) => set({ handLimit })} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label="행동 제한 시간">
|
||||
<Seg label="행동 제한 시간" value={o.turnSeconds} options={[[15, '15초'], [20, '20초'], [30, '30초'], [60, '60초'], [null, '무제한']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
</Field>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function optionsSummary(o: BlackjackOptions): string {
|
||||
const parts = [`${o.decks}벌`, `BJ ${o.blackjackPayout}`, o.dealerSoft17 === 'hit' ? 'H17' : 'S17'];
|
||||
if (o.charlie !== 'off') parts.push(o.charlie === 'five' ? '5카드 찰리' : '6카드 찰리');
|
||||
if (o.sevenTriple) parts.push('7트리플');
|
||||
if (o.surrender === 'late') parts.push('서렌더');
|
||||
parts.push(o.endCondition === 'hands' ? `${o.handLimit}판` : '최후 1인');
|
||||
parts.push(o.turnSeconds === null ? '시간 무제한' : `${o.turnSeconds}초`);
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- rules
|
||||
|
||||
function Rules({ options }: { options?: BlackjackOptions }) {
|
||||
const o: BlackjackOptions = {
|
||||
decks: 6, dealerSoft17: 'stand', blackjackPayout: '3:2', doubleRule: 'any', doubleAfterSplit: true, splitMaxHands: 4,
|
||||
resplitAces: false, hitSplitAces: false, surrender: 'none', insurance: true, charlie: 'off', sevenTriple: false,
|
||||
startingChips: 1000, minBet: 10, endCondition: 'hands', handLimit: 10, betSeconds: 20, turnSeconds: 20, handEndSeconds: 4, awaySeconds: 5,
|
||||
...(options ?? {}),
|
||||
};
|
||||
return (
|
||||
<div className="stack">
|
||||
<p>
|
||||
딜러를 상대로 카드 합을 <strong>21에 가깝게</strong> 만드는 게임이에요. 2~10은 숫자대로, J·Q·K는 10, A는 1이나 11 중 좋은 쪽으로 세요. 21을 넘으면(버스트) 바로 져요.
|
||||
</p>
|
||||
<p>
|
||||
먼저 베팅을 걸면 모두 두 장씩 받고, 딜러는 한 장을 펼치고 한 장을 가려요. 처음 두 장이 A+10이면 <strong>블랙잭</strong>(배당 {o.blackjackPayout})이에요.
|
||||
</p>
|
||||
<p>
|
||||
내 차례에 <strong>히트</strong>(한 장 더), <strong>스탠드</strong>(멈춤)를 골라요. 처음 두 장이면 <strong>더블</strong>(베팅 두 배, 한 장만){o.doubleRule === 'none' ? '은 꺼져 있어요' : o.doubleRule === 'any' ? '을 아무 때나' : `는 합 ${o.doubleRule === '9to11' ? '9~11' : '10~11'}에서만`} 할 수 있고, 같은 숫자 두 장이면 <strong>스플릿</strong>(최대 {o.splitMaxHands}손패)으로 나눠요{o.doubleAfterSplit ? '(스플릿 뒤에도 더블 가능)' : ''}. 에이스를 나누면 {o.hitSplitAces ? '자유롭게 더 받아요' : '각각 한 장만 받아요'}.
|
||||
</p>
|
||||
{o.surrender === 'late' && <p><strong>서렌더</strong>: 처음 두 장일 때 베팅 절반만 잃고 그 판을 포기할 수 있어요.</p>}
|
||||
{o.insurance && <p><strong>인슈어런스</strong>: 딜러가 A를 펼치면 베팅 절반을 더 걸 수 있어요. 딜러가 블랙잭이면 2:1로 돌려받고, 아니면 잃어요.</p>}
|
||||
<p>
|
||||
모두 멈추면 딜러가 가린 카드를 펼치고 <strong>{o.dealerSoft17 === 'hit' ? '소프트 17까지 받고' : '17 이상이면 멈추고'}</strong> 승부해요. 딜러가 버스트거나 내 수가 더 크면 1:1로 받고, 같으면 푸시(비김), 작으면 져요.
|
||||
</p>
|
||||
{o.charlie !== 'off' && <p><strong>카드 찰리</strong>(하우스 룰): 버스트하지 않고 {o.charlie === 'five' ? '5' : '6'}장을 모으면 자동으로 이겨요.</p>}
|
||||
{o.sevenTriple && <p><strong>7-7-7 보너스</strong>(하우스 룰): 7 세 장(21)이면 3:1로 받아요.</p>}
|
||||
<p>
|
||||
{o.endCondition === 'hands' ? `${o.handLimit}판을 치고 칩이 가장 많은 사람이 이겨요.` : '칩이 가장 많은 한 사람이 남을 때까지 해요.'}
|
||||
{o.turnSeconds === null ? ' 이 방은 행동 시간 제한이 없어요.' : ` 시간 안에 고르지 않으면 자동으로 멈춰요(스탠드).`}
|
||||
</p>
|
||||
<p className="small muted">{PLAYING_CARD_CREDIT}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const ui: GameUI<BlackjackView, BlackjackOptions> = {
|
||||
Board,
|
||||
Side,
|
||||
statusText,
|
||||
isMyTurn,
|
||||
Options,
|
||||
optionsSummary,
|
||||
Rules,
|
||||
quickStart,
|
||||
helpNow,
|
||||
};
|
||||
|
||||
export default ui;
|
||||
75
apps/web/src/games/blackjack/quick.tsx
Normal file
75
apps/web/src/games/blackjack/quick.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
/** 블랙잭 30초 규칙 요약 (docs/07 §5). */
|
||||
import type { QuickCard } from '../types';
|
||||
|
||||
/** A 46 × 64 card at (x, y) showing a rank + suit. */
|
||||
function Card({ r = '', s, x, y, down }: { r?: string; s?: string; x: number; y: number; down?: boolean }) {
|
||||
const red = s === '♥' || s === '◆';
|
||||
return (
|
||||
<g transform={`translate(${x} ${y})`}>
|
||||
<rect width={46} height={64} rx={7} fill={down ? '#1e3a8a' : '#fffef9'} stroke="#334155" strokeWidth={2} />
|
||||
{down ? (
|
||||
<rect x={6} y={6} width={34} height={52} rx={4} fill="none" stroke="#93c5fd" strokeWidth={2} strokeDasharray="4 3" />
|
||||
) : (
|
||||
<>
|
||||
<text x={8} y={20} fontSize={16} fontWeight={900} fill={red ? '#dc2626' : '#111827'}>
|
||||
{r}
|
||||
</text>
|
||||
<text x={23} y={46} textAnchor="middle" fontSize={22} fill={red ? '#dc2626' : '#111827'}>
|
||||
{s}
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
export const quickStart: QuickCard[] = [
|
||||
{
|
||||
pic: (
|
||||
<svg viewBox="0 0 250 150" width={250} height={150} aria-hidden>
|
||||
<text x={12} y={16} fontSize={12} fontWeight={800} fill="#6b7280">딜러</text>
|
||||
<Card r="K" s="♠" x={12} y={22} />
|
||||
<Card x={58} y={22} down />
|
||||
<text x={12} y={96} fontSize={12} fontWeight={800} fill="#6b7280">나 (합 20)</text>
|
||||
<Card r="10" s="♥" x={12} y={102} />
|
||||
<Card r="Q" s="♣" x={58} y={102} />
|
||||
<text x={150} y={78} fontSize={20} fontWeight={900} fill="#15803d">21에 가깝게!</text>
|
||||
</svg>
|
||||
),
|
||||
alt: '딜러는 카드 한 장을 가리고, 내 두 장은 합이 20',
|
||||
title: '딜러보다 21에 가깝게',
|
||||
text: '카드 두 장을 받아요. 2~10은 숫자대로, J·Q·K는 10, A는 1 또는 11. 21을 넘기면(버스트) 바로 져요.',
|
||||
},
|
||||
{
|
||||
pic: (
|
||||
<svg viewBox="0 0 250 120" width={250} height={120} aria-hidden>
|
||||
{['히트', '스탠드', '더블', '스플릿'].map((t, i) => (
|
||||
<g key={t} transform={`translate(${8 + i * 60} 40)`}>
|
||||
<rect width={52} height={40} rx={10} fill="#1d4ed8" />
|
||||
<text x={26} y={25} textAnchor="middle" fontSize={13} fontWeight={800} fill="#fff">
|
||||
{t}
|
||||
</text>
|
||||
</g>
|
||||
))}
|
||||
<text x={125} y={100} textAnchor="middle" fontSize={13} fill="#374151">한 장 더 받거나 멈추고, 두 배로 걸거나 쌍패를 나눠요</text>
|
||||
</svg>
|
||||
),
|
||||
alt: '히트·스탠드·더블·스플릿 버튼',
|
||||
title: '히트·스탠드·더블·스플릿',
|
||||
text: '내 차례에 히트(한 장 더), 스탠드(멈춤). 처음 두 장이면 더블(두 배로 걸고 한 장), 같은 숫자면 스플릿으로 두 손패로 나눠요.',
|
||||
},
|
||||
{
|
||||
pic: (
|
||||
<svg viewBox="0 0 250 120" width={250} height={120} aria-hidden>
|
||||
<Card r="A" s="♠" x={16} y={16} />
|
||||
<Card r="K" s="♥" x={58} y={16} />
|
||||
<text x={118} y={40} fontSize={15} fontWeight={900} fill="#b45309">블랙잭!</text>
|
||||
<text x={118} y={62} fontSize={14} fontWeight={800} fill="#15803d">3 : 2 배당</text>
|
||||
<text x={16} y={100} fontSize={13} fill="#374151">딜러는 17이 될 때까지 받고 멈춰요</text>
|
||||
</svg>
|
||||
),
|
||||
alt: 'A와 K로 만든 블랙잭은 3대 2 배당',
|
||||
title: '블랙잭은 3:2',
|
||||
text: '처음 두 장이 A+10이면 블랙잭(3:2). 다들 멈추면 딜러가 17까지 받아요. 딜러가 버스트거나 내 수가 더 크면 이겨요.',
|
||||
},
|
||||
];
|
||||
@@ -9,7 +9,7 @@ import { assertCleanText, eachView, seatIds, usersOf } from './help-kit.test-uti
|
||||
const IDS = Object.keys(GAME_UI);
|
||||
|
||||
test('모든 게임에 도움말이 있어요', () => {
|
||||
expect(IDS).toHaveLength(33);
|
||||
expect(IDS).toHaveLength(34);
|
||||
for (const id of IDS) {
|
||||
const src = readFileSync(join(import.meta.dir, id, 'index.tsx'), 'utf8');
|
||||
expect(src, id).toMatch(/\bquickStart,/);
|
||||
|
||||
@@ -35,6 +35,7 @@ export const GAME_UI: Record<string, () => Promise<{ default: GameUI }>> = {
|
||||
uno: () => import('./uno'),
|
||||
liar: () => import('./liar'),
|
||||
'magical-athlete': () => import('./magical-athlete'),
|
||||
blackjack: () => import('./blackjack'),
|
||||
};
|
||||
|
||||
const cache = new Map<string, GameUI>();
|
||||
|
||||
@@ -32,6 +32,7 @@ export const GAME_ICON: Record<string, string> = {
|
||||
uno: '🌈',
|
||||
liar: '🤥',
|
||||
'magical-athlete': '🏃',
|
||||
blackjack: '🂡',
|
||||
};
|
||||
|
||||
/** Shown on the home screen so users know what's coming (docs/12-roadmap.md). */
|
||||
@@ -40,6 +41,6 @@ export const UPCOMING: string[] = [];
|
||||
/** Tabs on the game picker (docs/07 §3.3). Games not listed here only show under 전체. */
|
||||
export const GAME_GROUPS: { key: string; label: string; ids: string[] }[] = [
|
||||
{ key: 'board', label: '판·주사위', ids: ['omok', 'connect-four', 'othello', 'chess', 'janggi', 'baduk', 'quoridor', 'yut', 'marble', 'yacht', 'las-vegas', 'magical-athlete', 'clue'] },
|
||||
{ key: 'cards', label: '카드·패', ids: ['seotda', 'poker', 'one-card', 'uno', 'gostop', 'dalmuti', 'splendor', 'cockroach-poker', 'ninety-nine', 'old-maid', 'mahjong', 'rummikub', 'davinci-code'] },
|
||||
{ key: 'cards', label: '카드·패', ids: ['seotda', 'poker', 'blackjack', 'one-card', 'uno', 'gostop', 'dalmuti', 'splendor', 'cockroach-poker', 'ninety-nine', 'old-maid', 'mahjong', 'rummikub', 'davinci-code'] },
|
||||
{ key: 'party', label: '여럿이 파티', ids: ['bang', 'halli-galli', 'dobble', 'catchmind', 'mafia', 'liar', 'apple'] },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user