카드 게임 시간 무제한(우노·뱅!·달무티·고스톱·도둑잡기·포커·바퀴벌레 포커·99), 공통 카드 움직임(card-fx), 우노·달무티·도둑잡기·포커 소리·애니메이션

- 무제한(null): 차례 시계·타임아웃 없음, 자리 비움만 짧은 시계, 연결 끊김은 방 유예 뒤 자동 행동 그대로
- 포커는 리바이 고르는 시간도 무제한 가능, 고스톱은 고·스톱 선택 시간도 무제한 가능, 뱅!은 반응 시간·캐릭터 고르기도
- card-fx: 날아가는 카드·칩(ghost), 제자리 날아오기, 배너, view 변화 감지 훅(처음 렌더·다시 보기는 건너뜀)

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

View File

@@ -1053,7 +1053,7 @@ describe('시간 초과·자리 비움·나가기 (§8.5)', () => {
const c = pool();
const g = c('gatling');
let s = rig({ players: basic({ A: { hand: [g] }, B: { life: 1, hand: [c('beer')] } }) });
const before = s.turn.deadline;
const before = s.turn.deadline!;
s = play(s, 'A', g);
const paused = clock;
s = act(s, 'B', { type: 'takeHit' });
@@ -1083,7 +1083,7 @@ describe('시간 초과·자리 비움·나가기 (§8.5)', () => {
// Next time it is A's turn the limit is 5 s.
for (const p of ['B', 'C', 'D']) x = act(x, p, { type: 'timeout' });
expect(x.turn.player).toBe('A');
expect(x.turn.deadline - clock).toBe(5000);
expect(x.turn.deadline! - clock).toBe(5000);
x = act(x, 'A', { type: 'endPlay' });
expect(pl(x, 'A').away).toBe(false);
});
@@ -1111,6 +1111,73 @@ describe('시간 초과·자리 비움·나가기 (§8.5)', () => {
expect(s.reactions.map((r) => (r.kind === 'indians' ? r.target : ''))).toEqual(['B', 'D']);
});
test('무제한 (turnSeconds·reactionSeconds null): 시계 없음, 연결이 끊긴 사람은 여전히 자동 처리, 자리 비움은 5초', () => {
const shape = (bang.optionsSchema as unknown as { shape: Record<string, { meta(): { labels?: Record<string, string> } | undefined }> }).shape;
expect(shape.turnSeconds!.meta()?.labels?.null).toBe('무제한');
expect(shape.reactionSeconds!.meta()?.labels?.null).toBe('무제한');
expect(bang.optionsSchema.safeParse({ turnSeconds: null, reactionSeconds: null }).success).toBe(true);
expect(bang.defaultOptions).toMatchObject({ turnSeconds: 60, reactionSeconds: 15 });
const options = { turnSeconds: null, reactionSeconds: null };
const c = pool();
const ind = c('indians');
const bg = c('bang');
let s = rig({ players: basic({ A: { hand: [ind, bg, c('mustang'), c('scope'), c('barrel'), c('jail'), c('volcanic'), c('beer'), c('beer')] }, C: { hand: [c('bang')] } }), options });
s.turn.deadline = null;
expect(bang.deadline!(s)).toBeNull();
expect(bang.timeoutPlayers!(s)).toEqual(['A']);
expect(bang.view(s, 'A')).toMatchObject({ turnDeadline: null, deadlineTotalMs: 5000, reactionTotalMs: 5000 });
// 인디언: every reaction is unclocked, so every responder is listed (the room's disconnect grace times each one out).
s = play(s, 'A', ind);
expect(s.reactions.map((r) => r.deadline)).toEqual([null, null, null]);
expect(bang.deadline!(s)).toBeNull();
expect(bang.timeoutPlayers!(s).sort()).toEqual(['B', 'C', 'D']);
expect(bang.view(s, 'B').reactions.every((r) => r.deadline === null)).toBe(true);
expect(JSON.parse(JSON.stringify(s))).toEqual(s);
s = act(s, 'C', { type: 'timeout' });
expect(s.log.some((e) => e.t === 'respond' && e.p === 'C' && e.why === 'indians')).toBe(true);
s = act(s, 'B', { type: 'timeout' });
expect(pl(s, 'B').life).toBe(pl(s, 'B').maxLife - 1);
s = act(s, 'D', { type: 'takeHit' });
// The turn clock stays off after the reactions (pause arithmetic skips null).
expect(s.reactions).toEqual([]);
expect(s.turn).toMatchObject({ deadline: null, pausedAt: null });
// 뱅! at an away player: only that reaction has a clock (5 s), so only they are timed.
pl(s, 'B').away = true;
s = play(s, 'A', bg, { target: 'B' });
expect(s.reactions[0]!.deadline).toBe(clock + 5000);
expect(bang.deadline!(s)).toBe(clock + 5000);
expect(bang.timeoutPlayers!(s)).toEqual(['B']);
s = act(s, 'B', { type: 'timeout' });
// Hand over the limit → discard phase, still unclocked; a timeout discards at random.
s = act(s, 'A', { type: 'endPlay' });
expect(s.turn).toMatchObject({ phase: 'discard', deadline: null });
s = act(s, 'A', { type: 'timeout' });
expect(s.turn.player).toBe('B');
// B is away → the short clock on its own turn; C (not away) gets no clock.
expect(s.turn.deadline! - clock).toBe(5000);
expect(bang.deadline!(s)).toBe(s.turn.deadline);
s = act(s, 'B', { type: 'timeout' });
expect(s.turn.player).toBe('C');
expect(s.turn.deadline).toBeNull();
});
test('무제한: choose2 캐릭터 고르기도 시계 없음, 시간 초과(연결 끊김) 시 첫 번째 카드', () => {
const players = ['A', 'B', 'C', 'D'];
let s = bang.setup({ players, options: bang.optionsSchema.parse({ characterDraft: 'choose2', turnSeconds: null }), rng: SeededRng.fromSeed(seedN(5)), now: 0 });
expect(s.reactions.every((r) => r.kind === 'choose2' && r.deadline === null)).toBe(true);
expect(bang.deadline!(s)).toBeNull();
expect(bang.timeoutPlayers!(s).sort()).toEqual(players);
const offer = pl(s, 'B').characterOffer!;
s = act(s, 'B', { type: 'timeout' });
expect(pl(s, 'B').character).toBe(offer[0]!);
for (const p of ['A', 'C', 'D']) s = act(s, p, { type: 'timeout' });
expect(s.turn.phase).not.toBe('draft');
expect(s.turn.deadline).toBeNull();
// Timed draft keeps its 30 s clock.
const t = bang.setup({ players, options: bang.optionsSchema.parse({ characterDraft: 'choose2' }), rng: SeededRng.fromSeed(seedN(5)), now: 0 });
expect(bang.deadline!(t)).toBe(30_000);
});
test('onTimeout은 모든 상태에서 합법 행동', () => {
for (let seed = 1; seed <= 40; seed++) {
const players = ['A', 'B', 'C', 'D', 'E'];
@@ -1261,6 +1328,7 @@ const PRESETS: Partial<BangOptions>[] = [
{ autoDefend: false, drawBeforeDeath: true },
{ beerAtFullHealth: true, selfTargetCatBalou: true, deputyCount7: true },
{ characterDraft: 'choose2', autoBarrel: false, autoDefend: false, reactionSeconds: 8 },
{ characterDraft: 'choose2', turnSeconds: null, reactionSeconds: null },
];
const SEEDS = playoutSeeds(1000);
@@ -1297,6 +1365,7 @@ describe(`무작위 대국 (시드 ${SEEDS}개, 4~7명)`, () => {
[5, { characterDraft: 'choose2' }],
[6, { autoBarrel: false }],
[7, { drawBeforeDeath: true }],
[5, { turnSeconds: null, reactionSeconds: null, characterDraft: 'choose2' }],
] as const)('randomPlayout with the engine per-step leak / round-trip checks: %i players', (n, opts) => {
const players = Array.from({ length: n }, (_, k) => `P${k}`);
const options = bang.optionsSchema.parse(opts);