루미큐브·다빈치 코드·마작 차례 시간 '무제한' 옵션: 무제한이면 타이머·시간 초과 없음(연결 끊김 처리는 그대로)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 04:10:35 +09:00
parent f12cf12b84
commit f053b8fc6b
10 changed files with 139 additions and 38 deletions

View File

@@ -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) {

View File

@@ -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<typeof davinciOptionsSchema>;
@@ -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;
}