카드 게임 시간 무제한(우노·뱅!·달무티·고스톱·도둑잡기·포커·바퀴벌레 포커·99), 공통 카드 움직임(card-fx), 우노·달무티·도둑잡기·포커 소리·애니메이션
- 무제한(null): 차례 시계·타임아웃 없음, 자리 비움만 짧은 시계, 연결 끊김은 방 유예 뒤 자동 행동 그대로 - 포커는 리바이 고르는 시간도 무제한 가능, 고스톱은 고·스톱 선택 시간도 무제한 가능, 뱅!은 반응 시간·캐릭터 고르기도 - card-fx: 날아가는 카드·칩(ghost), 제자리 날아오기, 배너, view 변화 감지 훅(처음 렌더·다시 보기는 건너뜀) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -776,6 +776,29 @@ describe('시간 초과·연결 끊김 (§8.5)', () => {
|
||||
s = act(s, 'A', play(gostop.view(s, 'A').myHand![0]!.card.id), 14_000);
|
||||
expect(s.autoPilot[0]).toBe(false);
|
||||
});
|
||||
test('무제한 (turnSeconds·decisionSeconds null): 마감 없음, 그래도 시간 초과(연결 끊김)는 처리되고 2회면 autoPilot 2초', () => {
|
||||
expect(gostop.optionsSchema.safeParse({ turnSeconds: null, decisionSeconds: null }).success).toBe(true);
|
||||
expect(gostop.optionsSchema.safeParse({ turnSeconds: 7 }).success).toBe(false);
|
||||
let s = rigged(2, { hands: [[2, 6, 10], [11, 15, 19]], floor: [20], deck: [24, 36, 37, 38, 39, 42, 43] }, { turnSeconds: null, decisionSeconds: null });
|
||||
expect(gostop.deadline!(s)).toBeNull();
|
||||
expect(gostop.view(s, 'A').deadline).toBeNull();
|
||||
s = act(s, 'A', { type: 'timeout' }, 10_000);
|
||||
expect(s.autoPilot[0]).toBe(false);
|
||||
expect(s.deadline).toBeNull();
|
||||
s = act(s, 'B', play(11), 11_000);
|
||||
s = act(s, 'A', { type: 'timeout' }, 12_000);
|
||||
expect(s.autoPilot[0]).toBe(true);
|
||||
s = act(s, 'B', play(15), 13_000);
|
||||
expect(s.deadline).toBe(13_000 + 2_000);
|
||||
s = act(s, 'A', play(gostop.view(s, 'A').myHand![0]!.card.id), 14_000);
|
||||
expect(s.autoPilot[0]).toBe(false);
|
||||
// 고·스톱 같은 선택 단계도 마감이 없어요.
|
||||
const g = rigged(2, { hands: [[25, 2], [11, 15]], floor: [24], deck: [36, 37, 38], captured: [[0, 8, 28, 1, 5, 9, 13, 33], [44]] }, { decisionSeconds: null });
|
||||
const after = act(g, 'A', play(25), 20_000);
|
||||
expect(after.round!.step).toBe('goStop');
|
||||
expect(after.deadline).toBeNull();
|
||||
expect(act(after, 'A', { type: 'timeout' }).round!.outcome?.type).toBe('stop');
|
||||
});
|
||||
test('나가기: autoPilot, 끊긴 사람 차례 마감 2초, 결과 화면 준비에서 빠짐', () => {
|
||||
let s = rigged(2, { hands: [[2, 6], [11, 15]], floor: [20], deck: [24, 36, 37, 38] });
|
||||
s = act(s, 'A', { type: 'leave' }, 5000);
|
||||
|
||||
@@ -89,7 +89,9 @@ function deadlineMs(s: GostopState): number | null {
|
||||
if (w.length === 0) return null;
|
||||
if (w.every((i) => s.autoPilot[i])) return AUTO_MS;
|
||||
const step = s.round!.step;
|
||||
return (step === 'play' ? s.rules.turnSeconds : s.rules.decisionSeconds) * 1000;
|
||||
const sec = step === 'play' ? s.rules.turnSeconds : s.rules.decisionSeconds;
|
||||
// 무제한: no clock (the room still times out a dropped connection after its grace time).
|
||||
return sec === null ? null : sec * 1000;
|
||||
}
|
||||
|
||||
function refreshDeadline(s: GostopState, now: number): void {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from 'zod';
|
||||
import type { PlayerId } from '@bg/engine';
|
||||
import type { BonusSetting, CardId, CardView } from './cards';
|
||||
|
||||
const lit = <T extends string | number>(...vals: T[]) =>
|
||||
const lit = <T extends string | number | null>(...vals: T[]) =>
|
||||
z.union(vals.map((v) => z.literal(v)) as unknown as [z.ZodLiteral<T>, z.ZodLiteral<T>, ...z.ZodLiteral<T>[]]);
|
||||
|
||||
export const gostopOptionsSchema = z.object({
|
||||
@@ -58,12 +58,14 @@ export const gostopOptionsSchema = z.object({
|
||||
.enum(['gwang', 'gwangPlus'])
|
||||
.default('gwang')
|
||||
.meta({ title: '팔 수 있는 패', labels: { gwang: '광만', gwangPlus: '광 + 쌍피·국진·보너스' } }),
|
||||
turnSeconds: lit(5, 10, 15, 20, 30, 60)
|
||||
/** null = 무제한 (no clock; a dropped connection still gets auto moves after the room's grace time, autoPilot keeps 2초). */
|
||||
turnSeconds: lit(5, 10, 15, 20, 30, 60, null)
|
||||
.default(15)
|
||||
.meta({ title: '한 턴 제한 시간', labels: { 5: '5초', 10: '10초', 15: '15초', 20: '20초', 30: '30초', 60: '60초' } }),
|
||||
decisionSeconds: lit(5, 10, 15, 20, 30)
|
||||
.meta({ title: '한 턴 제한 시간', labels: { 5: '5초', 10: '10초', 15: '15초', 20: '20초', 30: '30초', 60: '60초', null: '무제한' } }),
|
||||
/** null = 무제한 (고·스톱, 뒤집은 패 고르기, 총통, 광팔기, 국진). */
|
||||
decisionSeconds: lit(5, 10, 15, 20, 30, null)
|
||||
.default(10)
|
||||
.meta({ title: '고·스톱·선택 제한 시간', labels: { 5: '5초', 10: '10초', 15: '15초', 20: '20초', 30: '30초' } }),
|
||||
.meta({ title: '고·스톱·선택 제한 시간', labels: { 5: '5초', 10: '10초', 15: '15초', 20: '20초', 30: '30초', null: '무제한' } }),
|
||||
hints: z.boolean().default(true).meta({ title: '먹을 수 있는 패·족보 힌트' }),
|
||||
});
|
||||
export type GostopOptions = z.infer<typeof gostopOptionsSchema>;
|
||||
|
||||
Reference in New Issue
Block a user