할리갈리·도블·사과 게임: 뒤집기 시간 무제한·사과 게임 무제한(여기까지), 소리·움직임
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,15 @@ export const AWAY_FLIP_MS = 1000;
|
||||
const LOG_KEEP = 30;
|
||||
const POINTS = [3, 2, 1];
|
||||
|
||||
export const flipMs = (o: HalliGalliOptions): number => (o.kidMode ? 8 : o.flipSeconds) * 1000;
|
||||
/** Flip time limit in ms; null = 무제한 (자동 뒤집기 still needs a pace: 3 s, 어린이 모드 8 s). */
|
||||
export function flipMs(o: HalliGalliOptions): number | null {
|
||||
if (o.flipSeconds === null) return o.autoFlip ? (o.kidMode ? 8 : 3) * 1000 : null;
|
||||
return (o.kidMode ? 8 : o.flipSeconds) * 1000;
|
||||
}
|
||||
const deadlineFrom = (o: HalliGalliOptions, from: number): number | null => {
|
||||
const ms = flipMs(o);
|
||||
return ms === null ? null : from + ms;
|
||||
};
|
||||
/** Public key of a visible card; secretsOf uses the same form so leak checks are meaningful. */
|
||||
export const cardKey = (id: number): string => `hg${id}`;
|
||||
|
||||
@@ -116,7 +124,7 @@ function othersClockwise(s: S, p: PlayerId): PlayerId[] {
|
||||
function startTurn(s: S, p: PlayerId, now: number): void {
|
||||
s.turn = p;
|
||||
s.turnStartedAt = now;
|
||||
s.turnDeadline = now + flipMs(s.options);
|
||||
s.turnDeadline = deadlineFrom(s.options, now);
|
||||
s.pendingFlip = null;
|
||||
}
|
||||
|
||||
@@ -327,7 +335,7 @@ function tick(s: S, actor: PlayerId, ctx: Ctx): void {
|
||||
if (ctx.now >= s.ringWindow.openedAt + RING_WINDOW_MS) resolveWindow(s, ctx);
|
||||
return;
|
||||
}
|
||||
const due = (s.pendingFlip !== null && ctx.now >= s.flipAllowedAt) || ctx.now >= Math.max(s.turnDeadline, s.flipAllowedAt);
|
||||
const due = (s.pendingFlip !== null && ctx.now >= s.flipAllowedAt) || (s.turnDeadline !== null && ctx.now >= Math.max(s.turnDeadline, s.flipAllowedAt));
|
||||
if (actor === s.turn || due) flipOrQueue(s, s.turn, ctx);
|
||||
}
|
||||
|
||||
@@ -413,7 +421,7 @@ export const halliGalli: GameDefinition<S, A, HalliGalliView, HalliGalliOptions>
|
||||
officialDuel: false,
|
||||
turn: first,
|
||||
turnStartedAt: now,
|
||||
turnDeadline: countdownEndsAt + flipMs(options),
|
||||
turnDeadline: deadlineFrom(options, countdownEndsAt),
|
||||
flipAllowedAt: countdownEndsAt,
|
||||
pendingFlip: null,
|
||||
tableVersion: 0,
|
||||
@@ -544,9 +552,9 @@ export const halliGalli: GameDefinition<S, A, HalliGalliView, HalliGalliOptions>
|
||||
if (s.ringWindow) c.push(s.ringWindow.openedAt + RING_WINDOW_MS);
|
||||
else {
|
||||
if (s.pendingFlip) c.push(s.flipAllowedAt);
|
||||
c.push(Math.max(s.turnDeadline, s.flipAllowedAt));
|
||||
if (s.turnDeadline !== null) c.push(Math.max(s.turnDeadline, s.flipAllowedAt));
|
||||
}
|
||||
return Math.min(...c);
|
||||
return c.length ? Math.min(...c) : null;
|
||||
},
|
||||
|
||||
/** Only the turn player's clock drives the server tick (flips, guard, bell window, time limit). */
|
||||
|
||||
Reference in New Issue
Block a user