루미큐브·다빈치 코드·마작 차례 시간 '무제한' 옵션: 무제한이면 타이머·시간 초과 없음(연결 끊김 처리는 그대로)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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<DavinciOptions>) {
|
||||
<Seg label="시작 타일 수" value={o.startTiles} options={[['auto', '자동(2·3명 4개, 4명 3개)'], [3, '3개'], [4, '4개'], [5, '5개']]} onChange={(startTiles) => set({ startTiles })} />
|
||||
</Field>
|
||||
<Field label="추리 제한 시간">
|
||||
<Seg label="추리 제한 시간" value={o.turnSeconds} options={[[20, '20초'], [30, '30초'], [45, '45초'], [60, '60초']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
<Seg
|
||||
label="추리 제한 시간"
|
||||
value={o.turnSeconds === null ? 'none' : String(o.turnSeconds)}
|
||||
options={[['20', '20초'], ['30', '30초'], ['45', '45초'], ['60', '60초'], ['none', '무제한']]}
|
||||
onChange={(k) => set({ turnSeconds: k === 'none' ? null : (Number(k) as 20 | 30 | 45 | 60) })}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="가능한 숫자 후보 표시(초보 도움)">
|
||||
<Seg label="후보 표시" value={o.deductionHelper} options={[[false, '끄기'], [true, '켜기']]} onChange={(deductionHelper) => 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 }) {
|
||||
이미 공개된 같은 색·같은 숫자를 말하는 것처럼 말이 안 되는 추리도 할 수는 있어요(화면에서 알려 줘요). 오른쪽 <strong>추리 기록</strong>에서 누가 어떤 숫자를 말했는지 다시 볼 수 있어요.
|
||||
</p>
|
||||
<p className="muted">
|
||||
시간 안에 추리하지 않으면 공개된 정보로 가장 가능성 있는 작은 숫자를 자동으로 말해요. 세 번 연속 시간을 넘기면 제한 시간이 5초로 줄어요. 결과 화면에는 각자 맞힌 횟수와 추리 횟수가 나와요.
|
||||
{o?.turnSeconds === null
|
||||
? '시간 제한이 없어서 천천히 생각해도 돼요. 연결이 끊긴 채로 오래 지나면 공개된 정보로 가장 가능성 있는 작은 숫자를 자동으로 말해요.'
|
||||
: '시간 안에 추리하지 않으면 공개된 정보로 가장 가능성 있는 작은 숫자를 자동으로 말해요. 세 번 연속 시간을 넘기면 제한 시간이 5초로 줄어요.'}{' '}
|
||||
결과 화면에는 각자 맞힌 횟수와 추리 횟수가 나와요.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1065,8 +1065,8 @@ function Options({ value: o, onChange }: OptionsProps<MahjongOptions>) {
|
||||
<Field label="대국 길이" help="동풍전 약 25분, 반장전 약 50분">
|
||||
<Seg label="대국 길이" value={o.length} options={[['tonpuu', '동풍전'], ['hanchan', '반장전']]} onChange={(length) => set({ length })} />
|
||||
</Field>
|
||||
<Field label="타패 제한 시간">
|
||||
<Seg label="타패 제한 시간" value={o.turnSeconds} options={[[10, '10초'], [15, '15초'], [20, '20초'], [30, '30초'], [60, '60초']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
<Field label="타패 제한 시간" help={o.turnSeconds === 0 ? '무제한이면 울기·론 응답도 시간 없이 기다려요.' : undefined}>
|
||||
<Seg label="타패 제한 시간" value={o.turnSeconds} options={[[10, '10초'], [15, '15초'], [20, '20초'], [30, '30초'], [60, '60초'], [0, '무제한']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
</Field>
|
||||
<Field label="초보 모드 허용" help="켜면 각자 대기패·역 힌트를 켜고 끌 수 있어요.">
|
||||
<Seg label="초보 모드 허용" value={o.beginnerMode} options={onOff} onChange={(beginnerMode) => set({ beginnerMode })} />
|
||||
@@ -1138,12 +1138,16 @@ function Options({ value: o, onChange }: OptionsProps<MahjongOptions>) {
|
||||
<Field label="연풍패 머리 부수">
|
||||
<Seg label="연풍패 머리 부수" value={o.renpuuPairFu} options={[[2, '2부'], [4, '4부']]} onChange={(renpuuPairFu) => set({ renpuuPairFu })} />
|
||||
</Field>
|
||||
<Field label="울기·론 응답 시간">
|
||||
<Seg label="울기·론 응답 시간" value={o.claimSeconds} options={[[5, '5초'], [8, '8초'], [12, '12초'], [20, '20초']]} onChange={(claimSeconds) => set({ claimSeconds })} />
|
||||
</Field>
|
||||
<Field label="개인 예비 시간" help="타패 시간을 넘기면 깎이고, 매 국 5초씩 다시 채워져요.">
|
||||
<Seg label="개인 예비 시간" value={o.timeBankSeconds} options={[[0, '없음'], [30, '30초'], [60, '60초'], [120, '120초']]} onChange={(timeBankSeconds) => set({ timeBankSeconds })} />
|
||||
</Field>
|
||||
{o.turnSeconds !== 0 && (
|
||||
<>
|
||||
<Field label="울기·론 응답 시간">
|
||||
<Seg label="울기·론 응답 시간" value={o.claimSeconds} options={[[5, '5초'], [8, '8초'], [12, '12초'], [20, '20초']]} onChange={(claimSeconds) => set({ claimSeconds })} />
|
||||
</Field>
|
||||
<Field label="개인 예비 시간" help="타패 시간을 넘기면 깎이고, 매 국 5초씩 다시 채워져요.">
|
||||
<Seg label="개인 예비 시간" value={o.timeBankSeconds} options={[[0, '없음'], [30, '30초'], [60, '60초'], [120, '120초']]} onChange={(timeBankSeconds) => set({ timeBankSeconds })} />
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
<Field label="(3인) 쯔모 지불">
|
||||
<Seg label="3인 쯔모 지불" value={o.sanmaTsumo} options={[['tsumoLoss', '쯔모손'], ['northBisection', '북가 몫 반씩']]} onChange={(sanmaTsumo) => set({ sanmaTsumo })} />
|
||||
</Field>
|
||||
@@ -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(' · ');
|
||||
}
|
||||
|
||||
|
||||
@@ -709,7 +709,12 @@ function Options({ value: o, onChange }: OptionsProps<RummikubOptions>) {
|
||||
<Seg label="첫 등록 최소 점수" value={o.initialMeldPoints} options={[[0, '없음'], [20, '20점'], [30, '30점(공식)'], [50, '50점']]} onChange={(initialMeldPoints) => set({ initialMeldPoints })} />
|
||||
</Field>
|
||||
<Field label="한 차례 제한 시간" help="어르신이나 아이와 할 때는 넉넉하게 골라 주세요.">
|
||||
<Seg label="한 차례 제한 시간" value={o.turnSeconds} options={[[60, '1분'], [90, '1분 30초'], [120, '2분'], [180, '3분']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
<Seg
|
||||
label="한 차례 제한 시간"
|
||||
value={o.turnSeconds === null ? 'none' : String(o.turnSeconds)}
|
||||
options={[['60', '1분'], ['90', '1분 30초'], ['120', '2분'], ['180', '3분'], ['none', '무제한']]}
|
||||
onChange={(k) => set({ turnSeconds: k === 'none' ? null : (Number(k) as 60 | 90 | 120 | 180) })}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="판 수">
|
||||
<Seg label="판 수" value={o.gamesPerMatch} options={[['1', '1판'], ['players', '인원수만큼'], ['2', '2판'], ['3', '3판'], ['4', '4판']]} onChange={(gamesPerMatch) => set({ gamesPerMatch })} />
|
||||
@@ -748,8 +753,9 @@ function Options({ value: o, onChange }: OptionsProps<RummikubOptions>) {
|
||||
|
||||
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 }) {
|
||||
<strong>바닥 고치기</strong>: 첫 등록 뒤에는 바닥의 묶음을 쪼개고 합치고 옮겨서 내 타일을 끼워 넣을 수 있어요. 예를 들어 빨강 4-5-6-7-8 사이에 내 빨강 6을 넣어 4-5-6과 6-7-8로 나눌 수 있어요. 바닥 타일은 받침대로 가져올 수 없고, 조커를 빼 왔다면 같은 차례에 다시 바닥에 써야 해요.
|
||||
</p>
|
||||
<p>
|
||||
<strong>시간</strong>: 한 차례는 {o ? `${o.turnSeconds}초` : '1분'}예요. 시간이 다 되면{' '}
|
||||
<strong>시간</strong>: {o?.turnSeconds === null ? '이 방은 시간 제한이 없어요. 연결이 끊긴 채로 오래 지나면' : `한 차례는 ${o ? `${o.turnSeconds}초` : '1분'}예요. 시간이 다 되면`}{' '}
|
||||
{o?.timeoutValidDraft === 'revert' ? '놓아 둔 타일을 되돌리고 1장을 가져와요' : '올바르게 놓아 둔 타일은 자동으로 확정돼요'}. 묶음이 틀린 채로 끝나면 처음으로 되돌리고 {o?.invalidTimeoutPenalty ?? 3}장을 가져와요.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<MahjongState, MahjongAction, MahjongView, M
|
||||
const h = s.hand;
|
||||
// Time bank use for own-turn decisions.
|
||||
if (h && s.phase === 'playing' && h.turn === seat && (h.stage === 'afterDraw' || h.stage === 'afterCall') && a.type !== 'setPref' && a.type !== 'leave') {
|
||||
if (a.type === 'timeout') s.timeBank[seat] = s.autoPilot[seat] ? s.timeBank[seat]! : 0;
|
||||
if (unlimited(s)) {
|
||||
// No clock, nothing to spend.
|
||||
} else if (a.type === 'timeout') s.timeBank[seat] = s.autoPilot[seat] ? s.timeBank[seat]! : 0;
|
||||
else {
|
||||
const over = now - h.turnStartedAt - s.options.turnSeconds * 1000;
|
||||
if (over > 0) s.timeBank[seat] = Math.max(0, s.timeBank[seat]! - over);
|
||||
@@ -1498,7 +1508,7 @@ export const mahjong: GameDefinition<MahjongState, MahjongAction, MahjongView, M
|
||||
const due = c.decided ? c.minUntil : c.deadline;
|
||||
// The discarder's timer only runs once the outcome is settled; it closes the window (also early, when the
|
||||
// server fires it for a disconnected discarder — otherwise that timer would fire again and again).
|
||||
if (now >= 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' };
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -20,16 +20,16 @@ import {
|
||||
|
||||
export * from './rules';
|
||||
|
||||
const lit = <T extends number>(...vals: T[]) =>
|
||||
const lit = <T extends number | null>(...vals: T[]) =>
|
||||
z.union(vals.map((v) => z.literal(v)) as unknown as [z.ZodLiteral<T>, z.ZodLiteral<T>, ...z.ZodLiteral<T>[]]);
|
||||
|
||||
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<RummikubState, RummikubAction, RummikubVie
|
||||
current: playing ? s.current : null,
|
||||
turnNo: s.turnNo,
|
||||
turnStartedAt: s.turnStartedAt,
|
||||
turnMs: (s.timeoutsInRow[s.current] ?? 0) >= 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<RummikubState, RummikubAction, RummikubVie
|
||||
},
|
||||
|
||||
deadline(s) {
|
||||
if (s.phase === 'playing') return s.turnStartedAt + ((s.timeoutsInRow[s.current] ?? 0) >= 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;
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user