제한 시간 보정: 같은 단계의 채팅은 준 시간을 유지, 대표자 마감은 실제 답할 사람 기준, 바뀐 마감은 항상 화면에 전달; 이의있음! 재선택 창은 같은 후보여도 이의있음! 화면 뒤에

- room: reveal을 단계(마감·답할 사람·시간 재는 사람)가 바뀔 때만 새로 시작, clockExtra(대표자는 답할 사람들 중 가장 늦은 화면 기준),
  마지막으로 보낸 마감(sentDeadline)과 비교해 deadline 메시지
- 증강 윷놀이 AugSelect: 고를 때마다 새 키(같은 후보 재추첨도 새 창), 열림 조건에 !blocked, 고르는 중(pending)엔 자동으로 안 열림
- 테스트: 오목 마감 연장 전달, 라이어식 공통 단계(대표자 A·답할 사람 B·채팅), e2e 같은 후보 재선택·화면 타이머 = 서버 마감
- e2e 매지컬 애슬릿: 주사위·이동을 다 보여 준 뒤 다음 선택이 나와 한 판이 길어져 시간 한도 420초 → 900초

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-08 11:33:11 +09:00
parent fa53175f51
commit bc8cb7ae8c
6 changed files with 144 additions and 16 deletions

View File

@@ -117,6 +117,28 @@ describe('Room timers', () => {
expect(room.effectiveDeadline()).toBe(base + 2_000);
});
test('a deadline moved by a screen that reported before is told to every client (omok)', () => {
const { room, clock, conn } = harness();
const a = conn('A');
const b = conn('B');
room.join(a, 'player');
room.join(b, 'player');
room.configure('A', { options: { colorAssignment: 'hostBlack', timeControl: { kind: 'perMove', perMoveSec: 10 } } });
room.start('A');
room.settled('A', room.seq);
room.settled('B', room.seq);
room.act('A', 1, (room.def.legalActions!(room.game!.state, 'A') as unknown[])[0]);
room.clearTimer();
const base = clock.now() + 10_000;
const sent = b.msgs.filter((m) => m.t === 'state').at(-1) as { deadline: number };
expect(sent.deadline).toBe(base);
clock.advance(2_000);
room.settled('B', room.seq);
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base + 2_000);
for (const c of [a, b]) expect(c.msgs.at(-1)).toEqual({ t: 'deadline', deadline: base + 2_000 });
});
test('disconnected player is auto-acted after the grace period, not before the turn deadline rules', () => {
const { room, clock, conn } = harness();
const a = conn('A');
@@ -345,3 +367,63 @@ describe('Room chat (2026-10-13)', () => {
expect(typingOf(b)).toHaveLength(3);
});
});
describe('Room clocks after the animation (shared steps)', () => {
// Like 라이어 게임's last guess: everybody votes, then only the liar (B) answers, while the room times a stand-in (A).
const guess: AnyGameDefinition = {
id: 'guess',
nameKo: '맞히기',
minPlayers: 2,
maxPlayers: 2,
stateVersion: 1,
defaultOptions: {},
optionsSchema: z.object({}),
actionSchema: z.object({ type: z.enum(['go', 'chat']) }),
setup: ({ players, now }) => ({ players, step: 'vote', deadlineAt: now + 10_000, chats: 0 }),
validate: () => ({ ok: true }),
apply: (s: any, _p, a: any, { now }) => ({ state: a.type === 'go' ? { ...s, step: 'guess', deadlineAt: now + 10_000 } : { ...s, chats: s.chats + 1 }, events: [] }),
view: (s) => s,
activePlayers: (s: any) => (s.step === 'guess' ? [s.players[1]] : s.players),
timeoutPlayers: (s: any) => (s.step === 'guess' ? [s.players[0]] : s.players),
deadline: (s: any) => s.deadlineAt,
onTimeout: () => ({ type: 'chat' }),
result: () => null,
};
test('the stand-in\'s clock waits for the real answerer\'s screen, and a chat line keeps the time given', () => {
const { room, clock, conn } = harness({ guess });
const a = conn('A');
const b = conn('B');
room.join(a, 'player');
room.join(b, 'player');
room.start('A');
room.settled('A', room.seq);
room.settled('B', room.seq);
room.act('A', 1, { type: 'go' }); // → only B answers now, A is the timed stand-in
room.clearTimer();
const base = clock.now() + 10_000;
clock.advance(1_000);
room.settled('A', room.seq); // A's screen is quick: that must not start B's clock
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base + 15_000);
clock.advance(5_000);
room.settled('B', room.seq); // B's screen took 6 s
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base + 6_000);
expect(b.msgs.at(-1)).toEqual({ t: 'deadline', deadline: base + 6_000 });
// A chat line in the same step keeps B's 6 s.
clock.advance(1_000);
room.act('A', 2, { type: 'chat' });
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base + 6_000);
expect((b.msgs.filter((m) => m.t === 'state').at(-1) as { deadline: number }).deadline).toBe(base + 6_000);
room.settled('B', room.seq);
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base + 6_000);
// B still gets the whole 10 s from when the screen settled: nothing fires a moment before that.
clock.advance(base + 6_000 - clock.now() - 1);
room.onTimer();
room.clearTimer();
expect((room.game!.state as any).chats).toBe(1);
});
});