채팅 연타가 몇 초씩 밀리던 문제: 브라우저가 0.55초(마피아·라이어 0.75초)에 한 줄씩만 내보내던 대기열과 게임 채팅 0.7초 간격 제한을 없애고, 방 채팅·마피아·라이어가 같은 속도 규칙(한 번에 6줄, 그 뒤 0.3초에 한 줄)을 쓰게. 사람이 치는 속도로는 기다리지 않고 바로 올라감
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
* and the liar is told "시민" like everybody else). Who the liar is never appears in any view before the reveal.
|
||||
*/
|
||||
import { fail, ok, type GameDefinition, type GameEvent, type GameResult, type PlayerId, type Validation } from '@bg/engine';
|
||||
import { chatNext, chatWait } from '../chat-pace';
|
||||
import { judge, normalize } from '../catchmind/text';
|
||||
import { chatProblem, cleanChat } from '../mafia';
|
||||
import {
|
||||
@@ -40,7 +41,6 @@ export const REVEAL_MS = 10_000;
|
||||
export const CHAT_MAX = 200;
|
||||
/** One description is one sentence. */
|
||||
export const DESCRIBE_MAX = 80;
|
||||
export const CHAT_GAP_MS = 700;
|
||||
export const GUESS_MAX = 20;
|
||||
/** Points (docs §6): a citizen win gives every citizen 1, a liar win gives the liar 2. */
|
||||
export const CITIZEN_POINTS = 1;
|
||||
@@ -339,7 +339,7 @@ function validate(s: LiarState, actor: PlayerId, a: LiarAction, ctx?: { now: num
|
||||
const mine = wordOf(s, actor);
|
||||
if (mine && saysWord(text, s.topic, mine)) return fail('제시어를 직접 말하면 안 돼요.');
|
||||
// Pace limit for free talk only: a description is one per turn anyway.
|
||||
if (ph.kind !== 'describe' && ctx && ctx.now - (s.lastChatAt[actor] ?? -Infinity) < CHAT_GAP_MS) return fail('조금 천천히 보내 주세요.');
|
||||
if (ph.kind !== 'describe' && ctx && chatWait(s.lastChatAt[actor], ctx.now) > 0) return fail('조금 천천히 보내 주세요.');
|
||||
return ok;
|
||||
}
|
||||
case 'ready':
|
||||
@@ -514,7 +514,7 @@ export const liar: Def = {
|
||||
s.descriptions.push({ n: s.descriptions.length + 1, round: ph.round, from: actor, text, at: now });
|
||||
nextTurn(s, now, ph.round, ph.turn + 1);
|
||||
} else {
|
||||
s.lastChatAt[actor] = now;
|
||||
s.lastChatAt[actor] = chatNext(s.lastChatAt[actor], now);
|
||||
s.chat.push({ n: (s.chat.at(-1)?.n ?? 0) + 1, from: actor, text, at: now });
|
||||
if (s.chat.length > CHAT_KEEP) s.chat.splice(0, s.chat.length - CHAT_KEEP);
|
||||
}
|
||||
|
||||
@@ -257,11 +257,13 @@ describe('차례대로 설명 (§5.2)', () => {
|
||||
let s = rig(3);
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '안녕' })).toContain('확인하는 중');
|
||||
s = until(s, 'discussion');
|
||||
s = act(s, 'P1', { type: 'chat', text: '누구지' });
|
||||
expect(reject(s, 'P1', { type: 'chat', text: '또' }, at(s) - 1000 + 100)).toBe('조금 천천히 보내 주세요.');
|
||||
const t = at(s);
|
||||
// A quick run of lines goes through at once; only a flood is refused.
|
||||
for (let i = 0; i < 6; i++) s = act(s, 'P1', { type: 'chat', text: `누구지 ${i}` }, t);
|
||||
expect(reject(s, 'P1', { type: 'chat', text: '또' }, t + 100)).toBe('조금 천천히 보내 주세요.');
|
||||
s = until(s, 'vote');
|
||||
s = act(s, 'P2', { type: 'chat', text: '투표해요' });
|
||||
expect(s.chat.map((m) => m.text)).toEqual(['누구지', '투표해요']);
|
||||
expect(s.chat.map((m) => m.text)).toEqual(['누구지 0', '누구지 1', '누구지 2', '누구지 3', '누구지 4', '누구지 5', '투표해요']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ export interface LiarState {
|
||||
phase: Phase;
|
||||
descriptions: Description[];
|
||||
chat: ChatMessage[];
|
||||
/** Chat pace per person: the time the next line is free from (`chat-pace.ts`; older saves hold the last send time). */
|
||||
lastChatAt: Record<PlayerId, number>;
|
||||
events: PublicEvent[];
|
||||
accused: PlayerId | null;
|
||||
|
||||
Reference in New Issue
Block a user