그림 맞히기·클루: 그리기·차례 시간 무제한(출제자 정답 공개로 넘기기), 소리·움직임, 할리갈리·사과 게임 문서에 무제한

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 13:01:42 +09:00
parent bafbf95d98
commit b8966db2a6
15 changed files with 413 additions and 84 deletions

View File

@@ -118,11 +118,16 @@ export function reportsNeeded(s: S): number {
return Math.floor(voters / 2) + 1;
}
/** 무제한 drawings time their hints and the speed bonus as if they had the default 80 seconds. */
export const UNLIMITED_REF_MS = 80_000;
/** The drawing's length for hints / speed bonus (무제한: the 80 s reference). */
const drawLen = (t: Turn) => (t.endsAt === null ? UNLIMITED_REF_MS : t.endsAt - t.startedAt);
/** Next hint time while drawing (`hints: full` only): 50% → initials, 75% → one letter (skipped for ≤ 2 letters). */
export function nextHintAt(s: S): number | null {
const t = s.turn;
if (s.finished || t.phase !== 'drawing' || s.options.hints !== 'full' || !t.word) return null;
const dur = t.endsAt - t.startedAt;
const dur = drawLen(t);
if (t.hintStage === 0) return t.startedAt + Math.round(dur * 0.5);
if (t.hintStage === 1 && letters(t.word.word) > 2) return t.startedAt + Math.round(dur * 0.75);
return null;
@@ -178,7 +183,7 @@ function beginDrawing(s: S, index: number, ctx: Ctx): void {
t.choices = [];
t.phase = 'drawing';
t.startedAt = ctx.now;
t.endsAt = ctx.now + s.options.drawSeconds * 1000;
t.endsAt = s.options.drawSeconds === null ? null : ctx.now + s.options.drawSeconds * 1000;
t.hintStage = 0;
ctx.events.push({ type: 'drawing', no: t.no, drawer: t.drawer });
}
@@ -297,7 +302,7 @@ function guess(s: S, p: PlayerId, raw: string, ctx: Ctx): void {
if (j === 'correct') {
const k = t.solvers.length + 1;
let points = s.options.guessMode === 'multi' ? Math.max(10 - 2 * (k - 1), 4) : 10;
if (s.options.speedBonus) points += Math.round((5 * Math.max(0, t.endsAt - ctx.now)) / Math.max(1, t.endsAt - t.startedAt));
if (s.options.speedBonus) points += Math.round((5 * Math.max(0, t.startedAt + drawLen(t) - ctx.now)) / Math.max(1, drawLen(t)));
t.solvers.push({ id: p, at: ctx.now, points });
s.scores[p] = (s.scores[p] ?? 0) + points;
s.correctCounts[p] = (s.correctCounts[p] ?? 0) + 1;
@@ -318,7 +323,7 @@ function tick(s: S, ctx: Ctx): void {
const t = s.turn;
if (t.phase === 'choosing') {
// Only a disconnected drawer is timed out before the 10 s are up (room grace hook): skip them next time.
if (ctx.now < t.endsAt) markAway(s, t.drawer);
if (ctx.now < t.endsAt!) markAway(s, t.drawer);
beginDrawing(s, 0, ctx);
return;
}
@@ -328,7 +333,7 @@ function tick(s: S, ctx: Ctx): void {
advanceHint(s, ctx);
hinted = true;
}
if (ctx.now >= t.endsAt) return endDrawing(s, 'time', ctx);
if (t.endsAt !== null && ctx.now >= t.endsAt) return endDrawing(s, 'time', ctx);
if (hinted) return;
// Nothing was due: the drawer has been disconnected for DRAWER_AWAY_MS (§5.2) → 0 points, answer revealed.
markAway(s, t.drawer);
@@ -499,7 +504,7 @@ function buildView(s: S, viewer: PlayerId | null, withCanvas: boolean): Catchmin
drawer: t.drawer,
startedAt: t.startedAt,
endsAt: t.endsAt,
phaseMs: t.endsAt - t.startedAt,
phaseMs: t.endsAt === null ? null : t.endsAt - t.startedAt,
choices: isDrawer && t.phase === 'choosing' && !s.finished ? t.choices.map((w) => ({ word: w.word, category: w.category, difficulty: w.difficulty })) : null,
word: knows && t.word ? t.word.word : null,
category: knows && t.word ? t.word.category : null,
@@ -613,7 +618,7 @@ export const catchmind: GameDefinition<S, A, CatchmindView, CatchmindOptions> =
const len = [...cleanText(a.text)].length;
if (len < 1) return fail('내용을 입력해 주세요.');
if (len > GUESS_MAX) return fail(`${GUESS_MAX}자까지 쓸 수 있어요.`);
if (now !== undefined && now >= t.endsAt) return fail('시간이 다 됐어요.');
if (now !== undefined && t.endsAt !== null && now >= t.endsAt) return fail('시간이 다 됐어요.');
if (!rateOk(s.msgTimes[actor], GUESS_MSGS_PER_SEC, now)) return fail('조금 천천히 보내 주세요.');
return ok;
}
@@ -632,6 +637,11 @@ export const catchmind: GameDefinition<S, A, CatchmindView, CatchmindOptions> =
return ok;
case 'back':
return s.away.includes(actor) ? ok : fail('이미 게임에 참여하고 있어요.');
case 'giveUp':
if (actor !== t.drawer) return fail('출제자만 정답을 공개할 수 있어요.');
if (t.phase !== 'drawing') return fail('그리는 동안에만 정답을 공개할 수 있어요.');
if (s.options.drawSeconds !== null) return fail('제한 시간이 있는 방에서는 시간이 끝날 때까지 그려요.');
return ok;
case 'report':
if (!s.options.letterReport) return fail('이 방은 신고를 쓰지 않아요.');
if (t.phase !== 'drawing') return fail('그리는 동안에만 신고할 수 있어요.');
@@ -670,6 +680,9 @@ export const catchmind: GameDefinition<S, A, CatchmindView, CatchmindOptions> =
case 'back':
ctx.events.push({ type: 'back', player: actor });
break;
case 'giveUp':
endDrawing(s, 'giveUp', ctx);
break;
case 'report':
s.turn.reports.push(actor);
ctx.events.push({ type: 'report', count: s.turn.reports.length, need: reportsNeeded(s) });
@@ -702,7 +715,9 @@ export const catchmind: GameDefinition<S, A, CatchmindView, CatchmindOptions> =
deadline(s) {
if (s.finished) return null;
const h = nextHintAt(s);
return h === null ? s.turn.endsAt : Math.min(h, s.turn.endsAt);
const e = s.turn.endsAt;
if (h === null) return e;
return e === null ? h : Math.min(h, e);
},
/** The drawer's clock drives every server tick (choosing, hints, time up, reveal). */
@@ -768,7 +783,7 @@ export const catchmind: GameDefinition<S, A, CatchmindView, CatchmindOptions> =
out.push({ type: 'draw', op: { k: 'e', s: t.lastStroke } });
}
if (t.live > 0) out.push({ type: 'draw', op: { k: 'u' } }, { type: 'draw', op: { k: 'x' } });
out.push({ type: 'reaction', code: 'almost' });
out.push({ type: 'reaction', code: 'almost' }, { type: 'giveUp' });
} else {
out.push({ type: 'guess', text: t.word!.word }, { type: 'guess', text: '모르겠어요' }, { type: 'guess', text: `${t.word!.word} 맞나` }, { type: 'report' });
}