From f053b8fc6b1a0410970a9c8f8924fd5e86535ada Mon Sep 17 00:00:00 2001
From: EJClaw
Date: Tue, 13 Oct 2026 04:10:35 +0900
Subject: [PATCH 1/5] =?UTF-8?q?=EB=A3=A8=EB=AF=B8=ED=81=90=EB=B8=8C=C2=B7?=
=?UTF-8?q?=EB=8B=A4=EB=B9=88=EC=B9=98=20=EC=BD=94=EB=93=9C=C2=B7=EB=A7=88?=
=?UTF-8?q?=EC=9E=91=20=EC=B0=A8=EB=A1=80=20=EC=8B=9C=EA=B0=84=20'?=
=?UTF-8?q?=EB=AC=B4=EC=A0=9C=ED=95=9C'=20=EC=98=B5=EC=85=98:=20=EB=AC=B4?=
=?UTF-8?q?=EC=A0=9C=ED=95=9C=EC=9D=B4=EB=A9=B4=20=ED=83=80=EC=9D=B4?=
=?UTF-8?q?=EB=A8=B8=C2=B7=EC=8B=9C=EA=B0=84=20=EC=B4=88=EA=B3=BC=20?=
=?UTF-8?q?=EC=97=86=EC=9D=8C(=EC=97=B0=EA=B2=B0=20=EB=81=8A=EA=B9=80=20?=
=?UTF-8?q?=EC=B2=98=EB=A6=AC=EB=8A=94=20=EA=B7=B8=EB=8C=80=EB=A1=9C)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Claude Opus 5.5
---
apps/web/src/games/davinci-code/index.tsx | 16 +++++++++----
apps/web/src/games/mahjong/index.tsx | 22 ++++++++++-------
apps/web/src/games/rummikub/index.tsx | 14 +++++++----
.../src/davinci-code/davinci-code.test.ts | 20 ++++++++++++++++
packages/games/src/davinci-code/index.ts | 14 ++++++-----
packages/games/src/mahjong/index.ts | 24 +++++++++++++------
packages/games/src/mahjong/mahjong.test.ts | 17 +++++++++++++
packages/games/src/mahjong/types.ts | 14 ++++++++---
packages/games/src/rummikub/index.ts | 20 ++++++++++++----
packages/games/src/rummikub/rummikub.test.ts | 16 +++++++++++++
10 files changed, 139 insertions(+), 38 deletions(-)
diff --git a/apps/web/src/games/davinci-code/index.tsx b/apps/web/src/games/davinci-code/index.tsx
index fc31b61..44915a8 100644
--- a/apps/web/src/games/davinci-code/index.tsx
+++ b/apps/web/src/games/davinci-code/index.tsx
@@ -23,7 +23,7 @@ const hiddenLeft = (row: DavinciTileView[]) => row.filter((t) => !t.revealed).le
function totalMsOf(v: DavinciView): number {
if (v.phase === 'chooseStart') return 15_000;
if ((v.idle[v.current] ?? 0) >= 3) return 5_000;
- return v.phase === 'guess' ? v.options.turnSeconds * 1000 : 10_000;
+ return v.phase === 'guess' ? (v.options.turnSeconds ?? 30) * 1000 : 10_000;
}
/** Seats starting with the one after `me` (clockwise); spectators see everyone. */
@@ -864,7 +864,12 @@ function Options({ value: o, onChange }: OptionsProps) {
set({ startTiles })} />
- set({ turnSeconds })} />
+ set({ turnSeconds: k === 'none' ? null : (Number(k) as 20 | 30 | 45 | 60) })}
+ />
set({ deductionHelper })} />
@@ -894,7 +899,7 @@ function optionsSummary(o: DavinciOptions): string {
o.jokers ? '조커 사용' : '조커 없음',
o.startTiles === 'auto' ? '시작 타일 자동' : `시작 타일 ${o.startTiles}개`,
o.chooseColors ? '색 골라 가져오기' : '무작위로 가져오기',
- `추리 ${o.turnSeconds}초`,
+ o.turnSeconds === null ? '시간 무제한' : `추리 ${o.turnSeconds}초`,
...(o.tieOrder === 'white-left' ? ['같은 숫자는 흰색 먼저'] : []),
...(o.deductionHelper ? ['후보 표시'] : []),
].join(' · ');
@@ -942,7 +947,10 @@ function Rules({ options }: { options?: DavinciOptions }) {
이미 공개된 같은 색·같은 숫자를 말하는 것처럼 말이 안 되는 추리도 할 수는 있어요(화면에서 알려 줘요). 오른쪽 추리 기록에서 누가 어떤 숫자를 말했는지 다시 볼 수 있어요.
- 시간 안에 추리하지 않으면 공개된 정보로 가장 가능성 있는 작은 숫자를 자동으로 말해요. 세 번 연속 시간을 넘기면 제한 시간이 5초로 줄어요. 결과 화면에는 각자 맞힌 횟수와 추리 횟수가 나와요.
+ {o?.turnSeconds === null
+ ? '시간 제한이 없어서 천천히 생각해도 돼요. 연결이 끊긴 채로 오래 지나면 공개된 정보로 가장 가능성 있는 작은 숫자를 자동으로 말해요.'
+ : '시간 안에 추리하지 않으면 공개된 정보로 가장 가능성 있는 작은 숫자를 자동으로 말해요. 세 번 연속 시간을 넘기면 제한 시간이 5초로 줄어요.'}{' '}
+ 결과 화면에는 각자 맞힌 횟수와 추리 횟수가 나와요.
);
diff --git a/apps/web/src/games/mahjong/index.tsx b/apps/web/src/games/mahjong/index.tsx
index db221a0..2721ef2 100644
--- a/apps/web/src/games/mahjong/index.tsx
+++ b/apps/web/src/games/mahjong/index.tsx
@@ -1065,8 +1065,8 @@ function Options({ value: o, onChange }: OptionsProps) {
set({ length })} />
-
- set({ turnSeconds })} />
+
+ set({ turnSeconds })} />
set({ beginnerMode })} />
@@ -1138,12 +1138,16 @@ function Options({ value: o, onChange }: OptionsProps) {
set({ renpuuPairFu })} />
-
- set({ claimSeconds })} />
-
-
- set({ timeBankSeconds })} />
-
+ {o.turnSeconds !== 0 && (
+ <>
+
+ set({ claimSeconds })} />
+
+
+ set({ timeBankSeconds })} />
+
+ >
+ )}
set({ sanmaTsumo })} />
@@ -1165,7 +1169,7 @@ function optionsSummary(o: MahjongOptions): string {
if (o.kuitan) parts.push('쿠이탕');
if (o.doubleRon === 'headBump') parts.push('머리튀기');
if (o.beginnerMode) parts.push('초보 모드');
- parts.push(`${o.turnSeconds}초`);
+ parts.push(o.turnSeconds === 0 ? '시간 무제한' : `${o.turnSeconds}초`);
return parts.join(' · ');
}
diff --git a/apps/web/src/games/rummikub/index.tsx b/apps/web/src/games/rummikub/index.tsx
index e84869d..daac81c 100644
--- a/apps/web/src/games/rummikub/index.tsx
+++ b/apps/web/src/games/rummikub/index.tsx
@@ -709,7 +709,12 @@ function Options({ value: o, onChange }: OptionsProps) {
set({ initialMeldPoints })} />
- set({ turnSeconds })} />
+ set({ turnSeconds: k === 'none' ? null : (Number(k) as 60 | 90 | 120 | 180) })}
+ />
set({ gamesPerMatch })} />
@@ -748,8 +753,9 @@ function Options({ value: o, onChange }: OptionsProps) {
function optionsSummary(o: RummikubOptions): string {
const games = o.gamesPerMatch === 'players' ? '인원수만큼' : `${o.gamesPerMatch}판`;
- const sec = o.turnSeconds % 60 ? `${Math.floor(o.turnSeconds / 60)}분 ${o.turnSeconds % 60}초` : `${o.turnSeconds / 60}분`;
- return [o.initialMeldPoints ? `첫 등록 ${o.initialMeldPoints}점` : '첫 등록 점수 없음', `한 차례 ${sec}`, games, o.jokerPenalty === 50 ? '조커 50점' : '', o.showDraftToOthers ? '배치 공개' : '']
+ const t = o.turnSeconds;
+ const sec = t === null ? null : t % 60 ? `${Math.floor(t / 60)}분 ${t % 60}초` : `${t / 60}분`;
+ return [o.initialMeldPoints ? `첫 등록 ${o.initialMeldPoints}점` : '첫 등록 점수 없음', sec ? `한 차례 ${sec}` : '시간 무제한', games, o.jokerPenalty === 50 ? '조커 50점' : '', o.showDraftToOthers ? '배치 공개' : '']
.filter(Boolean)
.join(' · ');
}
@@ -802,7 +808,7 @@ function Rules({ options }: { options?: RummikubOptions }) {
바닥 고치기: 첫 등록 뒤에는 바닥의 묶음을 쪼개고 합치고 옮겨서 내 타일을 끼워 넣을 수 있어요. 예를 들어 빨강 4-5-6-7-8 사이에 내 빨강 6을 넣어 4-5-6과 6-7-8로 나눌 수 있어요. 바닥 타일은 받침대로 가져올 수 없고, 조커를 빼 왔다면 같은 차례에 다시 바닥에 써야 해요.
- 시간: 한 차례는 {o ? `${o.turnSeconds}초` : '1분'}예요. 시간이 다 되면{' '}
+ 시간: {o?.turnSeconds === null ? '이 방은 시간 제한이 없어요. 연결이 끊긴 채로 오래 지나면' : `한 차례는 ${o ? `${o.turnSeconds}초` : '1분'}예요. 시간이 다 되면`}{' '}
{o?.timeoutValidDraft === 'revert' ? '놓아 둔 타일을 되돌리고 1장을 가져와요' : '올바르게 놓아 둔 타일은 자동으로 확정돼요'}. 묶음이 틀린 채로 끝나면 처음으로 되돌리고 {o?.invalidTimeoutPenalty ?? 3}장을 가져와요.
diff --git a/packages/games/src/davinci-code/davinci-code.test.ts b/packages/games/src/davinci-code/davinci-code.test.ts
index 46fe308..107e6ee 100644
--- a/packages/games/src/davinci-code/davinci-code.test.ts
+++ b/packages/games/src/davinci-code/davinci-code.test.ts
@@ -493,6 +493,26 @@ describe('시간 초과·연결 끊김 (§8.5)', () => {
}
});
+ test('무제한: 어느 단계도 마감이 없고, 연결이 끊겨 자동으로 둔 사람만 5초 마감', () => {
+ expect(davinci.optionsSchema.parse({ turnSeconds: null }).turnSeconds).toBeNull();
+ const players = ['A', 'B'];
+ let s = davinci.setup({ players, options: davinci.optionsSchema.parse({ turnSeconds: null }), rng: SeededRng.fromSeed(seedN(3)), now: 0 });
+ expect(davinci.deadline!(s)).toBeNull();
+ const r = SeededRng.fromSeed(seedN(4));
+ let sawIdle = false;
+ for (let step = 0; step < 3000 && s.phase.kind !== 'finished'; step++) {
+ const p = davinci.timeoutPlayers!(s)[0]!;
+ const idle = s.phase.kind !== 'chooseStart' && s.current === 'A' && (s.idle.A ?? 0) >= 3;
+ if (idle) sawIdle = true;
+ expect(davinci.deadline!(s) === null).toBe(!idle);
+ // A is disconnected (the room fires its timeouts after the grace period); B plays.
+ const a = p === 'A' ? davinci.onTimeout(s, p) : davinci.legalActions!(s, p)[0]!;
+ s = davinci.apply(s, p, a, { rng: r, now: step * 1000 }).state;
+ }
+ expect(s.phase.kind).toBe('finished');
+ expect(sawIdle).toBe(true);
+ });
+
test('all-AFK game (everyone times out) still ends', () => {
for (let seed = 1; seed <= 20; seed++) {
for (const emptyPoolPenalty of ['reveal-own', 'none'] as const) {
diff --git a/packages/games/src/davinci-code/index.ts b/packages/games/src/davinci-code/index.ts
index df987a7..3c9afea 100644
--- a/packages/games/src/davinci-code/index.ts
+++ b/packages/games/src/davinci-code/index.ts
@@ -32,9 +32,9 @@ export const davinciOptionsSchema = z.object({
.default('reveal-own')
.meta({ title: '더미가 빈 뒤 틀렸을 때', labels: { 'reveal-own': '내 숨은 타일 1개 공개', none: '벌칙 없음' } }),
turnSeconds: z
- .union([z.literal(20), z.literal(30), z.literal(45), z.literal(60)])
+ .union([z.literal(20), z.literal(30), z.literal(45), z.literal(60), z.literal(null)])
.default(30)
- .meta({ title: '추리 제한 시간', labels: { 20: '20초', 30: '30초', 45: '45초', 60: '60초' } }),
+ .meta({ title: '추리 제한 시간', labels: { 20: '20초', 30: '30초', 45: '45초', 60: '60초', null: '무제한' } }),
deductionHelper: z.boolean().default(false).meta({ title: '가능한 숫자 후보 표시(초보 도움)' }),
});
export type DavinciOptions = z.infer;
@@ -255,21 +255,23 @@ export function candidatesFor(
function refreshDeadline(s: DavinciState, now: number, phaseChanged: boolean): void {
if (!phaseChanged) return;
s.phaseStartedAt = now;
+ // 무제한(turnSeconds null): no step has a clock; only an idle (disconnected, auto-played) player keeps the short one.
+ const unlimited = s.options.turnSeconds === null;
let ms: number | null;
switch (s.phase.kind) {
case 'finished':
ms = null;
break;
case 'chooseStart':
- ms = CHOOSE_START_MS;
+ ms = unlimited ? null : CHOOSE_START_MS;
break;
case 'guess':
- ms = s.options.turnSeconds * 1000;
+ ms = s.options.turnSeconds === null ? null : s.options.turnSeconds * 1000;
break;
default:
- ms = SHORT_MS;
+ ms = unlimited ? null : SHORT_MS;
}
- if (ms !== null && s.phase.kind !== 'chooseStart' && (s.idle[s.current] ?? 0) >= IDLE_TURNS) ms = IDLE_MS;
+ if (s.phase.kind !== 'finished' && s.phase.kind !== 'chooseStart' && (s.idle[s.current] ?? 0) >= IDLE_TURNS) ms = IDLE_MS;
s.deadlineAt = ms === null ? null : now + ms;
}
diff --git a/packages/games/src/mahjong/index.ts b/packages/games/src/mahjong/index.ts
index 967eb6e..40a359e 100644
--- a/packages/games/src/mahjong/index.ts
+++ b/packages/games/src/mahjong/index.ts
@@ -409,7 +409,7 @@ function openWindow(s: MahjongState, source: ClaimWindow['source'], tile: TileId
winning,
responses: eligible.map(() => null),
openedAt: ctx.now,
- deadline: ctx.now + s.options.claimSeconds * 1000,
+ deadline: unlimited(s) ? null : ctx.now + s.options.claimSeconds * 1000,
minUntil: ctx.now + MIN_CLAIM_MS,
decided: false,
riichiPending,
@@ -1017,8 +1017,13 @@ function riichiOk(s: MahjongState, seat: Seat, tile: TileId): boolean {
// ---------------------------------------------------------------- timers
-function turnLimitMs(s: MahjongState, seat: Seat): number {
- return s.autoPilot[seat] ? AUTO_MS : s.options.turnSeconds * 1000 + s.timeBank[seat]!;
+/** turnSeconds 0 = 무제한: no discard clock, no time bank, claim windows wait for every answer. */
+const unlimited = (s: MahjongState) => s.options.turnSeconds === 0;
+
+/** null = 무제한 (an auto-piloted seat still gets the short clock). */
+function turnLimitMs(s: MahjongState, seat: Seat): number | null {
+ if (s.autoPilot[seat]) return AUTO_MS;
+ return unlimited(s) ? null : s.options.turnSeconds * 1000 + s.timeBank[seat]!;
}
function deadlineAt(s: MahjongState): number | null {
@@ -1026,7 +1031,10 @@ function deadlineAt(s: MahjongState): number | null {
if (s.phase === 'handResult') return s.resultAt + RESULT_MS;
const h = H(s);
if (h.stage === 'claim') return h.claim!.decided ? h.claim!.minUntil : h.claim!.deadline;
- if (h.stage === 'afterDraw' || h.stage === 'afterCall') return h.turnStartedAt + turnLimitMs(s, h.turn);
+ if (h.stage === 'afterDraw' || h.stage === 'afterCall') {
+ const ms = turnLimitMs(s, h.turn);
+ return ms === null ? null : h.turnStartedAt + ms;
+ }
return null;
}
@@ -1336,7 +1344,7 @@ function buildView(s: MahjongState, viewer: PlayerId | null): MahjongView {
// Eligible players get their own countdown in `my.claim`.
let total = 0;
if (s.phase === 'handResult') total = RESULT_MS;
- else if (live && h.stage !== 'claim') total = turnLimitMs(s, h.turn);
+ else if (live && h.stage !== 'claim') total = turnLimitMs(s, h.turn) ?? 0;
return {
mode: s.mode,
n,
@@ -1454,7 +1462,9 @@ export const mahjong: GameDefinition 0) s.timeBank[seat] = Math.max(0, s.timeBank[seat]! - over);
@@ -1498,7 +1508,7 @@ export const mahjong: GameDefinition= due || (c.decided && seat === c.from)) {
+ if ((due !== null && now >= due) || (c.decided && seat === c.from)) {
c.eligible.forEach((e, i) => {
if (e && !c.responses[i]) {
c.responses[i] = { type: 'pass' };
diff --git a/packages/games/src/mahjong/mahjong.test.ts b/packages/games/src/mahjong/mahjong.test.ts
index 83967f0..b2a2e0c 100644
--- a/packages/games/src/mahjong/mahjong.test.ts
+++ b/packages/games/src/mahjong/mahjong.test.ts
@@ -1029,6 +1029,23 @@ describe('시간 초과 §8.5', () => {
expect(s.timeoutsInRow[1]).toBe(1);
expect(s.hand!.turn).toBe(1);
});
+ test('무제한(turnSeconds 0): 타패·응답 창 마감 없음, 예비 시간 그대로; 연결 끊긴 응답자는 서버 타이머로 패스', () => {
+ expect(mahjong.optionsSchema.safeParse({ turnSeconds: 0 }).success).toBe(true);
+ expect(mahjong.optionsSchema.safeParse({ turnSeconds: 3 }).success).toBe(false);
+ let s = rig(make(4, { turnSeconds: 0 }), { hands: ['*', T2, '*', '*'], drawn: '5m' });
+ expect(mahjong.deadline!(s)).toBeNull();
+ expect(view(s, 0).deadlineTotalMs).toBe(0);
+ s = act(s, 0, { type: 'discard', tile: codeIn(s, 0, '5m') }, 500_000);
+ expect(s.timeBank[0]).toBe(60_000);
+ expect(s.hand!.stage).toBe('claim');
+ expect(claimOf(s, 1)!.ron).toBe(true);
+ expect(claimOf(s, 1)!.deadline).toBeNull();
+ expect(mahjong.deadline!(s)).toBeNull();
+ // B is disconnected: the room fires B's timeout after the grace period → pass.
+ s = act(s, 1, { type: 'timeout' }, 600_000);
+ expect(s.hand!.turn).toBe(1);
+ expect(s.timeoutsInRow[1]).toBe(1);
+ });
test('예비 시간: 기본 시간을 넘긴 만큼 깎이고, 다음 국에 5초 충전', () => {
let s = rig(make(4), { hands: ['*', '*', '*', '*'], drawn: '5s' });
s = act(s, 0, { type: 'discard', tile: codeIn(s, 0, '5s') }, 25_000);
diff --git a/packages/games/src/mahjong/types.ts b/packages/games/src/mahjong/types.ts
index 4929344..75a1f1d 100644
--- a/packages/games/src/mahjong/types.ts
+++ b/packages/games/src/mahjong/types.ts
@@ -46,7 +46,14 @@ export const mahjongOptionsSchema = z.object({
sanmaTsumo: z.enum(['tsumoLoss', 'northBisection']).default('tsumoLoss').meta({ title: '(3인) 쯔모 지불', labels: { tsumoLoss: '쯔모손(북가 몫 없음)', northBisection: '북가 몫을 둘이 반씩' } }),
sanmaHonba: lit(200, 300, 1000).default(200).meta({ title: '(3인) 본장 1개당 점수', labels: { 200: '200점', 300: '300점', 1000: '1,000점' } }),
sanmaNotenPool: lit(2000, 3000).default(2000).meta({ title: '(3인) 유국 텐파이료 합계', labels: { 2000: '2,000점', 3000: '3,000점' } }),
- turnSeconds: z.number().int().min(5).max(60).default(15).meta({ title: '타패 제한 시간(초, 5~60)' }),
+ turnSeconds: z
+ .number()
+ .int()
+ .min(0)
+ .max(60)
+ .refine((v) => v === 0 || v >= 5, '5~60초 또는 0(무제한)이어야 해요.')
+ .default(15)
+ .meta({ title: '타패 제한 시간(초, 5~60, 0 = 무제한: 울기·론 응답도 기다려요)' }),
claimSeconds: z.number().int().min(3).max(20).default(8).meta({ title: '울기·론 응답 시간(초, 3~20)' }),
timeBankSeconds: z.number().int().min(0).max(300).default(60).meta({ title: '개인 예비 시간(초, 0~300)' }),
beginnerMode: z.boolean().default(true).meta({ title: '초보 모드 허용(대기패·역 힌트)' }),
@@ -118,7 +125,8 @@ export interface ClaimWindow {
winning: boolean[];
responses: (ClaimResponse | null)[];
openedAt: number;
- deadline: number;
+ /** null = 무제한 (waits for every eligible answer). */
+ deadline: number | null;
/** The window never closes before this (information-leak mitigation, §5.3.2). */
minUntil: number;
/** The outcome is settled; only the minimum delay is left. */
@@ -306,7 +314,7 @@ export interface MyView {
kakan: string[];
canKita: boolean;
canKyuushu: boolean;
- claim: { tile: string; source: ClaimWindow['source']; ron: boolean; pon: string[][]; kan: string[][]; chi: string[][]; responded: boolean; deadline: number; totalMs: number } | null;
+ claim: { tile: string; source: ClaimWindow['source']; ron: boolean; pon: string[][]; kan: string[][]; chi: string[][]; responded: boolean; deadline: number | null; totalMs: number } | null;
riichi: boolean;
furiten: boolean;
/** Current waits (13-tile state), with tiles left from what I can see. */
diff --git a/packages/games/src/rummikub/index.ts b/packages/games/src/rummikub/index.ts
index d76cfdf..076df52 100644
--- a/packages/games/src/rummikub/index.ts
+++ b/packages/games/src/rummikub/index.ts
@@ -20,16 +20,16 @@ import {
export * from './rules';
-const lit = (...vals: T[]) =>
+const lit = (...vals: T[]) =>
z.union(vals.map((v) => z.literal(v)) as unknown as [z.ZodLiteral, z.ZodLiteral, ...z.ZodLiteral[]]);
export const rummikubOptionsSchema = z.object({
initialMeldPoints: lit(0, 20, 30, 50)
.default(30)
.meta({ title: '첫 등록 최소 점수', labels: { 0: '없음', 20: '20점', 30: '30점(공식)', 50: '50점' } }),
- turnSeconds: lit(60, 90, 120, 180)
+ turnSeconds: lit(60, 90, 120, 180, null)
.default(60)
- .meta({ title: '한 차례 제한 시간', labels: { 60: '1분(공식)', 90: '1분 30초', 120: '2분', 180: '3분' } }),
+ .meta({ title: '한 차례 제한 시간', labels: { 60: '1분(공식)', 90: '1분 30초', 120: '2분', 180: '3분', null: '무제한' } }),
timeoutValidDraft: z
.enum(['commit', 'revert'])
.default('commit')
@@ -185,6 +185,7 @@ export interface RummikubView {
current: PlayerId | null;
turnNo: number;
turnStartedAt: number;
+ /** 0 = 무제한. */
turnMs: number;
poolCount: number;
table: TableSet[];
@@ -215,6 +216,12 @@ export interface RummikubView {
// ---------------------------------------------------------------- helpers
const AWAY_MS = 3000;
+
+/** The current turn's time limit; null = 무제한 (a disconnected, auto-played player still gets the short one). */
+function turnLimitMs(s: RummikubState): number | null {
+ if ((s.timeoutsInRow[s.current] ?? 0) >= 3) return AWAY_MS;
+ return s.options.turnSeconds === null ? null : s.options.turnSeconds * 1000;
+}
const ROUND_END_MS = 30_000;
const HISTORY_MAX = 100;
@@ -712,7 +719,7 @@ export const rummikub: GameDefinition= 3 ? AWAY_MS : s.options.turnSeconds * 1000,
+ turnMs: turnLimitMs(s) ?? 0,
poolCount: s.pool.length,
table: s.table,
lastChanged: s.lastChanged,
@@ -748,7 +755,10 @@ export const rummikub: GameDefinition= 3 ? AWAY_MS : s.options.turnSeconds * 1000);
+ if (s.phase === 'playing') {
+ const ms = turnLimitMs(s);
+ return ms === null ? null : s.turnStartedAt + ms;
+ }
if (s.phase === 'roundEnd') return (s.roundEndAt ?? 0) + ROUND_END_MS;
return null;
},
diff --git a/packages/games/src/rummikub/rummikub.test.ts b/packages/games/src/rummikub/rummikub.test.ts
index 606da0b..1052f9b 100644
--- a/packages/games/src/rummikub/rummikub.test.ts
+++ b/packages/games/src/rummikub/rummikub.test.ts
@@ -421,6 +421,22 @@ describe('시간 초과 (§5.7, §8.5)', () => {
s = act(s, p, { type: 'draw' });
expect(s.timeoutsInRow[p]).toBe(0);
});
+
+ test('무제한: 차례 마감이 없고(타이머 0), 연결이 끊겨 3번 넘어간 사람만 짧은 마감', () => {
+ let s = mk({ turnSeconds: null }, ['A', 'B'], 2);
+ expect(rummikub.deadline!(s)).toBeNull();
+ expect(rummikub.view(s, null).turnMs).toBe(0);
+ const p = s.current;
+ for (let i = 0; i < 3; i++) {
+ s = act(s, p, { type: 'timeout' });
+ expect(rummikub.deadline!(s)).toBeNull();
+ s = act(s, s.current, { type: 'draw' });
+ }
+ expect(rummikub.deadline!(s)).toBe(s.turnStartedAt + 3000);
+ s = act(s, p, { type: 'draw' });
+ s = act(s, s.current, { type: 'draw' });
+ expect(rummikub.deadline!(s)).toBeNull();
+ });
});
// ---------------------------------------------------------------- scoring / end
From 0a406306da101962280b3aa4444103d550fd441f Mon Sep 17 00:00:00 2001
From: EJClaw
Date: Tue, 13 Oct 2026 04:14:45 +0900
Subject: [PATCH 2/5] =?UTF-8?q?=EB=AC=B8=EC=84=9C:=20=EB=A3=A8=EB=AF=B8?=
=?UTF-8?q?=ED=81=90=EB=B8=8C=C2=B7=EB=8B=A4=EB=B9=88=EC=B9=98=20=EC=BD=94?=
=?UTF-8?q?=EB=93=9C=C2=B7=EB=A7=88=EC=9E=91=20=EB=AC=B4=EC=A0=9C=ED=95=9C?=
=?UTF-8?q?=20=EC=8B=9C=EA=B0=84=20=EA=B7=9C=EC=B9=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Claude Opus 5.5
---
docs/games/davinci-code.md | 3 ++-
docs/games/mahjong.md | 3 ++-
docs/games/rummikub.md | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/docs/games/davinci-code.md b/docs/games/davinci-code.md
index 18c7e94..51d9214 100644
--- a/docs/games/davinci-code.md
+++ b/docs/games/davinci-code.md
@@ -15,7 +15,7 @@
| `startTiles` | 시작 타일 수 | `auto`(2·3인 4개, 4인 3개) / 3 / 4 / 5 | `auto` |
| `chooseColors` | 타일을 가져올 때 색을 고르게 하기(실물 규칙, 뒷면 색이 보임) | on / off(무작위) | on |
| `emptyPoolPenalty` | 더미가 비었을 때 틀리면 | `reveal-own`(자기 숨은 타일 1개 공개) / `none`(벌칙 없음) | `reveal-own` |
-| `turnSeconds` | 추리 제한 시간 | 20 / 30 / 45 / 60 | 30 |
+| `turnSeconds` | 추리 제한 시간 | 20 / 30 / 45 / 60 / null(무제한) | 30 |
| `deductionHelper` | 공개 정보로 가능한 숫자 후보 표시(초보 도움) | on / off | off |
## 3. 구성물
@@ -147,6 +147,7 @@ interface DavinciState {
### 8.5 타이머·시간 초과·연결 끊김 시 자동 행동
- 마감: `chooseStart` 15초, `draw` 10초, `guess` `turnSeconds`, `afterCorrect` 10초, `placeJoker`/`revealOwn` 10초.
+- `turnSeconds = null`(무제한)이면 모든 단계에 마감이 없고 타이머도 안 보인다. 연결이 끊기면 방의 유예 시간 뒤 서버가 `timeout`을 보내 아래 자동 행동을 하는 처리는 그대로이고, 연속 3턴 자동으로 둔 사람에게는 무제한이어도 5초 마감이 붙는다(다시 직접 두면 풀림).
- `onTimeout`
- `chooseStart`: 가능한 한 반반(홀수면 검정 하나 더).
- `draw`: 더 많이 남은 색(같으면 검정).
diff --git a/docs/games/mahjong.md b/docs/games/mahjong.md
index bbb8688..dd9eef8 100644
--- a/docs/games/mahjong.md
+++ b/docs/games/mahjong.md
@@ -34,7 +34,7 @@
| `sanmaTsumo` | 산마 쯔모 지불 방식 | `tsumoLoss`(쯔모손: 없는 북가 몫 소멸) / `northBisection`(북가 몫을 둘이 반씩) | `tsumoLoss` |
| `sanmaHonba` | 산마 본장 1개당 점수 합계 | 200 / 300 / 1000 | 200 |
| `sanmaNotenPool` | 산마 유국 텐파이료 총액 | 2000 / 3000 | 2000 |
-| `turnSeconds` | 타패 기본 제한 시간(초) | 5~60 | 15 |
+| `turnSeconds` | 타패 기본 제한 시간(초). 0 = 무제한(타패·울기·론 응답 모두 마감 없음, 예비 시간 안 씀) | 0, 5~60 | 15 |
| `claimSeconds` | 울기·론 응답 창 시간(초) | 3~20 | 8 |
| `timeBankSeconds` | 개인 예비 시간(대국 전체, 매 국 +5초 충전, 최대값까지) | 0~300 | 60 |
| `beginnerMode` | 초보 모드 허용(개인별로 켜고 끔) | true / false | true |
@@ -505,6 +505,7 @@ interface MahjongState {
### 8.5 타이머·시간 초과·연결 끊김 시 자동 행동
- 차례 타이머: `turnSeconds` 소진 후 개인 `timeBank`를 깎는다. 둘 다 0이면 `onTimeout`.
+- `turnSeconds = 0`(무제한): 타패 마감과 응답 창 마감이 없다(응답 창은 응답 가능자가 모두 답할 때까지 기다린다. 최소 지연 400ms는 그대로). 예비 시간은 깎지 않고, 타이머도 안 보인다. 연결이 끊긴 사람은 방의 유예 시간 뒤 서버가 `timeout`을 보내 자동 처리(쯔모기리·패스)하고, `autoPilot`이 되면 무제한이어도 차례 마감 2초가 붙는다. 결과 화면 15초는 차례 시간이 아니라서 그대로다.
- 응답 창: `claimSeconds` 고정, 예비 시간을 쓰지 않는다.
- `deadline(state)`: 현재 단계의 마감 시각(차례 = 시작 + 기본 + 남은 예비, 응답 창 = 창 마감, 결과 화면 = 표시 후 15초).
- `onTimeout(state, player)`:
diff --git a/docs/games/rummikub.md b/docs/games/rummikub.md
index 6005fe6..0d2a07c 100644
--- a/docs/games/rummikub.md
+++ b/docs/games/rummikub.md
@@ -11,7 +11,7 @@
| 옵션 키 | 설명 | 선택지 | 기본값 |
|---|---|---|---|
| `initialMeldPoints` | 첫 등록에 필요한 최소 점수 | 0(없음) / 20 / 30 / 50 | 30 |
-| `turnSeconds` | 턴 제한 시간(공식 1분) | 60 / 90 / 120 / 180 | 60 |
+| `turnSeconds` | 턴 제한 시간(공식 1분) | 60 / 90 / 120 / 180 / null(무제한) | 60 |
| `timeoutValidDraft` | 시간 초과 때 초안이 유효한 경우 처리 | `commit`(자동 확정) / `revert`(공식대로 되돌리고 1장 뽑기) | `commit` |
| `invalidTimeoutPenalty` | 시간 초과 때 초안이 무효한 경우 뽑는 장수(공식 3) | 1 / 3 | 3 |
| `invalidCommitPenalty` | "완료"를 눌렀는데 무효일 때 처리 | `reject`(거부만, 계속 수정) / `penalty3`(되돌리고 3장 뽑고 턴 종료) | `reject` |
@@ -246,7 +246,7 @@ function normalizeSet(d: DraftSet, tiles): TableSet | null {
- 그 외 진행 중에는 RNG를 쓰지 않는다(뽑기는 섞인 풀의 앞에서부터).
### 8.5 타이머·시간 초과·연결 끊김 시 자동 행동
-- `deadline = turnStartedAt + turnSeconds*1000`.
+- `deadline = turnStartedAt + turnSeconds*1000`. `turnSeconds = null`(무제한)이면 차례 마감이 없고 타이머도 안 보인다(`turnMs = 0`). 연결이 끊기면 방의 유예 시간 뒤 서버가 `timeout`을 보내는 처리는 그대로이고, 3번 연속 넘어간 자리 비움 사람에게는 무제한이어도 짧은 마감(3초)이 붙는다. 판 사이 준비 30초는 차례 시간이 아니라서 그대로다.
- `onTimeout(state, p)`는 내부 액션 `timeout`을 돌려준다. `apply`에서 5.7의 규칙대로 처리한다.
- 초안 변경 없음 → 1개 뽑기 또는 넘기기.
- 유효 초안 → `commit` 또는 되돌리고 1개 뽑기.
From 1b4c80a2df89b5d8782a1d21a370cda1a4b12fa3 Mon Sep 17 00:00:00 2001
From: EJClaw
Date: Tue, 13 Oct 2026 13:09:19 +0900
Subject: [PATCH 3/5] =?UTF-8?q?=EC=9A=94=ED=8A=B8=20=EB=8B=A4=EC=9D=B4?=
=?UTF-8?q?=EC=8A=A4=C2=B7=EB=9D=BC=EC=8A=A4=EB=B2=A0=EA=B0=80=EC=8A=A4?=
=?UTF-8?q?=C2=B7=EB=B6=80=EB=A3=A8=EB=A7=88=EB=B6=88=20=EC=B0=A8=EB=A1=80?=
=?UTF-8?q?=20=EC=8B=9C=EA=B0=84=20'=EB=AC=B4=EC=A0=9C=ED=95=9C'=20?=
=?UTF-8?q?=ED=91=9C=EA=B8=B0=20=ED=86=B5=EC=9D=BC:=20=EC=9A=94=ED=8A=B8?=
=?UTF-8?q?=20'=EC=A0=9C=ED=95=9C=20=EC=97=86=EC=9D=8C'=E2=86=92'=EB=AC=B4?=
=?UTF-8?q?=EC=A0=9C=ED=95=9C',=20=EC=9A=94=EC=95=BD=EC=9D=80=20'=EC=8B=9C?=
=?UTF-8?q?=EA=B0=84=20=EB=AC=B4=EC=A0=9C=ED=95=9C',=20=EB=B6=80=EB=A3=A8?=
=?UTF-8?q?=EB=A7=88=EB=B6=88=20=EB=AC=B4=EC=A0=9C=ED=95=9C=20=EB=A7=88?=
=?UTF-8?q?=EA=B0=90=20=EC=97=86=EC=9D=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Claude Opus 5.5
---
packages/games/src/marble/marble.test.ts | 11 +++++++++++
packages/games/src/yacht/index.ts | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/packages/games/src/marble/marble.test.ts b/packages/games/src/marble/marble.test.ts
index 9b10847..6704a71 100644
--- a/packages/games/src/marble/marble.test.ts
+++ b/packages/games/src/marble/marble.test.ts
@@ -926,6 +926,17 @@ describe('시간 초과·연결 끊김 (§8.5)', () => {
expect(s.timeouts.B).toBe(0);
});
+ test('제한 시간 무제한: 결정마다 마감이 없음(교환 응답은 20초 그대로)', () => {
+ let s = make({ turnSeconds: null });
+ expect(s.deadlineAt).toBeNull();
+ s = roll(s, 1, 2); // A → 3, buy decision
+ expect(s.phase).toBe('decide');
+ expect(s.deadlineAt).toBeNull();
+ s = act(s, 'A', { type: 'PASS' });
+ expect(curId(s)).toBe('B');
+ expect(s.deadlineAt).toBeNull();
+ });
+
test('onLeave = CONCEDE: 땅은 은행으로, 차례 넘김; 빚 갚는 중이면 그 빚은 먼저 갚음', () => {
let s = make({}, 3);
own(s, 1, 'A');
diff --git a/packages/games/src/yacht/index.ts b/packages/games/src/yacht/index.ts
index 5a43edf..33429f2 100644
--- a/packages/games/src/yacht/index.ts
+++ b/packages/games/src/yacht/index.ts
@@ -32,7 +32,7 @@ export const yachtOptionsSchema = z.object({
.meta({ title: '13칸 변형: 요트가 또 나왔을 때', labels: { forced: '정해진 순서대로 넣기(공식)', free: '아무 칸이나 고르기' } }),
turnSeconds: lit(30, 60, 90, 0)
.default(60)
- .meta({ title: '한 차례 제한 시간', labels: { 30: '30초', 60: '60초', 90: '90초', 0: '제한 없음' } }),
+ .meta({ title: '한 차례 제한 시간', labels: { 30: '30초', 60: '60초', 90: '90초', 0: '무제한' } }),
showPreview: z.boolean().default(true).meta({ title: '빈 칸에 지금 넣을 때 점수 미리 보여 주기' }),
});
export type YachtOptions = z.infer;
From a6ace5b5e8eb369542a8a6e0025216f6e4d67933 Mon Sep 17 00:00:00 2001
From: EJClaw
Date: Tue, 13 Oct 2026 13:09:19 +0900
Subject: [PATCH 4/5] =?UTF-8?q?=EB=A3=A8=EB=AF=B8=ED=81=90=EB=B8=8C=C2=B7?=
=?UTF-8?q?=EB=8B=A4=EB=B9=88=EC=B9=98=20=EC=BD=94=EB=93=9C=C2=B7=EB=A7=88?=
=?UTF-8?q?=EC=9E=91=C2=B7=EB=9D=BC=EC=8A=A4=EB=B2=A0=EA=B0=80=EC=8A=A4?=
=?UTF-8?q?=C2=B7=EB=B6=80=EB=A3=A8=EB=A7=88=EB=B6=88=C2=B7=EC=9A=94?=
=?UTF-8?q?=ED=8A=B8=20=EB=8B=A4=EC=9D=B4=EC=8A=A4=20=EC=86=8C=EB=A6=AC?=
=?UTF-8?q?=C2=B7=EC=95=A0=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98:=20?=
=?UTF-8?q?=EC=83=81=EB=8C=80=C2=B7=EC=BB=B4=ED=93=A8=ED=84=B0=20=ED=96=89?=
=?UTF-8?q?=EB=8F=99=EB=8F=84=20=ED=99=94=EB=A9=B4=20=EB=B3=80=ED=99=94?=
=?UTF-8?q?=EB=A1=9C=20=ED=95=9C=20=EB=B2=88=EB=A7=8C=20=EC=9A=B8=EB=A6=BC?=
=?UTF-8?q?(=EC=B2=98=EC=9D=8C=20=EB=93=A4=EC=96=B4=EC=98=AC=20=EB=95=8C?=
=?UTF-8?q?=C2=B7=EC=9E=AC=EC=A0=91=EC=86=8D=EC=9D=80=20=EC=A1=B0=EC=9A=A9?=
=?UTF-8?q?),=20=ED=83=80=EC=9D=BC=20=EB=86=93=EA=B8=B0=C2=B7=EB=92=A4?=
=?UTF-8?q?=EC=A7=91=EA=B8=B0,=20=EC=A3=BC=EC=82=AC=EC=9C=84=20=EA=B5=B4?=
=?UTF-8?q?=EB=A6=BC,=20=EB=A7=90=20=ED=95=9C=20=EC=B9=B8=EC=94=A9=20?=
=?UTF-8?q?=EC=9D=B4=EB=8F=99,=20=EC=A0=90=EC=88=98=20=ED=86=B5=20?=
=?UTF-8?q?=ED=8A=80=EA=B8=B0,=20=ED=81=B0=20=EC=88=9C=EA=B0=84=20?=
=?UTF-8?q?=EB=B0=B0=EB=84=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Claude Opus 5.5
---
apps/web/src/games/davinci-code/index.tsx | 253 +++++++++++---
apps/web/src/games/las-vegas/index.tsx | 303 +++++++++++++----
apps/web/src/games/mahjong/index.tsx | 387 ++++++++++++++++++---
apps/web/src/games/marble/events.test.ts | 46 +++
apps/web/src/games/marble/events.ts | 86 +++++
apps/web/src/games/marble/index.tsx | 395 ++++++++++++++++++----
apps/web/src/games/rummikub/index.tsx | 204 +++++++++--
apps/web/src/games/yacht/index.tsx | 156 +++++++--
8 files changed, 1557 insertions(+), 273 deletions(-)
create mode 100644 apps/web/src/games/marble/events.test.ts
create mode 100644 apps/web/src/games/marble/events.ts
diff --git a/apps/web/src/games/davinci-code/index.tsx b/apps/web/src/games/davinci-code/index.tsx
index 44915a8..58f37cd 100644
--- a/apps/web/src/games/davinci-code/index.tsx
+++ b/apps/web/src/games/davinci-code/index.tsx
@@ -1,10 +1,10 @@
/** 다빈치 코드 화면 (docs/games/davinci-code.md §9). */
-import { useEffect, useRef, useState } from 'react';
+import { useCallback, useEffect, useRef, useState, type CSSProperties } from 'react';
import type { DavinciGuess, DavinciOptions, DavinciTileView, DavinciView, PhaseKind, TColor, TileValue } from '@bg/games/davinci-code';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar } from '../../components/ui';
import { TurnTimer } from '../../components/TurnTimer';
-import { haptic, sounds } from '../../lib/feedback';
+import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
@@ -20,6 +20,60 @@ const valueKo = (v: TileValue) => (v === 'joker' ? '조커' : String(v));
const faceOf = (v: TileValue) => (v === 'joker' ? '−' : String(v));
const hiddenLeft = (row: DavinciTileView[]) => row.filter((t) => !t.revealed).length;
+/** Standing number-tile sounds (synthesized; the site volume is applied by feedback.ts). */
+const snd = {
+ /** A tile taken from the face-down pile. */
+ draw: () => {
+ noise(120, 0.08, 0, 'bandpass', 1200, 0.7);
+ tone(330, 60, 'triangle', 0.07, 100);
+ },
+ /** A tile slotted into a row: a solid "딸깍". */
+ set: (delay = 0) => {
+ noise(30, 0.15, delay, 'bandpass', 2600, 2);
+ tone(950, 38, 'triangle', 0.09, delay);
+ tone(260, 70, 'sine', 0.08, delay + 10);
+ },
+ /** A tile tipped over face up. */
+ flip: (delay = 0) => {
+ noise(45, 0.11, delay, 'highpass', 3000);
+ tone(620, 70, 'triangle', 0.08, delay + 25, { slideTo: 1240 });
+ },
+ /** Somebody guessed my tile right. */
+ ouch: (delay = 0) => tone(520, 200, 'triangle', 0.1, delay, { slideTo: 300 }),
+ /** A joker goes into a row (only when the viewer can see it is a joker). */
+ joker: (delay = 0) => [1568, 2093, 2637].forEach((f, i) => tone(f, 90, 'triangle', 0.05, delay + i * 60)),
+ /** A player is out. */
+ out: (delay = 0) => [523, 440, 349].forEach((f, i) => tone(f, 170, 'triangle', 0.09, delay + i * 130)),
+};
+
+/** A value that shows for `ms` and then clears itself (timer cleaned up on unmount). */
+function useTimed(): [T | null, (v: T, ms: number) => void] {
+ const [val, setVal] = useState(null);
+ const timer = useRef | undefined>(undefined);
+ useEffect(() => () => clearTimeout(timer.current), []);
+ const set = useCallback((v: T, ms: number) => {
+ clearTimeout(timer.current);
+ setVal(v);
+ timer.current = setTimeout(() => setVal(null), ms);
+ }, []);
+ return [val, set];
+}
+
+/** Wraps a number that bumps (anim-bump) whenever it changes after the first render. */
+function Bump({ value, children }: { value: number; children: React.ReactNode }) {
+ const prev = useRef(value);
+ const n = useRef(0);
+ if (prev.current !== value) {
+ prev.current = value;
+ n.current += 1;
+ }
+ return (
+
+ {children}
+
+ );
+}
+
function totalMsOf(v: DavinciView): number {
if (v.phase === 'chooseStart') return 15_000;
if ((v.idle[v.current] ?? 0) >= 3) return 5_000;
@@ -46,6 +100,10 @@ function guessLine(g: DavinciGuess, players: Record): string
}
const CSS = `
+.dv-bump { display: inline-block; }
+.dv-banner { position: fixed; z-index: 40; top: 34%; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 92vw; text-align: center;
+ padding: 12px 26px; border-radius: 18px; font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 900;
+ background: linear-gradient(160deg, #42454d, #141519); color: #fff; border: 2px solid #050505; box-shadow: 0 4px 0 rgba(0,0,0,.45), 0 12px 30px rgba(0,0,0,.35); }
.dv-board { width: 100%; max-width: 980px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; }
.dv-opps { display: grid; gap: 10px; }
.dv-player { background: var(--surface); border-radius: var(--radius-lg); padding: 10px 12px; box-shadow: var(--shadow); border: 3px solid transparent; }
@@ -74,13 +132,16 @@ const CSS = `
.dv-tile.secret { outline: 3px dashed var(--primary); outline-offset: 2px; }
.dv-tile.sm { --w: 30px; }
.dv-tile.lg { --w: 54px; }
-.dv-tile.hit { animation: dv-flip .5s ease-out, dv-hit 1.2s ease-out; }
-.dv-tile.miss { animation: dv-flip .5s ease-out, dv-miss 1.2s ease-out; }
-.dv-tile.new { animation: dv-drop .35s ease-out; }
-@keyframes dv-flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }
+.dv-tile.hit { animation: dv-flip .5s ease-out both, dv-hit 1.2s ease-out both; }
+.dv-tile.miss { animation: dv-flip .5s ease-out both, dv-miss 1.2s ease-out both; animation-delay: var(--anim-delay, 0ms); }
+.dv-tile.new { animation: dv-drop .38s ease-out both; animation-delay: var(--anim-delay, 0ms); }
+.dv-tile.shake { animation: anim-shake .45s ease, dv-miss 1.2s ease-out; }
+.dv-tile.deal { animation: anim-deal .38s cubic-bezier(0.2, 0.8, 0.3, 1.15) both; animation-delay: var(--anim-delay, 0ms); }
+.dv-tile.reveal { animation: dv-flip .45s ease-out both; animation-delay: var(--anim-delay, 0ms); }
+@keyframes dv-flip { 0% { transform: perspective(500px) rotateY(90deg); } 60% { transform: perspective(500px) rotateY(-12deg); } 100% { transform: perspective(500px) rotateY(0); } }
@keyframes dv-hit { 0%, 60% { box-shadow: 0 0 0 4px #22c55e, 0 0 18px 6px rgba(34,197,94,.7); } 100% { box-shadow: 0 3px 0 rgba(0,0,0,.35); } }
@keyframes dv-miss { 0%, 60% { box-shadow: 0 0 0 4px #ef4444, 0 0 18px 6px rgba(239,68,68,.6); } 100% { box-shadow: 0 3px 0 rgba(0,0,0,.35); } }
-@keyframes dv-drop { 0% { transform: translateY(-14px); opacity: .3; } 100% { transform: translateY(0); opacity: 1; } }
+@keyframes dv-drop { 0% { transform: translateY(-34px) scale(.85); opacity: .2; } 70% { transform: translateY(3px); opacity: 1; } 100% { transform: translateY(0); } }
.dv-pick { background: none; border: 0; padding: 3px; border-radius: 11px; cursor: pointer; color: inherit; }
.dv-pick:disabled { cursor: default; }
.dv-pick.can { box-shadow: 0 0 0 3px var(--primary); }
@@ -136,19 +197,26 @@ const CSS = `
.dv-board { max-height: none; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) {
- .dv-tile.hit, .dv-tile.miss, .dv-tile.new { animation: none; }
+ .dv-tile.hit, .dv-tile.miss, .dv-tile.new, .dv-tile.shake, .dv-tile.deal, .dv-tile.reveal { animation: none; }
+ .dv-banner { display: none; }
}
`;
// ---------------------------------------------------------------- tiles
-type Fx = 'hit' | 'miss' | 'new';
+type FxKind = 'hit' | 'miss' | 'new' | 'shake' | 'deal' | 'reveal';
+/** One tile's animation: kind, start delay, and a sequence number so the same kind can replay. */
+interface Fx {
+ k: FxKind;
+ d: number;
+ s: number;
+}
function Tile({ color, n, revealed, mine, size, fx }: { color: TColor; n?: TileValue; revealed: boolean; mine?: boolean; size?: 'sm' | 'lg'; fx?: Fx }) {
const known = n !== undefined;
- const cls = ['dv-tile', color, known ? '' : 'back', revealed ? 'open' : '', mine && !revealed ? 'secret' : '', size ?? '', fx ?? ''].filter(Boolean).join(' ');
+ const cls = ['dv-tile', color, known ? '' : 'back', revealed ? 'open' : '', mine && !revealed ? 'secret' : '', size ?? '', fx?.k ?? ''].filter(Boolean).join(' ');
return (
-
+
{known ? faceOf(n) : ?}
);
@@ -161,6 +229,8 @@ function tileLabel(t: DavinciTileView, pos: number, mine: boolean): string {
// ---------------------------------------------------------------- board
+const NO_FX = new Map();
+
interface Sel {
target: string;
index: number;
@@ -171,10 +241,12 @@ function DavinciBoard({ view: v, me, players, act, pending, deadline }: BoardPro
const myTurn = amPlayer && v.current === me && !!v.alive[me!] && v.phase !== 'chooseStart' && v.phase !== 'finished';
const [sel, setSel] = useState(null);
const [val, setVal] = useState(null);
- const [fx, setFx] = useState