결과는 움직임이 끝날 때까지(시간 상한 없음), 제한 시간은 각자 화면이 연출을 다 보여 준 뒤부터

- lib/motion: useMotionSettled에서 12초 상한을 없앰(명시한 maxMs만)
- 서버: 클라이언트 settled(seq)를 받으면 그 사람의 제한 시간을 연출에 걸린 만큼 늦춤(보고 전에는 최대 15초×속도,
  보고한 적 없는 화면·컴퓨터·실시간 게임은 예전 그대로), 마감이 바뀌면 deadline 메시지
- 바퀴벌레 포커: 게임을 끝낸 판정은 패배 배너까지 다 끝난 뒤에 끝 화면
- 증강 윷놀이: 선택 창 열림을 후보 묶음마다 따로, 이의있음! 재선택 창은 이의있음! 화면이 사라진 뒤에
- e2e/motion.e2e.ts: 30초 움직임·바퀴벌레 포커 마지막 판정·이의있음! 재선택·다빈치 ×1/8 회귀 확인, 방 타이머 단위 테스트

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-08 10:40:48 +09:00
parent 4e0eb4d52c
commit fa53175f51
18 changed files with 371 additions and 22 deletions

View File

@@ -61,6 +61,62 @@ describe('Room timers', () => {
expect((room.game!.state as any).moves[0].auto).toBe(true);
});
test('a turn clock starts when the player\'s screen has finished animating (settled), not before', () => {
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 } } });
expect(room.start('A')).toBeNull();
room.clearTimer();
const base = clock.now() + 10_000;
// A screen that never reported keeps the old clock (pages from before this change, computers).
expect(room.effectiveDeadline()).toBe(base);
// A's screen finishes the opening 1.5 s later: A's clock is 1.5 s longer, and everyone is told the new deadline.
clock.advance(1_500);
room.settled('A', room.seq);
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base + 1_500);
expect(b.msgs.at(-1)).toEqual({ t: 'deadline', deadline: base + 1_500 });
clock.advance(10_000 - 1);
room.onTimer();
room.clearTimer();
expect((room.game!.state as any).moves).toHaveLength(0);
clock.advance(1);
room.onTimer();
room.clearTimer();
expect((room.game!.state as any).moves).toHaveLength(1);
// Next state, B to move: a late report for an older state counts nothing, and B (who never reported) keeps the plain clock.
const seq = room.seq;
const base2 = clock.now() + 10_000;
room.settled('A', seq - 1);
expect(room.effectiveDeadline()).toBe(base2); // B is to move and B never reported: B's clock is unchanged
room.settled('B', seq);
room.clearTimer();
expect(room.effectiveDeadline()).toBe(base2);
});
test('a player who reported once but not yet for this state: the timer waits for the screen (at most 15 s at ×1)', () => {
const { room, clock, conn } = harness();
room.join(conn('A'), 'player');
room.join(conn('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.clearTimer();
// A plays; B (to move) has not reported this new state yet
room.act('A', 1, (room.def.legalActions!(room.game!.state, 'A') as unknown[])[0]);
room.clearTimer();
const base = clock.now() + 10_000;
expect(room.effectiveDeadline()).toBe(base + 15_000);
clock.advance(2_000);
room.settled('B', room.seq);
room.clearTimer();
expect(room.effectiveDeadline()).toBe(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');