From 28ef4ed947e1755c1dcf148cea7ad4ebb186bff0 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Mon, 19 Oct 2026 22:42:52 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9C=B7=EB=86=80=EC=9D=B4:=20=EC=A6=9D?= =?UTF-8?q?=EA=B0=95=20=EC=9C=B7=EB=86=80=EC=9D=B4=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(=EC=9B=90=EC=9E=91=20=EC=A6=9D=EA=B0=95?= =?UTF-8?q?=2071=EA=B0=9C=20+=20=EC=B6=94=EA=B0=80=2010=EA=B0=9C,=20?= =?UTF-8?q?=EC=A6=9D=EA=B0=95=20=ED=83=AD=C2=B7=EC=84=A0=ED=83=9D=20?= =?UTF-8?q?=EC=B0=BD=C2=B7=EB=8A=A5=EB=A0=A5=C2=B7=EC=95=8C=EA=B9=8C?= =?UTF-8?q?=EA=B8=B0=C2=B7=ED=8A=B9=EC=88=98=20=EC=8A=B9=EB=A6=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔진 aug.ts: 라운드·동시 비공개 증강 선택(1·6·12 등, 혼돈 모드, 후보 수, 제외 목록), 질문(거머리·접기·돌림판·투표·색 맞히기 등), 특수 말·보호막·함께 서기·함정/선물/똥/마늘/조준/지뢰, 특수 승리·탈락·순위, 컴퓨터(aug-bot.ts), 알까기 물리(physics.ts) - 화면: 방 설정 [게임 종류] + [증강 윷놀이] 탭(켜기/끄기·찾기), 증강 선택 창, 내 증강 쓰기, 증강 칸, 특수 승리 팝업, 안개, 알까기 조준 - 문서 docs/games/yut-augmented.md, 테스트 aug.test.ts 59개, e2e yut-aug Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- apps/web/src/games/yut/aug-options.tsx | 172 ++ apps/web/src/games/yut/aug-ui.tsx | 746 ++++++ apps/web/src/games/yut/help.ts | 11 + apps/web/src/games/yut/house-rules.ts | 3 + apps/web/src/games/yut/index.tsx | 230 +- apps/web/src/pages/RoomPage.tsx | 5 +- apps/web/src/pages/admin/SchemaForm.tsx | 22 +- docs/games/README.md | 2 +- docs/games/yut-augmented.md | 174 ++ docs/games/yut.md | 2 + e2e/games.e2e.ts | 156 ++ packages/games/package.json | 2 + packages/games/src/yut/aug-bot.ts | 179 ++ packages/games/src/yut/aug.test.ts | 693 +++++ packages/games/src/yut/aug.ts | 3085 +++++++++++++++++++++++ packages/games/src/yut/augments.ts | 156 ++ packages/games/src/yut/board.ts | 75 + packages/games/src/yut/bot.ts | 5 + packages/games/src/yut/index.ts | 127 +- packages/games/src/yut/physics.ts | 122 + 21 files changed, 5928 insertions(+), 41 deletions(-) create mode 100644 apps/web/src/games/yut/aug-options.tsx create mode 100644 apps/web/src/games/yut/aug-ui.tsx create mode 100644 docs/games/yut-augmented.md create mode 100644 packages/games/src/yut/aug-bot.ts create mode 100644 packages/games/src/yut/aug.test.ts create mode 100644 packages/games/src/yut/aug.ts create mode 100644 packages/games/src/yut/augments.ts create mode 100644 packages/games/src/yut/physics.ts diff --git a/README.md b/README.md index 343fe20..b541baf 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ |---|---| | 2인 수 싸움 | 오목, 커넥트 포(사목), 오셀로, 체스(체스960 포함), 장기, 바둑, 쿼리도(2·4명) | | 카드·화투 | 원카드, 우노, 도둑잡기, 섯다, 포커, 블랙잭, 고스톱, 달무티, 티츄, 젝스님트, 구십구, 바퀴벌레 포커, 뱅! | -| 타일·주사위·판 | 루미큐브, 다빈치 코드, 마작, 요트 다이스, 윷놀이(지역 룰 선택), 라스베가스, 부루마불, 스플렌더, 야단법석 달리기, 클루, 젬블로, 버건디의 성 | +| 타일·주사위·판 | 루미큐브, 다빈치 코드, 마작, 요트 다이스, 윷놀이(지역 룰 선택, 증강 윷놀이), 라스베가스, 부루마불, 스플렌더, 야단법석 달리기, 클루, 젬블로, 버건디의 성 | | 순발력·대화·파티 | 할리갈리, 도블, 그림 맞히기, 사과 게임, 마피아, 라이어 게임, 핫스트릭, 사건 파일(협력 추리) | 칩·포인트·지폐, 섯다의 "원"은 모두 놀이용이다(실제 돈과 무관, 충전·환전 없음). diff --git a/apps/web/src/games/yut/aug-options.tsx b/apps/web/src/games/yut/aug-options.tsx new file mode 100644 index 0000000..b8d38f9 --- /dev/null +++ b/apps/web/src/games/yut/aug-options.tsx @@ -0,0 +1,172 @@ +/** 증강 윷놀이 방 설정 (docs/games/yut-augmented.md): 혼돈 모드, 고르는 라운드, 후보 수, 나오게 할 증강 목록. */ +import { useState } from 'react'; +import type { YutOptions } from '@bg/games/yut'; +import { AUGS, AUG_IDS, AUG_ROUNDS, KIND_KO, TIER_KO, selectionTier, type AugId, type AugRoundsKey, type AugTier } from '@bg/games/yut/augments'; + +const CATS: { key: string; title: string; ids: AugId[] }[] = [ + { key: 'any', title: '범용', ids: AUG_IDS.filter((id) => AUGS[id].tier === 'any' && !AUGS[id].custom) }, + { key: 'start', title: '시작 전용', ids: AUG_IDS.filter((id) => AUGS[id].tier === 'start' && !AUGS[id].custom) }, + { key: 'mid', title: '중간 전용', ids: AUG_IDS.filter((id) => AUGS[id].tier === 'mid' && !AUGS[id].custom) }, + { key: 'final', title: '마무리 전용', ids: AUG_IDS.filter((id) => AUGS[id].tier === 'final' && !AUGS[id].custom) }, + { key: 'custom', title: '이 사이트 추가', ids: AUG_IDS.filter((id) => AUGS[id].custom) }, +]; +const WIN_IDS = AUG_IDS.filter((id) => AUGS[id].win); +const CUSTOM_IDS = AUG_IDS.filter((id) => AUGS[id].custom); +const ROUND_LABELS: Record = { standard: '1·6·12라운드', quick: '1·4·8라운드', many: '1·3·5·7·9라운드' }; + +const AUG_CSS = ` +.yut-aug-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } +.yut-aug-cat { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 10px; border: 1px dashed var(--border); border-radius: 12px; min-width: 0; } +.yut-aug-cat-head { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; } +.yut-aug-cat-head strong { margin-right: auto; } +.yut-aug-row { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; min-width: 0; } +.yut-aug-row.off { opacity: .6; } +.yut-aug-row input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); } +.yut-aug-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; } +.yut-aug-name { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-weight: 700; } +.yut-aug-badge { border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; background: var(--primary-soft); color: var(--text); white-space: nowrap; } +.yut-aug-badge.win { background: var(--warning-soft, var(--primary-soft)); } +.yut-aug-warn { color: var(--danger); } +`; + +function Seg({ value, options, onChange }: { value: T; options: [T, string][]; onChange: (v: T) => void }) { + return ( +
+ {options.map(([k, l]) => ( + + ))} +
+ ); +} + +function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) { + return ( +
+ {label} + {children} + {hint && {hint}} +
+ ); +} + +export function AugOptions({ value: o, onChange }: { value: YutOptions; onChange: (patch: Partial) => void }) { + const [query, setQuery] = useState(''); + const [open, setOpen] = useState>({}); + const off = new Set(o.augOff ?? []); + /** Keep `augOff` in AUG_IDS order so the value is stable. */ + const setOff = (next: Set) => onChange({ augOff: AUG_IDS.filter((id) => next.has(id)) }); + const toggle = (id: AugId) => { + const next = new Set(off); + if (next.has(id)) next.delete(id); + else next.add(id); + setOff(next); + }; + const setMany = (ids: readonly AugId[], on: boolean) => { + const next = new Set(off); + for (const id of ids) { + if (on) next.delete(id); + else next.add(id); + } + setOff(next); + }; + + const roundsKey: AugRoundsKey = o.augRounds ?? 'standard'; + const n = AUG_ROUNDS[roundsKey].length; + const tiers = [...new Set(Array.from({ length: n }, (_, i) => selectionTier(i, n)))]; + const warnings = tiers.flatMap((t: Exclude) => { + const c = AUG_IDS.filter((id) => !off.has(id) && (AUGS[id].tier === 'any' || AUGS[id].tier === t)).length; + return c < 3 ? [`${TIER_KO[t]} 선택 때 나올 수 있는 증강이 ${c}개뿐이에요(범용 + ${TIER_KO[t]}). 후보가 적게 나오거나 아예 안 나올 수 있어요.`] : []; + }); + + const q = query.trim().toLowerCase(); + const match = (id: AugId) => !q || AUGS[id].name.toLowerCase().includes(q) || AUGS[id].text.toLowerCase().includes(q); + const onCount = AUG_IDS.length - off.size; + + return ( +
+ + + onChange({ augChaos: k === 'on' })} /> + + + [k, ROUND_LABELS[k]])} onChange={(augRounds) => onChange({ augRounds })} /> + + + onChange({ augOffers })} /> + +
+ + 나오게 할 증강 켜진 증강 {onCount}/{AUG_IDS.length} + + 끈 증강은 후보에 나오지 않아요. + setQuery(e.target.value)} /> +
+ + + +
+ {warnings.map((w) => ( + + ⚠ {w} + + ))} + {CATS.map((cat) => { + const shown = cat.ids.filter(match); + if (!shown.length) return null; + const on = cat.ids.filter((id) => !off.has(id)).length; + const showRows = !!q || !!open[cat.key]; + return ( +
+
+ + + +
+ {showRows && shown.map((id) => { + const a = AUGS[id]; + const enabled = !off.has(id); + return ( + + ); + })} +
+ ); + })} + {q && CATS.every((c) => !c.ids.some(match)) && '{query.trim()}'에 맞는 증강이 없어요.} +
+
+ ); +} diff --git a/apps/web/src/games/yut/aug-ui.tsx b/apps/web/src/games/yut/aug-ui.tsx new file mode 100644 index 0000000..7d173c1 --- /dev/null +++ b/apps/web/src/games/yut/aug-ui.tsx @@ -0,0 +1,746 @@ +/** + * 증강 윷놀이 screen parts (docs/games/yut-augmented.md §화면): augment selection, prompts, popups, the "내 증강" panel, + * board objects, fog, special-piece badges and the 알까기 aim / replay. Used by index.tsx only when `view.aug` exists. + */ +import { useEffect, useMemo, useRef, useState } from 'react'; +import type { AugFx, AugUseOption, PieceKind, YutAugView, YutView } from '@bg/games/yut'; +import { AUGS, KIND_KO, TIER_KO, type AugId } from '@bg/games/yut/augments'; +import { NODE_POS } from '@bg/games/yut/board'; +import type { PublicUser } from '@bg/shared/lite'; +import { Sheet } from '../../components/ui'; +import { haptic, sounds } from '../../lib/feedback'; +import { fxMs } from '../../lib/motion'; + +type Act = (a: unknown) => void; +const nick = (players: Record, id: string | undefined) => (id ? (players[id]?.nickname ?? '알 수 없음') : '알 수 없음'); +const SOLO = ['빨강', '파랑', '초록', '노랑']; +const COLORS = ['#dc2626', '#2563eb', '#16a34a', '#eab308']; +export const augSideName = (side: number) => SOLO[side] ?? '?'; +const playerOf = (v: YutView, side: number) => v.sides[side]?.members[0]; +const who = (v: YutView, players: Record, side: number) => { + const p = playerOf(v, side); + return p ? `${nick(players, p)}(${augSideName(side)})` : augSideName(side); +}; + +export const AUG_CSS = ` +.aug-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 2px 8px; border-radius: 10px; border: 2px solid var(--border); + background: var(--surface-2, var(--surface)); font-size: .8rem; font-weight: 700; line-height: 1.15; position: relative; max-width: 100%; } +.aug-chip.used { opacity: .6; } +.aug-chip.used::after { content: '✔'; position: absolute; right: -6px; top: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-size: .7rem; display: grid; place-items: center; } +.aug-chip.voided { text-decoration: line-through; opacity: .5; } +.aug-chip.cat { border-style: dashed; } +.aug-chip small { font-weight: 600; color: var(--text-sub); } +.aug-chip.win { border-color: #f59e0b; } +.aug-slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; } +.aug-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; } +.aug-card { text-align: left; border: 3px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 10px 12px; cursor: pointer; + display: flex; flex-direction: column; gap: 6px; min-height: 120px; font: inherit; } +.aug-card[aria-pressed='true'] { border-color: var(--primary); background: var(--primary-soft); } +.aug-card:disabled { cursor: not-allowed; opacity: .55; } +.aug-card h3 { margin: 0; font-size: 1.05rem; } +.aug-card p { margin: 0; font-size: .9rem; } +.aug-tags { display: flex; gap: 4px; flex-wrap: wrap; } +.aug-tag { font-size: .7rem; font-weight: 800; border-radius: 999px; padding: 1px 7px; background: var(--primary-soft); color: var(--text); } +.aug-tag.win { background: #fde68a; color: #78350f; } +.aug-tag.custom { background: #ddd6fe; color: #4c1d95; } +.aug-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-weight: 700; } +.aug-bar .muted { font-weight: 600; } +.aug-popup { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; } +.aug-popup .kicker { color: var(--danger); font-weight: 800; } +.aug-popup h2 { margin: 0; font-size: 2rem; } +.aug-toast { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; max-width: 92%; background: rgba(17, 24, 39, .88); color: #fff; + padding: 8px 14px; border-radius: 12px; font-weight: 700; font-size: .92rem; text-align: center; pointer-events: none; animation: aug-toast 3.2s ease both; } +@keyframes aug-toast { 0% { opacity: 0; transform: translate(-50%, 6px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } } +.aug-uses { display: flex; flex-direction: column; gap: 8px; } +.aug-use-row { display: flex; flex-wrap: wrap; gap: 6px; } +.aug-target-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow: auto; } +.aug-target-list .btn { min-height: 44px; } +.aug-plan { display: flex; flex-wrap: wrap; gap: 8px; } +.aug-board-wrap { position: relative; } +.aug-aim { touch-action: none; cursor: crosshair; } +.sheet:has(.aug-cards) { width: min(100%, 780px); } +@media (prefers-reduced-motion: reduce) { .aug-toast { animation: none; } } +`; + +// ---------------------------------------------------------------- round bar + +export function AugRoundBar({ v }: { v: YutView }) { + const a = v.aug!; + const next = a.rounds[a.selectNo]; + return ( +
+ 🌀 {a.round}라운드 + {next !== undefined ? `다음 증강 선택: ${next}라운드` : '증강 선택 끝'} + {a.echo && 메아리: 차례 두 번씩} + {a.fogOwner !== null && 🌫 안개} + {a.winsOff && 특수 승리 취소됨} +
+ ); +} + +// ---------------------------------------------------------------- slots in the side card + +export function AugSlots({ v, side }: { v: YutView; side: number }) { + const s = v.aug?.sides.find((x) => x.id === side); + if (!s) return null; + const info: string[] = []; + if (s.sticks !== 4) info.push(`윷가락 ${s.sticks}개`); + if (s.skip) info.push(`건너뛰기 ${s.skip}번`); + if (s.hp !== null) info.push(`체력 ${'❤'.repeat(Math.max(0, s.hp))}${s.hp <= 0 ? '0' : ''}`); + if (s.queenLives !== null) info.push(`👑 목숨 ${s.queenLives}`); + for (const l of s.links) info.push(`${l.by === 'leech' ? '🩸 거머리' : '💀 네크로'} → ${augSideName(l.to)}`); + return ( + <> + {info.length > 0 &&
{info.join(' · ')}
} +
+ {s.augs.length === 0 && 증강 없음} + {s.augs.map((o) => { + const meta = AUGS[o.id]; + const cat = o.catUntil !== null; + return ( + + {cat ? '🐱 ' : ''} + {meta.name} + {o.note && {o.note}} + + ); + })} +
+ + ); +} + +// ---------------------------------------------------------------- selection + +function AugCard({ id, picked, onPick, disabled }: { id: AugId; picked: boolean; onPick: () => void; disabled?: boolean }) { + const m = AUGS[id]; + return ( + + ); +} + +export function AugSelect({ v, act, pending, players }: { v: YutView; act: Act; pending: boolean; players: Record }) { + const sel = v.aug!.select!; + const [choice, setChoice] = useState(null); + const [target, setTarget] = useState(''); + const [open, setOpen] = useState(true); + const mine = sel.offers.length > 0 && sel.picksLeft > 0; + const key = sel.offers.join(','); + useEffect(() => { + setChoice(sel.forced); + setTarget(''); + if (mine) setOpen(true); + }, [key]); // eslint-disable-line react-hooks/exhaustive-deps + const tierText = { start: '범용 + 시작 전용', mid: '범용 + 중간 전용', final: '범용 + 마무리 전용' }[sel.tier]; + const targets = choice === 'detective' ? sel.detectiveTargets : choice === 'delivery' ? sel.deliveryTargets : []; + const needTarget = choice === 'detective' || (choice === 'delivery' && targets.length > 0); + const waiting = sel.waiting.map((s) => who(v, players, s)).join(', '); + if (!mine) { + return ( +
+ {v.aug!.round}라운드 증강 선택 중 +
{waiting ? `${waiting}님이 고르는 중이에요.` : '곧 끝나요.'}
+
+ ); + } + const confirm = () => { + if (!choice || (needTarget && !target)) return; + act({ type: 'AUG_PICK', aug: choice, ...(needTarget ? { target } : {}) }); + haptic(30); + }; + return ( + <> +
+ 🎁 증강을 골라 주세요{sel.picksLeft > 1 ? ` (혼돈 모드: ${sel.picksLeft}개 남음)` : ''} + +
+ {open && ( + setOpen(false)} label={`${v.aug!.round}라운드 증강 선택`}> +
+

{v.aug!.round}라운드 증강 선택

+ + 이 후보와 고른 것은 나에게만 보여요. {sel.offers.length}개 중 하나를 고르세요. ({tierText}) + + {sel.forced && 간택: 고양이가 나와서 고양이를 골라야 해요!} +
+
+ {sel.offers.map((id) => ( + (setChoice(id), setTarget(''))} /> + ))} +
+ {needTarget && ( + + )} +
+ + +
+
+ )} + + ); +} + +// ---------------------------------------------------------------- prompts + +const PROMPT_TITLE: Record['kind'], string> = { + leech: '거머리: 누구에게 말을 줄까요?', + fold: '게임 접어라: 어느 쪽으로 접을까요?', + whoami: '나 누구게? 내 색은 무엇일까요?', + vote: '내려: 누가 차례를 건너뛸까요?', + roulette: '돌려돌려 돌림판', + illusion: '언제부터 착각한 거지? 어떤 증강을 고양이로 바꿀까요?', + plan: '계획대로: 최종 순위를 예언해 주세요', + duel: '승부다! 누구와 겨룰까요?', + thief: '손버릇: 어떤 증강을 빼앗을까요?', +}; + +export function AugPrompt({ v, act, pending, players }: { v: YutView; act: Act; pending: boolean; players: Record }) { + const pr = v.aug!.prompt!; + const [plan, setPlan] = useState([]); + const owner = who(v, players, pr.owner); + if (!pr.choices) { + return ( +
+ {PROMPT_TITLE[pr.kind].split(':')[0]} +
+ {pr.kind === 'whoami' || pr.kind === 'vote' ? `${pr.waiting.length}명이 고르는 중이에요.` : `${v.aug!.hidden ? '누군가' : owner}님이 고르는 중이에요.`} +
+
+ ); + } + const send = (choice: number | number[]) => act({ type: 'AUG_ANSWER', choice }); + if (pr.kind === 'plan') { + const all = pr.choices; + return ( +
+ {PROMPT_TITLE.plan} + 1등부터 차례로 눌러 주세요. 모두 맞히면 나 혼자 이겨요. +
+ {all.map((c) => { + const i = plan.indexOf(c.value); + return ( + + ); + })} +
+ +
+ ); + } + return ( +
+ {PROMPT_TITLE[pr.kind]} + {pr.kind === 'roulette' && ( + + 돌림판 결과: {(pr.spin ?? 1) * 90}도 돌아가요. {pr.canRespin ? '마음에 안 들면 한 번 더 돌릴 수 있어요.' : '이제 그대로 돌아가요.'} + + )} + {pr.kind === 'whoami' && 말 색이 모두 가려졌어요. 내 말이 어디 있었는지 떠올려 보세요. 틀리면 차례를 한 번 건너뛰어요.} + {pr.kind === 'vote' && 표를 가장 많이 받은 사람이 차례를 건너뛰어요. {augSideName(pr.owner)}의 표는 2표예요.} +
+ {pr.choices.map((c) => ( + + ))} +
+
+ ); +} + +// ---------------------------------------------------------------- popups & toasts + +/** Shows each new effect once: a dialog for victories / going out, a short toast for the rest. */ +export function AugFxLayer({ v, players, me }: { v: YutView; players: Record; me: string | null }) { + const fx = v.aug?.fx ?? []; + const seen = useRef(fx.reduce((m, f) => Math.max(m, f.no), 0)); + const [popup, setPopup] = useState(null); + const [toast, setToast] = useState<{ key: number; text: string } | null>(null); + useEffect(() => { + const fresh = fx.filter((f) => f.no > seen.current); + if (!fresh.length) return; + seen.current = Math.max(...fresh.map((f) => f.no)); + // When the game just ended the result window says it all. + const big = v.phase === 'finished' ? undefined : fresh.find((f) => f.kind === 'win' || f.kind === 'out' || f.kind === 'bronze'); + if (big) { + setPopup(big); + const mine = playerOf(v, big.side) === me; + if (big.kind === 'out') (mine ? sounds.lose : sounds.buzz)(); + else (mine ? sounds.win : sounds.ding)(); + } + const small = fresh.filter((f) => f !== big && f.kind !== 'flick'); + if (small.length) setToast({ key: small[small.length - 1]!.no, text: small.map((f) => f.text).join(' · ') }); + }, [fx.map((f) => f.no).join(',')]); // eslint-disable-line react-hooks/exhaustive-deps + useEffect(() => { + if (!toast) return; + const t = setTimeout(() => setToast(null), fxMs(3200)); + return () => clearTimeout(t); + }, [toast]); + return ( + <> + {toast && ( +
+ {toast.text} +
+ )} + {popup && ( + setPopup(null)} label="증강 알림"> +
+ {popup.kind === 'out' ? '탈락' : popup.kind === 'bronze' ? '3위 확정' : popup.aug ? '특수 승리 조건 달성' : '완주'} +

{popup.aug ? AUGS[popup.aug].name : popup.kind === 'out' ? '탈락' : '전원 완주'}

+ {who(v, players, popup.side)} +

{popup.text}

+ +
+
+ )} + + ); +} + +// ---------------------------------------------------------------- my augments panel + +export interface AimState { + uid: number; + piece: number; + at: number; + angle: number; + power: number; +} + +/** Ability buttons for the player to move; node-target choices can also be tapped on the board (`onTargets`). */ +export function AugUses({ + v, + act, + pending, + aim, + setAim, + targetUid, + setTargetUid, +}: { + v: YutView; + act: Act; + pending: boolean; + aim: AimState | null; + setAim: (a: AimState | null) => void; + targetUid: number | null; + setTargetUid: (u: number | null) => void; +}) { + const a = v.aug!; + const byUid = useMemo(() => { + const m = new Map(); + for (const u of a.uses) m.set(u.uid, [...(m.get(u.uid) ?? []), u]); + return m; + }, [a.uses]); + const specials = a.specials; + if (!byUid.size && !specials.length) return null; + const use = (u: AugUseOption) => { + if (u.id === 'alkkagi') { + if (u.at === undefined || u.at === 'home') return; + setAim({ uid: u.uid, piece: u.action.piece!, at: u.at, angle: 270, power: 60 }); + return; + } + act({ type: 'AUG_USE', ...u.action }); + setTargetUid(null); + haptic(30); + }; + const open = targetUid !== null ? (byUid.get(targetUid) ?? []) : []; + return ( +
+ ✨ 내 증강 쓰기 +
+ {[...byUid.entries()].map(([uid, opts]) => { + const id = opts[0]!.id; + return ( + + ); + })} +
+ {open.length > 0 && !aim && ( +
+ + {AUGS[open[0]!.id].text} + {AUGS[open[0]!.id].wholeTurn ? ' (쓰면 이번 차례가 끝나요)' : ''} + {open.some((o) => o.action.node !== undefined && o.action.piece === undefined && o.action.node2 === undefined) ? ' 판에서 칸을 눌러도 돼요.' : ''} + + {open.length > 8 ? ( + + ) : ( +
+ {open.map((u, i) => ( + + ))} +
+ )} + +
+ )} + {aim && ( +
+ 🎯 판에서 말 반대쪽으로 끌었다 놓아 방향과 힘을 정하세요(새총처럼). 아래에서 조절해도 돼요. + + +
+ + +
+
+ )} + {specials.length > 0 && ( +
+ 특수 말 움직이기 (던지지 않고 한 번) +
+ {specials.map((m, i) => ( + + ))} +
+
+ )} +
+ ); +} + +/** Long target lists (명사수: every node): a select + button. */ +function ManyTargets({ opts, pending, onUse }: { opts: AugUseOption[]; pending: boolean; onUse: (u: AugUseOption) => void }) { + const [i, setI] = useState(0); + return ( +
+ + +
+ ); +} + +const NODE_KO = ['참먹이', '도', '개', '걸', '윷', '모', '뒷도', '뒷개', '뒷걸', '뒷윷', '뒷모', '찌도', '찌개', '찌걸', '찌윷', '찌모', '날도', '날개', '날걸', '날윷', '앞모도', '앞모개', '방', '속윷', '속모', '뒷모도', '뒷모개', '사려', '안찌']; +const nodeKo = (n: number | 'home' | 'goal') => (n === 'home' ? '대기' : n === 'goal' ? '남' : (NODE_KO[n] ?? String(n))); + +// ---------------------------------------------------------------- board layers (inside the board ) + +export const KIND_ICON: Record = { dokkaebi: '👹', vanguard: '🚩', cannon: '包', pawn: '♟', kim: '🧔', queen: '👑', cultist: '🕯', marathon: '🏃' }; +const OBJ_ICON = { skull: '💀', hat: '🎩', gift: '🎁', poop: '💩', garlic: '🧄', mark: '🎯', mine: '💣' } as const; +const OBJ_KO = { skull: '해골 함정', hat: '마녀 모자 함정', gift: '선물', poop: '똥', garlic: '마늘', mark: '명사수 조준', mine: '지뢰' } as const; + +export function BoardObjects({ v }: { v: YutView }) { + return ( + + {v.aug!.objs.map((o, i) => { + const [x, y] = NODE_POS[o.node]!; + return ( + + = 0 ? COLORS[o.owner] : 'var(--wood-line)'} strokeWidth={0.6} opacity={0.95} /> + + {OBJ_ICON[o.kind]} + + + ); + })} + + ); +} + +/** Badge on a token for special pieces, shields and frozen pieces. */ +export function TokenBadges({ x, y, r, kind, shield, frozen }: { x: number; y: number; r: number; kind?: PieceKind; shield?: boolean; frozen?: boolean }) { + return ( + + {shield && } + {kind && ( + + {KIND_ICON[kind]} + + )} + {frozen && ( + + ❄ + + )} + + ); +} + +/** 안개: everything but the nodes near my pieces is covered. */ +export function FogLayer({ v }: { v: YutView }) { + const a = v.aug!; + if (!a.fogged) return null; + const mine = v.stacks.filter((st) => st.side === v.mySide).map((st) => st.node); + const near = new Set(mine); + const NB: Record = {}; + const lines: number[][] = [[0, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15], [15, 16, 17, 18, 19, 0], [5, 20, 21, 22, 23, 24, 15], [10, 25, 26, 22, 27, 28, 0]]; + for (const l of lines) for (let i = 0; i + 1 < l.length; i++) ((NB[l[i]!] ??= []).push(l[i + 1]!), (NB[l[i + 1]!] ??= []).push(l[i]!)); + for (const n of mine) for (const m of NB[n] ?? []) near.add(m); + return ( + + + + + {[...near].map((n) => ( + + ))} + + + + + 🌫 안개 + + + ); +} + +/** Replays the last 알까기 (frames from the server). */ +export function FlickReplay({ v, draw }: { v: YutView; draw: (side: number, x: number, y: number, count: number, key: string) => React.ReactNode }) { + const f = (v.aug?.fx ?? []).find((x) => x.kind === 'flick' && x.bodies?.length); + const [t, setT] = useState(-1); + const seen = useRef(f?.no ?? 0); + useEffect(() => { + if (!f || f.no === seen.current) return; + seen.current = f.no; + const len = Math.max(...f.bodies!.map((b) => b.pts.length)); + let i = 0; + setT(0); + const id = setInterval(() => { + i += 1; + if (i >= len + 8) { + clearInterval(id); + setT(-1); + } else setT(i); + }, fxMs(33)); + return () => clearInterval(id); + }, [f?.no]); // eslint-disable-line react-hooks/exhaustive-deps + if (!f || t < 0) return null; + return ( + + {f.bodies!.map((b, i) => { + const p = b.pts[Math.min(t, b.pts.length - 1)]; + if (!p) return null; + const gone = b.out && t >= b.pts.length - 1; + return {draw(b.side, p[0], p[1], b.count, `fl${i}`)}; + })} + + ); +} + +/** Slingshot aim: drag away from the piece; the arrow shows where it flies. */ +export function FlickAim({ aim, setAim, svg }: { aim: AimState; setAim: (a: AimState) => void; svg: React.RefObject }) { + const [cx, cy] = NODE_POS[aim.at]!; + const dragging = useRef(false); + const toBoard = (e: React.PointerEvent) => { + const el = svg.current; + if (!el) return null; + const pt = el.createSVGPoint(); + pt.x = e.clientX; + pt.y = e.clientY; + const m = el.getScreenCTM(); + if (!m) return null; + const p = pt.matrixTransform(m.inverse()); + return [p.x, p.y] as const; + }; + const update = (e: React.PointerEvent) => { + const p = toBoard(e); + if (!p) return; + const dx = cx - p[0]; + const dy = cy - p[1]; + const len = Math.hypot(dx, dy); + if (len < 1) return; + const angle = Math.round(((Math.atan2(dy, dx) * 180) / Math.PI + 360) % 360) % 360; + const power = Math.max(1, Math.min(100, Math.round((len / 30) * 100))); + setAim({ ...aim, angle, power }); + }; + const rad = (aim.angle * Math.PI) / 180; + const L = 6 + (aim.power / 100) * 26; + const tx = cx + Math.cos(rad) * L; + const ty = cy + Math.sin(rad) * L; + const bx = cx - Math.cos(rad) * (L * 0.5); + const by = cy - Math.sin(rad) * (L * 0.5); + return ( + + { + dragging.current = true; + (e.target as Element).setPointerCapture?.(e.pointerId); + update(e); + }} + onPointerMove={(e) => dragging.current && update(e)} + onPointerUp={() => (dragging.current = false)} + aria-label="알까기 조준: 말 반대쪽으로 끌어서 방향과 힘을 정해요" + /> + + + + + + ); +} + +/** Node targets of the opened ability (명사수, 지뢰, …): tap a highlighted node to choose it. */ +export function NodeTargets({ opts, onPick }: { opts: AugUseOption[]; onPick: (u: AugUseOption) => void }) { + const nodeOpts = opts.filter((o) => o.action.node !== undefined && o.action.piece === undefined && o.action.node2 === undefined); + const pieceOpts = opts.filter((o) => o.at !== undefined && o.at !== 'home' && o.action.node === undefined && o.action.node2 === undefined && o.action.target === undefined); + const pts = [...nodeOpts.map((o) => ({ o, n: o.action.node! })), ...pieceOpts.map((o) => ({ o, n: o.at as number }))]; + return ( + + {pts.map(({ o, n }, i) => { + const [x, y] = NODE_POS[n]!; + return ( + onPick(o)} onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && (e.preventDefault(), onPick(o))}> + + + + ); + })} + + ); +} + +// ---------------------------------------------------------------- log & status + +/** Log line for 증강 events (null = not an augment event). */ +export function augLogLine(e: { type: string; [k: string]: unknown }, v: YutView, players: Record): string | null | undefined { + const sn = (s: unknown) => (typeof s === 'number' && s >= 0 ? augSideName(s) : '누군가'); + switch (e.type) { + case 'augSelect': + return `🎁 ${e.round}라운드: 증강을 골라요`; + case 'augPicked': + return `${sn(e.side)}: [${AUGS[e.aug as AugId]?.name ?? ''}]${e.voided ? ' — 명탐정에게 걸려 무효!' : ' 획득'}`; + case 'augEffect': + return String(e.text ?? ''); + case 'augCaught': + return `${e.side === null || e.side === undefined ? '' : `${sn(e.side)}이 `}${sn(e.victimSide)} 말 ${e.count}개를 잡았어요${e.aug ? ` (${AUGS[e.aug as AugId]?.name ?? ''})` : ''}`; + case 'augShield': + return `${sn(e.side)}: 보호막이 한 번 막았어요`; + case 'augOut': + return `${sn(e.side)} 탈락! (${e.reason})`; + case 'augSkip': + return `${sn(e.side)}: 차례를 건너뛰어요`; + case 'sideFinished': + return e.aug ? `${sn(e.side)} ${e.rank}위! (${AUGS[e.aug as AugId]?.name ?? ''})` : undefined; + case 'moved': + return e.fog ? `${sn(e.side)}: 안개 속에서 말을 움직였어요` : undefined; + case 'hidden': + return null; + case 'turnChanged': + return null; + } + void v; + void players; + return undefined; +} + +export function augStatus(v: YutView, me: string | null, players: Record): string | null { + const a = v.aug; + if (!a) return null; + if (v.phase === 'aug' && a.select) return a.select.offers.length && a.select.picksLeft ? `${a.round}라운드: 증강을 골라 주세요` : `${a.round}라운드: 다른 사람이 증강을 고르는 중이에요`; + if (v.phase === 'prompt' && a.prompt) { + if (a.prompt.choices) return PROMPT_TITLE[a.prompt.kind]; + return `${a.hidden ? '누군가' : who(v, players, a.prompt.owner)}의 증강: 고르는 중이에요`; + } + void me; + return null; +} diff --git a/apps/web/src/games/yut/help.ts b/apps/web/src/games/yut/help.ts index bcfb649..9c162f9 100644 --- a/apps/web/src/games/yut/help.ts +++ b/apps/web/src/games/yut/help.ts @@ -21,6 +21,15 @@ function throwReason(v: YutView): 'fresh' | 'yutmo' | 'capture' | 'backdo' { export function helpNow(v: YutView, me: string | null, players: Record): string { const goal = '내 말을 모두 먼저 한 바퀴 돌려 판 밖으로 내보내면(날) 이겨요.'; if (v.phase === 'finished') return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n결과 창에서 [한 판 더]를 누르면 다시 할 수 있어요.'; + if (v.aug) { + const a = v.aug; + if (v.phase === 'aug' && a.select) { + return a.select.offers.length && a.select.picksLeft + ? `${a.round}라운드 증강 선택이에요. [증강 후보 보기]를 눌러 후보 중 하나를 고르고 확인을 누르세요. 후보와 고른 것은 나에게만 보여요.\n증강은 규칙을 바꾸거나(규칙), 바로 효과가 나거나(즉시), 내 차례에 버튼으로 쓰거나(사용), 특별한 방법으로 이기게 해 줘요(승리 조건).` + : `${a.round}라운드 증강 선택이에요. 다른 사람이 고를 때까지 기다려 주세요.`; + } + if (v.phase === 'prompt' && a.prompt) return a.prompt.choices ? '증강 효과 때문에 하나를 골라야 해요. 오른쪽(휴대폰은 아래)의 선택지에서 골라 주세요.' : '다른 사람이 증강 효과를 고르는 중이에요. 기다려 주세요.'; + } const turnSide = v.sides[v.turnSide]; const sideTag = turnSide ? `(${turnSide.name}${v.team ? '' : ' 말'})` : ''; const who = `${players[v.current]?.nickname ?? '다른 사람'}님`; @@ -47,6 +56,8 @@ export function helpNow(v: YutView, me: string | null, players: Record setTossing(false), fxMs(820)); return () => clearTimeout(t); }, [lt?.no]); // eslint-disable-line react-hooks/exhaustive-deps - const sticks = lt?.sticks ?? [false, true, false, true]; - const label = !lt ? '' : tossing ? '…' : lt.result === 'nak' ? '낙!' : `${THROW_KO[lt.result]}!`; + const sticks = lt?.sticks ?? (v.aug ? Array.from({ length: v.aug.sides.find((x) => x.id === v.mySide)?.sticks ?? 4 }, (_, i) => i % 2 === 1) : [false, true, false, true]); + const vbW = Math.max(120, 14 + sticks.length * 27); + const label = !lt ? '' : tossing ? '…' : lt.result === 'nak' ? '낙!' : lt.results ? `${lt.results.map((r) => THROW_KO[r]).join('·')}!` : `${THROW_KO[lt.result]}!`; return (
- + {lt?.result === 'nak' ? ( @@ -235,14 +257,18 @@ function Sticks({ view: v, players }: { view: YutView; players: Record ) : ( - sticks.map((f, i) => ) + sticks.map((f, i) => ) )}
{label}
- {lt && !tossing &&
{nick(players, lt.player)}님
} + {lt && !tossing && ( +
+ {nick(players, lt.player)}님{lt.note ? ` · ${lt.note}` : ''} +
+ )}
); @@ -272,6 +298,15 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps(null); const [flash, setFlash] = useState<{ text: string; at: [number, number]; key: number } | null>(null); const [landing, setLanding] = useState<{ no: number; at: [number, number]; delayMs: number; goal: boolean; victims: { side: number; count: number }[] } | null>(null); + const aug = v.aug ?? null; + const [aim, setAim] = useState(null); + const [targetUid, setTargetUid] = useState(null); + const svgRef = useRef(null); + useEffect(() => { + setAim(null); + setTargetUid(null); + }, [v.turnSeq]); + const openUses = aug && targetUid !== null ? aug.uses.filter((u) => u.uid === targetUid) : []; const lastMoveNo = useRef(v.lastMove?.no ?? 0); const lastThrowNo = useRef(v.lastThrow?.no ?? 0); const prevCurrent = useRef(v.current); @@ -412,8 +447,10 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps -
- + {aug && } +
+ {aug && } + {LINES.map(([a, b]) => ( @@ -434,9 +471,10 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps + {aug && } {stacks.map((st) => { - // Stacks standing apart on one node (지역 룰 stacking = choose) sit side by side. - const twins = st.piece === undefined ? [] : stacks.filter((o) => o.node === st.node && o.side === st.side); + // Stacks standing apart on one node (지역 룰 stacking = choose; 증강: special pieces, several sides) sit side by side. + const twins = aug ? stacks.filter((o) => o.node === st.node) : st.piece === undefined ? [] : stacks.filter((o) => o.node === st.node && o.side === st.side); const k = twins.indexOf(st); const dx = twins.length > 1 ? (k - (twins.length - 1) / 2) * 5.2 : 0; const x = POS[st.node]![0] + dx; @@ -445,12 +483,13 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps 1 ? 3.3 : BIG.has(st.node) ? 4.6 : 4; return ( - + {(can || sel) && 1 ? r + 1.4 : R_BIG + 0.6} fill="none" stroke={sel ? 'var(--primary)' : 'var(--focus)'} strokeWidth={1.3} className={sel ? undefined : 'yut-can'} />} + {aug && } {mine && myTurn && v.phase === 'move' && ( )} + {aug && } + {aug && } />} + {aug && aim && } + {aug && !aim && openUses.length > 0 && ( + { + if (u.id === 'alkkagi') { + if (u.at !== undefined && u.at !== 'home') setAim({ uid: u.uid, piece: u.action.piece!, at: u.at, angle: 270, power: 60 }); + return; + } + act({ type: 'AUG_USE', ...u.action }); + setTargetUid(null); + }} + /> + )} {anim && ( @@ -525,6 +580,9 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps
+ {aug && } + {aug && v.phase === 'aug' && aug.select && } + {aug && v.phase === 'prompt' && aug.prompt && }
{v.phase !== 'finished' && } @@ -562,10 +620,23 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps - {myTurn && v.phase === 'throw' && ( + {myTurn && v.phase === 'throw' && !aim && (aug?.pickThrow ? ( +
+ + +
+ ) : ( + ))} + + {aug && myTurn && (v.phase === 'throw' || v.phase === 'move') && ( + )} {myTurn && v.phase === 'move' && ( @@ -636,8 +707,27 @@ function YutBoard({ view: v, me, players, act, pending, deadline }: BoardProps 대기 {mySideView.home}개{myTurn && movable.has('home') ? ' · 새 말 올리기' : ''} + {aug?.sides + .find((x) => x.id === mySideView.id) + ?.homeSpecial.map((h) => { + const src = srcOf('home', h.piece); + const can = myTurn && movable.has(src); + return ( + + ); + })} - 🏁 난 말 {mySideView.done}/{v.options.pieces} + 🏁 난 말 {mySideView.done}/{mySideView.total ?? v.options.pieces}
)} @@ -662,7 +752,8 @@ function badge(m: YutLegalMove): string | null { function SideCard({ side, view: v, players, me, deadline }: { side: YutSideView; view: YutView; players: Record; me: string | null; deadline: number | null }) { const turn = v.phase !== 'finished' && v.turnSide === side.id; const shape = SHAPE_KO[sideShape(side.id)]; - const status = side.finishedRank !== null ? `${side.finishedRank}등` : side.out ? '기권' : null; + const augSide = v.aug?.sides.find((x) => x.id === side.id); + const status = side.finishedRank !== null ? (v.aug ? `${side.finishedRank}위` : `${side.finishedRank}등`) : side.out ? (v.aug ? (augSide?.reason === '기권' ? '기권' : '탈락') : '기권') : null; return (
@@ -678,19 +769,25 @@ function SideCard({ side, view: v, players, me, deadline }: { side: YutSideView; )} 대기 {side.home} · 판 {side.onBoard} · 🏁 {side.done} + {side.total !== undefined ? `/${side.total}` : ''}
+ {augSide?.reason && (side.out || side.finishedRank !== null) &&
{augSide.reason}
}
{side.members.map((id) => { const u = userOf(players, id); - const cur = turn && v.current === id; + // 증강 선택·질문 중에는 고르는 사람에게 시계가 간다. + const waitingOn = v.phase === 'aug' ? v.aug?.select?.waiting : v.phase === 'prompt' ? v.aug?.prompt?.waiting : undefined; + const cur = waitingOn ? waitingOn.includes(side.id) : turn && v.current === id; return (
{u.nickname} {id === me && (나)} - {cur && · {v.phase === 'throw' ? '던지는 중' : '옮기는 중'}} + {cur && !waitingOn && (v.phase === 'throw' || v.phase === 'move') && · {v.phase === 'throw' ? '던지는 중' : '옮기는 중'}} + {v.phase === 'aug' && v.aug?.select?.waiting.includes(side.id) && · 증강 고르는 중} + {v.phase === 'prompt' && v.aug?.prompt?.waiting.includes(side.id) && · 고르는 중} {side.conceded.includes(id) && 기권} {v.away.includes(id) && !side.conceded.includes(id) && 자리 비움} @@ -699,11 +796,16 @@ function SideCard({ side, view: v, players, me, deadline }: { side: YutSideView; ); })}
+ {v.aug && }
); } function logLine(e: GameEvent, v: YutView, players: Record): string | null { + if (v.aug) { + const l = augLogLine(e, v, players); + if (l !== undefined) return l; + } const who = typeof e.player === 'string' ? nick(players, e.player) : ''; const sn = (s: unknown) => v.sides[s as number]?.name ?? ''; switch (e.type) { @@ -787,6 +889,9 @@ function YutSide({ view: v, me, players, act, deadline }: BoardProps) { function statusText(v: YutView, me: string | null, players: Record): string { if (v.phase === 'finished') return v.result?.summary ?? '게임이 끝났어요'; + const augText = augStatus(v, me, players); + if (augText) return augText; + if (v.aug?.hidden) return '나 누구게? 모두 자기 색을 맞히는 중이에요'; const cur = nick(players, v.current); if (v.current === me) { if (v.phase === 'throw') return v.pending.length || v.lastThrow?.player === me ? '내 차례예요. 한 번 더 던져요' : '내 차례예요. 윷을 던져 주세요'; @@ -836,21 +941,26 @@ const OPT_CSS = ` .yut-rule-group legend { padding: 0 6px; font-weight: 800; color: var(--text-sub); } .yut-rules-toggle { justify-content: space-between; text-align: left; white-space: normal; height: auto; min-height: var(--tap); } .yut-rules-count { display: inline-block; margin-left: 6px; border-radius: 999px; padding: 0 8px; font-size: .8rem; font-weight: 800; background: var(--primary-soft); color: var(--text); } +.yut-opt-tabs { border-bottom: 1px solid var(--border); padding-bottom: 10px; } +.yut-opt-tabs button { flex: 1; } +.yut-opt-tabs button[aria-selected='true'] { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; } `; function Options({ value: o, onChange }: OptionsProps) { const [more, setMore] = useState(false); + const [tab, setTab] = useState<'base' | 'aug'>('base'); const set = (patch: Partial) => onChange({ ...o, ...patch }); + const aug = o.augmented === true; const onOff = (b: boolean) => (b ? 'on' : 'off'); const rules = houseRules(o); const hint = (key: keyof YutOptions) => rules.find((r) => r.key === key)?.text; const changed = rules.filter((r) => r.changed).length; - return ( -
- + const base = ( + <> - set({ mode })} /> - {o.mode === 'team' && 자리 순서대로 청팀·홍팀이 번갈아 앉아요(1·3·5·7번째 청팀). 자리를 바꿔 팀을 맞춰 주세요.} + set({ mode })} /> + {aug && 증강 윷놀이는 개인전만 돼요.} + {!aug && o.mode === 'team' && 자리 순서대로 청팀·홍팀이 번갈아 앉아요(1·3·5·7번째 청팀). 자리를 바꿔 팀을 맞춰 주세요.} set({ pieces })} /> @@ -957,6 +1067,31 @@ function Options({ value: o, onChange }: OptionsProps) { )}
)} + + ); + return ( +
+ + + set(k === 'aug' ? { augmented: true, mode: 'individual' } : { augmented: false })} /> + + {aug ? ( + <> +
+ + +
+
+ {tab === 'base' ? base : } +
+ + ) : ( + base + )}
); } @@ -1003,10 +1138,56 @@ function StickRow({ flats, label }: { flats: boolean[]; label: string }) { ); } +function AugRules({ o }: { o: YutOptions }) { + const off = new Set(o.augOff ?? []); + const rounds = { standard: '1·6·12', quick: '1·4·8', many: '1·3·5·7·9' }[o.augRounds ?? 'standard']; + const groups: [string, (a: (typeof AUGS)[AugId]) => boolean][] = [ + ['범용', (a) => a.tier === 'any' && !a.custom], + ['시작 전용', (a) => a.tier === 'start'], + ['중간 전용', (a) => a.tier === 'mid' && !a.custom], + ['마무리 전용', (a) => a.tier === 'final'], + ['이 사이트 추가', (a) => !!a.custom], + ]; + return ( +
+

🌀 증강 윷놀이

+

+ 보통 윷놀이에 증강(특별한 규칙·능력)이 더해져요. 모두가 한 번씩 차례를 하면 한 라운드예요. {rounds}라운드가 시작될 때 모두 동시에 후보 {o.augOffers ?? 3}개 중 하나를 고르고 + {o.augChaos ? '(혼돈 모드: 두 번씩)' : ''}, 후보와 고른 것은 자기에게만 보여요. 첫 선택은 범용+시작 전용, 마지막은 범용+마무리 전용, 그 사이는 범용+중간 전용 증강이 나와요. +

+

+ 증강을 쓰거나 승리 조건을 이루면 바로 순위가 정해지고, 탈락하면 꼴찌 쪽 순위가 돼요. 개인전(2~4명)으로만 해요. 고른 증강은 모두에게 보이고, 오른쪽 사람 카드에서 확인할 수 있어요. +

+ {groups.map(([title, f]) => { + const list = AUG_IDS.filter((id) => f(AUGS[id]) && !off.has(id)); + if (!list.length) return null; + return ( +
+ + {title} ({list.length}) + +
    + {list.map((id) => ( +
  • + {AUGS[id].name} + {AUGS[id].once ? ' (1회)' : ''}: {AUGS[id].text} + {AUGS[id].note ? {AUGS[id].note} : null} +
  • + ))} +
+
+ ); + })} + {off.size > 0 &&

이 방에서 뺀 증강 {off.size}개는 나오지 않아요.

} +
+ ); +} + function Rules({ options }: { options?: YutOptions }) { const o = options; return (
+ {o?.augmented && }

윷가락 네 개를 던져 나온 만큼 말을 움직여, 내 말을 모두 먼저 판 밖으로 내보내면(날) 이겨요. 말은 오른쪽 아래 참먹이에서 출발해 시계 반대 방향으로 돌아요. {o?.mode === 'team' ? ' 팀전은 청팀·홍팀이 번갈아 던지고, 팀 안에서는 자리 순서대로 돌아가요.' : ''} @@ -1085,7 +1266,12 @@ const ui: GameUI = { Board: YutBoard, Side: YutSide, statusText, - isMyTurn: (v, me) => v.phase !== 'finished' && !!me && v.current === me, + isMyTurn: (v, me) => { + if (v.phase === 'finished' || !me) return false; + if (v.aug && v.phase === 'aug') return !!v.aug.select && v.aug.select.offers.length > 0 && v.aug.select.picksLeft > 0; + if (v.aug && v.phase === 'prompt') return !!v.aug.prompt?.choices; + return v.current === me; + }, Options, optionsSummary, Rules, diff --git a/apps/web/src/pages/RoomPage.tsx b/apps/web/src/pages/RoomPage.tsx index 422f50c..6131e33 100644 --- a/apps/web/src/pages/RoomPage.tsx +++ b/apps/web/src/pages/RoomPage.tsx @@ -633,7 +633,8 @@ function SettingsForm({ room, ui, inline, readOnly, onDone }: { room: RoomView; /** * Locks every control inside (each game's options form has its own buttons, selects and inputs), except - * disclosure toggles (`aria-expanded`, e.g. "▼ 자세한 설정") so hidden rules can still be opened and read. + * disclosure toggles (`aria-expanded`, e.g. "▼ 자세한 설정"), tabs (`role="tab"`) and search boxes (`type="search"`) + * so hidden rules can still be opened and read. * Re-locks whatever the form renders later (opening "자세한 설정" adds new controls). */ function ReadOnlyControls({ children }: { children: ReactNode }) { @@ -641,7 +642,7 @@ function ReadOnlyControls({ children }: { children: ReactNode }) { useLayoutEffect(() => { const root = ref.current!; const lock = () => { - root.querySelectorAll('button:not([aria-expanded]), input, select, textarea').forEach((el) => { + root.querySelectorAll('button:not([aria-expanded]):not([role="tab"]), input:not([type="search"]), select, textarea').forEach((el) => { if (!el.disabled) el.disabled = true; }); }; diff --git a/apps/web/src/pages/admin/SchemaForm.tsx b/apps/web/src/pages/admin/SchemaForm.tsx index 429051f..6a5daab 100644 --- a/apps/web/src/pages/admin/SchemaForm.tsx +++ b/apps/web/src/pages/admin/SchemaForm.tsx @@ -13,6 +13,7 @@ export interface JsonSchema { const?: string | number | boolean; anyOf?: JsonSchema[]; properties?: Record; + items?: JsonSchema; minimum?: number; maximum?: number; default?: unknown; @@ -70,7 +71,26 @@ function Field({ schema, value, onChange, path, locked, onToggleLock, root }: Pr let control: ReactNode; const opts = choices(schema); - if (opts) { + const itemOpts = schema.type === 'array' && schema.items ? choices(schema.items) : null; + if (itemOpts) { + const cur = (Array.isArray(value) ? value : Array.isArray(schema.default) ? schema.default : []) as unknown[]; + const labels = schema.items?.labels; + control = ( +

+ {itemOpts.map((o) => ( + + ))} +
+ ); + } else if (opts) { const cur = value ?? schema.default; control = (