카드 게임 시간 무제한(우노·뱅!·달무티·고스톱·도둑잡기·포커·바퀴벌레 포커·99), 공통 카드 움직임(card-fx), 우노·달무티·도둑잡기·포커 소리·애니메이션
- 무제한(null): 차례 시계·타임아웃 없음, 자리 비움만 짧은 시계, 연결 끊김은 방 유예 뒤 자동 행동 그대로 - 포커는 리바이 고르는 시간도 무제한 가능, 고스톱은 고·스톱 선택 시간도 무제한 가능, 뱅!은 반응 시간·캐릭터 고르기도 - card-fx: 날아가는 카드·칩(ghost), 제자리 날아오기, 배너, view 변화 감지 훅(처음 렌더·다시 보기는 건너뜀) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -389,6 +389,23 @@ describe('시간 초과 (§8.5)', () => {
|
||||
expect(game.deadline!(back)! - back.turnStartedAt).toBe(30_000);
|
||||
});
|
||||
|
||||
test('무제한 (turnSeconds null): 마감 없음, 그래도 시간 초과(연결 끊김)는 대신 두고 자리 비움이면 5초', () => {
|
||||
expect(game.optionsSchema.safeParse({ turnSeconds: null }).success).toBe(true);
|
||||
const t0 = rigged({ A: ['rat', 'fly'], B: ['bat'], C: ['toad'] }, { turnSeconds: null });
|
||||
expect(game.deadline!(t0)).toBeNull();
|
||||
expect(game.view(t0, 'A').turnMs).toBe(0);
|
||||
const third = actE({ ...t0, timeoutsInRow: { A: 2, B: 0, C: 0 } }, 'A', { type: 'timeout' });
|
||||
expect(third.events.map((e) => e.type)).toEqual(['timeout', 'away', 'offer']);
|
||||
// B (not away) now holds the card: still no clock.
|
||||
expect(game.deadline!(third.state)).toBeNull();
|
||||
const w = { ...t0, away: { A: true, B: false, C: false } };
|
||||
expect(game.deadline!(w)! - w.turnStartedAt).toBe(5000);
|
||||
expect(game.view(w, 'A').turnMs).toBe(5000);
|
||||
const back = act(w, 'A', { type: 'offer', cardId: 'rat-0', to: 'B', claim: 'rat' });
|
||||
expect(back.away.A).toBe(false);
|
||||
expect(game.deadline!(back)).toBeNull();
|
||||
});
|
||||
|
||||
test('모두 무응답이어도 게임이 끝남; 매 상태에서 onTimeout이 합법', () => {
|
||||
for (let seed = 1; seed <= 40; seed++) {
|
||||
const n = 2 + (seed % 5);
|
||||
@@ -538,7 +555,7 @@ function cfg(i: number): { players: string[]; options: CockroachOptions } {
|
||||
claimHistory: i % 3 !== 0,
|
||||
eightKindsRule: i % 7 === 0,
|
||||
twoPlayerPass: i % 2 === 0,
|
||||
turnSeconds: ([15, 30, 60] as const)[i % 3],
|
||||
turnSeconds: ([15, 30, 60, null] as const)[i % 4],
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,10 +45,11 @@ export const cockroachOptionsSchema = z.object({
|
||||
.union([z.literal('auto'), z.literal(3), z.literal(4), z.literal(5)])
|
||||
.default('auto')
|
||||
.meta({ title: '같은 벌레가 몇 장 모이면 패배', labels: { auto: '자동(2명 5장, 3~6명 4장)', 3: '3장(짧은 게임)', 4: '4장', 5: '5장' } }),
|
||||
/** null = 무제한 (no clock; a dropped connection still gets an auto move after the room's grace time). */
|
||||
turnSeconds: z
|
||||
.union([z.literal(15), z.literal(30), z.literal(60)])
|
||||
.union([z.literal(15), z.literal(30), z.literal(60), z.literal(null)])
|
||||
.default(30)
|
||||
.meta({ title: '건네기·판정 제한 시간', labels: { 15: '15초', 30: '30초', 60: '60초' } }),
|
||||
.meta({ title: '건네기·판정 제한 시간', labels: { 15: '15초', 30: '30초', 60: '60초', null: '무제한' } }),
|
||||
claimHistory: z.boolean().default(true).meta({ title: '이번 라운드 주장 기록 보이기' }),
|
||||
quickChat: z.boolean().default(true).meta({ title: '빠른 말 버튼("정말이야!", "의심스러운데?")' }),
|
||||
eightKindsRule: z.boolean().default(false).meta({ title: '앞마당에 8종을 모두 모아도 패배(하우스 룰)' }),
|
||||
@@ -200,6 +201,7 @@ export interface CockroachView {
|
||||
said: Said[];
|
||||
removedCount: number;
|
||||
turnStartedAt: number;
|
||||
/** Clock length in ms; 0 = 무제한 (no clock). */
|
||||
turnMs: number;
|
||||
seq: number;
|
||||
final: CockroachFinal | null;
|
||||
@@ -266,9 +268,11 @@ function peekBlock(s: CockroachState): string | null {
|
||||
return passTargets(s, r.holder!).length === 0 ? '모두 이 카드를 이미 봐서 넘길 사람이 없어요. 진짜인지 거짓인지 골라 주세요.' : null;
|
||||
}
|
||||
|
||||
function turnMs(s: CockroachState): number {
|
||||
/** Clock for the waiting player in ms; null = 무제한 (an away player still gets the short clock). */
|
||||
function turnMs(s: CockroachState): number | null {
|
||||
const p = waiting(s)[0];
|
||||
return p && s.away[p] ? AWAY_MS : s.options.turnSeconds * 1000;
|
||||
if (p && s.away[p]) return AWAY_MS;
|
||||
return s.options.turnSeconds === null ? null : s.options.turnSeconds * 1000;
|
||||
}
|
||||
|
||||
function newRound(s: CockroachState, starter: PlayerId): void {
|
||||
@@ -576,7 +580,7 @@ export const cockroachPoker: GameDefinition<CockroachState, CockroachAction, Coc
|
||||
said: s.said,
|
||||
removedCount: s.removed.length,
|
||||
turnStartedAt: s.turnStartedAt,
|
||||
turnMs: turnMs(s),
|
||||
turnMs: turnMs(s) ?? 0,
|
||||
seq: s.seq,
|
||||
final: s.final,
|
||||
revealed: over ? { hands: s.hands, removed: s.removed } : null,
|
||||
@@ -586,7 +590,8 @@ export const cockroachPoker: GameDefinition<CockroachState, CockroachAction, Coc
|
||||
activePlayers: waiting,
|
||||
|
||||
deadline(s) {
|
||||
return finished(s) ? null : s.turnStartedAt + turnMs(s);
|
||||
const ms = turnMs(s);
|
||||
return finished(s) || ms === null ? null : s.turnStartedAt + ms;
|
||||
},
|
||||
|
||||
timeoutPlayers: waiting,
|
||||
|
||||
Reference in New Issue
Block a user