마피아: 단계별 시간 무제한(토론·지목 투표·반론·찬반·밤, 모두 마치면 넘어감·연결 끊긴 사람은 유예 뒤 넘김), 밤·아침·판결 소리, 움직임
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import { openDb } from '../db';
|
||||
import { Room, type Conn, type RoomConfig } from './room';
|
||||
import { RoomStore } from './store';
|
||||
|
||||
function harness(players: string[]) {
|
||||
function harness(players: string[], options: Record<string, unknown> = {}) {
|
||||
const db = openDb(':memory:');
|
||||
const store = new RoomStore(db);
|
||||
let now = 1_000_000;
|
||||
@@ -16,7 +16,7 @@ function harness(players: string[]) {
|
||||
const deps = { store, games, users: { publicUser: (id: string) => ({ id, nickname: id, avatar: null, kind: 'guest' as const }) }, now: clock.now };
|
||||
const config: RoomConfig = {
|
||||
gameId: 'mafia',
|
||||
options: { ...games.mafia.defaultOptions, firstPhase: 'night' },
|
||||
options: { ...games.mafia.defaultOptions, firstPhase: 'night', ...options },
|
||||
maxPlayers: players.length,
|
||||
visibility: 'private',
|
||||
allowSpectators: true,
|
||||
@@ -67,4 +67,23 @@ describe('마피아 room flow', () => {
|
||||
expect(state().phase.kind).toBe('discussion');
|
||||
expect(state().day).toBe(2);
|
||||
});
|
||||
|
||||
test('밤 시간 무제한: 타이머 없이 모두 밤 마치기를 누를 때까지, 연결이 끊긴 사람은 유예 시간 뒤 넘김', () => {
|
||||
const { room, clock, conns, state } = harness(['A', 'B', 'C', 'D'], { nightSeconds: null });
|
||||
expect(room.start('A')).toBeNull();
|
||||
clock.advance(8_000);
|
||||
room.onTimer();
|
||||
expect(state().phase.kind).toBe('night');
|
||||
expect(room.effectiveDeadline()).toBeNull();
|
||||
let cs = 10;
|
||||
for (const p of ['A', 'B', 'C']) room.act(p, ++cs, { type: 'readyEarly' });
|
||||
clock.advance(3_600_000);
|
||||
room.onTimer();
|
||||
expect(state().phase.kind).toBe('night');
|
||||
room.disconnect(conns.D!);
|
||||
expect(room.effectiveDeadline()).toBe(clock.now() + 60_000);
|
||||
clock.advance(60_000);
|
||||
room.onTimer();
|
||||
expect(state().phase.kind).toBe('discussion');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user