라이어 게임: 토론 채팅을 게임 내내 열기, 설명은 별도 describe 액션으로
- chat은 확인 시간·설명 중(말하는 사람 포함)·토론·투표·정답 맞히기 내내 모두 쓸 수 있다 - 설명은 새 describe 액션(차례인 사람만, 80자). 채팅에 쓴 말은 설명으로 치지 않는다 - 자기 제시어 금지·고운 말 검사는 설명과 채팅 모두 그대로 - 컴퓨터 설명도 describe로 보내고, 모델이 켜져 있으면 "입력 중…" 뒤에 보낸다 - 화면: 채팅 입력칸을 항상 보이게, 설명 차례인 사람에게는 채팅 칸 안내 문구 - 문서(docs/games/liar.md)와 테스트 갱신 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -226,8 +226,9 @@ export class BotDriver {
|
||||
if (!def.validate(g.state, bot, decision.action, { now }).ok) continue; // the moment passed (phase changed); look again later
|
||||
const brain = this.room.brain;
|
||||
const say = decision.action as { type?: string; channel?: string; text?: string };
|
||||
if (brain && say.type === 'chat' && brain.enabled()) {
|
||||
this.typeLive(brain, bot, say as { type: 'chat'; channel: string; text: string }, decision.hint ?? null, names, g);
|
||||
// 라이어 게임's description is typed like a chat line too ("입력 중…" before it appears).
|
||||
if (brain && (say.type === 'chat' || say.type === 'describe') && brain.enabled()) {
|
||||
this.typeLive(brain, bot, say as { type: 'chat' | 'describe'; channel: string; text: string }, decision.hint ?? null, names, g);
|
||||
continue;
|
||||
}
|
||||
const err = this.room.run(bot, decision.action);
|
||||
@@ -240,7 +241,7 @@ export class BotDriver {
|
||||
* Live chat like a person: the model may say the planned line in the computer's own words, then "입력 중…" for the
|
||||
* typing time, then it is sent (if it still may be: the phase can end meanwhile).
|
||||
*/
|
||||
private typeLive(brain: BotBrain, bot: string, chat: { type: 'chat'; channel: string; text: string }, hint: string | null, names: Record<string, string>, g: unknown): void {
|
||||
private typeLive(brain: BotBrain, bot: string, chat: { type: 'chat' | 'describe'; channel: string; text: string }, hint: string | null, names: Record<string, string>, g: unknown): void {
|
||||
this.liveBusy.add(bot);
|
||||
const view = this.room.def.view(this.room.game!.state, bot) as { chat?: { channel: string; from: string; text: string }[] };
|
||||
const recent = (view.chat ?? []).filter((m) => m.channel === chat.channel).slice(-8).map((m) => ({ from: names[m.from] ?? '누군가', text: m.text }));
|
||||
|
||||
@@ -74,7 +74,7 @@ describe('라이어 게임 room flow with computers', () => {
|
||||
const speaker = () => GAMES.liar!.view(state(), null).phase.speaker;
|
||||
while (state().phase.kind === 'describe') {
|
||||
if (speaker() === 'A') {
|
||||
room.act('A', cs++, { type: 'chat', text: iAmLiar ? '저는 좋아하는 편이에요' : '음 다들 아실 거예요' });
|
||||
room.act('A', cs++, { type: 'describe', text: iAmLiar ? '저는 좋아하는 편이에요' : '음 다들 아실 거예요' });
|
||||
described++;
|
||||
}
|
||||
run(() => state().phase.kind !== 'describe' || speaker() === 'A');
|
||||
|
||||
@@ -45,7 +45,7 @@ export function helpNow(v: LiarView, me: string | null, players: Record<string,
|
||||
return `${topic} 내 차례예요! 오른쪽 칸에 한 문장(80자까지)으로 설명하고 [말하기]를 눌러요.\n${tip} ${unl ? '시간 제한은 없어요.' : '시간이 지나면 넘어가요.'}`;
|
||||
}
|
||||
const round = v.rounds > 1 ? ` ${ph.round}/${v.rounds}바퀴예요${ph.round === 2 ? '(두 번째 바퀴는 거꾸로 돌아요)' : ''}.` : '';
|
||||
return `${topic} ${ph.speaker ? josa(n(ph.speaker), ['이', '가']) : '다른 사람이'} 설명하는 중이에요.${round}\n설명 기록을 잘 보고 어색한 사람을 기억해 둬요. ${mine}`;
|
||||
return `${topic} ${ph.speaker ? josa(n(ph.speaker), ['이', '가']) : '다른 사람이'} 설명하는 중이에요.${round}\n설명 기록을 잘 보고 어색한 사람을 기억해 둬요. [토론 채팅]은 지금도 쓸 수 있어요. ${mine}`;
|
||||
}
|
||||
case 'discussion':
|
||||
return `${topic} 자유 토론 시간이에요. [토론 채팅]으로 누가 라이어 같은지 이야기해요. 제시어는 직접 말할 수 없어요.\n${unl ? '토론 시간은 무제한이에요. ' : ''}다 이야기했으면 [토론 끝내기]를 눌러요. 모두 누르면 바로 투표로 넘어가요(${ph.readyCount}/${ph.readyNeeded}).`;
|
||||
|
||||
@@ -432,11 +432,10 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record<string,
|
||||
...v.chat.map((m) => ({ k: 'chat' as const, text: m.text, from: m.from, key: `c${m.n}`, at: m.at })),
|
||||
// Stable sort: same moment keeps the event order, announcements before chat.
|
||||
].sort((a, b) => a.at - b.at || (a.k === b.k ? 0 : a.k === 'sys' ? -1 : 1));
|
||||
const talk = v.phase.kind === 'discussion' || v.phase.kind === 'vote';
|
||||
const canWrite = !!v.my?.canChat && talk;
|
||||
const canWrite = !!v.my?.canChat;
|
||||
const typing = useTypingSignal('game', canWrite);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const why = !me || !v.my ? '관전 중에는 채팅을 쓸 수 없어요.' : talk ? (v.my.chatWhy ?? '') : v.phase.kind === 'describe' ? '토론 채팅은 설명이 다 끝나면 열려요.' : (v.my.chatWhy ?? '');
|
||||
const why = !me || !v.my ? '관전 중에는 채팅을 쓸 수 없어요.' : (v.my.chatWhy ?? '');
|
||||
return (
|
||||
<section className="lg-box lg-chat" aria-label="토론 채팅">
|
||||
<h2>💬 토론 채팅</h2>
|
||||
@@ -478,7 +477,7 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record<string,
|
||||
}}
|
||||
onBlur={typing.stop}
|
||||
maxLength={200}
|
||||
placeholder="누가 라이어일까요?"
|
||||
placeholder={v.my?.canDescribe ? '여기는 채팅이에요. 설명은 [말하기] 칸에 써 주세요' : '누가 라이어일까요?'}
|
||||
aria-label="토론 채팅 메시지"
|
||||
enterKeyHint="send"
|
||||
/>
|
||||
@@ -506,7 +505,7 @@ function DescribeForm({ act, pending }: { act: (a: unknown) => void; pending: bo
|
||||
e.preventDefault();
|
||||
const t = text.trim();
|
||||
if (!t) return;
|
||||
act({ type: 'chat', text: t.slice(0, 80) });
|
||||
act({ type: 'describe', text: t.slice(0, 80) });
|
||||
}}
|
||||
>
|
||||
<input ref={ref} className="input" value={text} onChange={(e) => setText(e.target.value)} maxLength={80} placeholder="예: 여름이면 생각나요" aria-label="내 설명 (한 문장)" enterKeyHint="send" />
|
||||
@@ -1029,6 +1028,7 @@ function Rules() {
|
||||
</p>
|
||||
<ul className="small" style={{ margin: 0, paddingLeft: 18 }}>
|
||||
<li>제시어를 직접 말하면 안 돼요(띄어쓰기를 무시하고 막아요). 설명 차례에 시간이 지나면 넘어가요.</li>
|
||||
<li>토론 채팅은 게임 내내 열려 있어요. 설명하는 중에도 언제든 이야기할 수 있어요.</li>
|
||||
<li>투표는 나를 뺀 한 명을 골라요. 동점이면 동점인 사람끼리 한 번 더 투표하고, 또 동점이면 라이어가 이겨요.</li>
|
||||
<li>라이어가 아닌 사람이 지목되면 라이어 승리. 라이어가 지목되면 제시어를 한 번 맞힐 수 있어요(띄어쓰기·대소문자 무시). 맞히면 라이어, 틀리면 시민 승리예요.</li>
|
||||
<li>점수: 시민이 이기면 시민마다 1점, 라이어가 이기면 라이어 2점.</li>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
- 두 바퀴면 두 번째 바퀴는 거꾸로 돈다(처음에 아무것도 모르고 말한 사람이 마지막에 말한다). 첫 바퀴 마지막 사람은 두 번 이어서 말한다.
|
||||
- **제시어를 직접 말하면 안 된다**: 자기 단어(다른 표기 포함)가 띄어쓰기·대소문자·문장 부호를 무시하고 들어 있으면 서버가 거절한다("제시어를 직접 말하면 안 돼요."). 설명과 토론 채팅 모두.
|
||||
- 라이어(보통 모드)는 막지 않는다. 막으면 "이 말은 거절됐다 = 정답"이 새기 때문. 바보 모드 라이어는 자기 단어가 막힌다(시민과 똑같이 보이려고).
|
||||
- 설명 중에는 설명할 차례인 사람만 쓸 수 있다(다른 사람 채팅은 닫힘). 확인 시간·정답 맞히기 중에도 채팅은 닫힌다(라이어에게 힌트를 주지 못하게).
|
||||
- 설명(`describe`)은 차례인 사람만 할 수 있다. **토론 채팅(`chat`)은 게임 내내 모두에게 열려 있다**(확인 시간·설명 중·토론·투표·정답 맞히기). 설명 차례인 사람이 채팅에 쓴 말은 설명으로 치지 않는다(사용자 요청 2026-10-18: "토론 언제나 가능하게"). 자기 단어 금지는 채팅에도 그대로라서, 정답 맞히기 중에 시민이 제시어를 직접 알려 줄 수는 없다.
|
||||
|
||||
### 5.3 자유 토론
|
||||
- 모두 [토론 채팅]에 자유롭게 쓴다(200자, 속도 제한 없음 — 치는 대로 바로 올라감). 모두 [토론 끝내기]를 누르면 바로 투표(마피아와 같은 "모두 동의" 방식, 방장 혼자서는 못 끝냄).
|
||||
@@ -93,7 +93,8 @@ interface LiarState {
|
||||
### 8.2 액션
|
||||
| type | payload | 누가 / 언제 | 검증 조건 |
|
||||
|---|---|---|---|
|
||||
| `chat` | `text` | 설명 차례인 사람(설명) / 모두(토론·투표) | 채팅 열린 단계, 80자(설명)·200자, 고운 말, 자기 단어 금지, 속도 제한 없음 |
|
||||
| `chat` | `text` | 모두(게임 내내) | 200자, 고운 말, 자기 단어 금지, 속도 제한 없음 |
|
||||
| `describe` | `text` | 설명 차례인 사람 | 80자, 고운 말, 자기 단어 금지 |
|
||||
| `ready` | — | 확인 시간·토론 | 아직 안 누름 |
|
||||
| `vote` | `target` | 투표 | 나 말고, 후보(재투표는 동점자) 중 |
|
||||
| `guess` | `text` | 정답 맞히기의 라이어 | 1~20자, `choice`면 주제 단어 |
|
||||
|
||||
@@ -117,8 +117,8 @@ describe('reading', () => {
|
||||
const rng = SeededRng.fromSeed(seedN(4));
|
||||
let now = 0;
|
||||
st = liar.apply(st, players[0]!, { type: 'phaseTimeout' }, { rng, now: (now = st.phase.kind === 'reveal' ? st.phase.endsAt : 0) }).state;
|
||||
for (let i = 0; i < 4; i++) st = liar.apply(st, players[i]!, { type: 'chat', text: hints[i]! }, { rng, now: (now += 2000) }).state;
|
||||
st = liar.apply(st, players[4]!, { type: 'chat', text: '저는 좋아하는 편이에요' }, { rng, now: (now += 2000) }).state;
|
||||
for (let i = 0; i < 4; i++) st = liar.apply(st, players[i]!, { type: 'describe', text: hints[i]! }, { rng, now: (now += 2000) }).state;
|
||||
st = liar.apply(st, players[4]!, { type: 'describe', text: '저는 좋아하는 편이에요' }, { rng, now: (now += 2000) }).state;
|
||||
const names = Object.fromEntries(players.map((p, i) => [p, `컴퓨터 ${i + 1}`]));
|
||||
return { st, players, names, now };
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ class LiarBot {
|
||||
key: key('describe'),
|
||||
// Leave room for typing ("입력 중…" up to ~6초 on the server) inside the turn.
|
||||
due: this.inPhase(1.5, 5, 'describe', 0.3),
|
||||
make: () => ({ type: 'chat', text: this.description() }),
|
||||
make: () => ({ type: 'describe', text: this.description() }),
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -291,21 +291,20 @@ function wordOf(s: LiarState, id: PlayerId): string | null {
|
||||
return id === s.liar ? s.liarWord : s.word;
|
||||
}
|
||||
|
||||
/** Why `p` cannot write now (Korean), or null. */
|
||||
/** Why `p` cannot write in the free-talk chat now (Korean), or null. The chat stays open for the whole game. */
|
||||
function chatBlock(s: LiarState, p: PlayerState): string | null {
|
||||
const ph = s.phase;
|
||||
if (ph.kind === 'ended') return '게임이 끝났어요.';
|
||||
if (s.phase.kind === 'ended') return '게임이 끝났어요.';
|
||||
if (p.left) return '게임에서 나갔어요.';
|
||||
switch (ph.kind) {
|
||||
case 'reveal':
|
||||
return '제시어를 확인하는 중이에요. 곧 설명이 시작돼요.';
|
||||
case 'describe':
|
||||
return speakerOf(s) === p.id ? null : '지금은 설명 차례인 사람만 말할 수 있어요.';
|
||||
case 'guess':
|
||||
return '라이어가 제시어를 맞히는 중이에요.';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Shared text checks of a description and a chat line: 고운 말, and not one's own word. */
|
||||
function textProblem(s: LiarState, actor: PlayerId, text: string): string | null {
|
||||
const why = chatProblem(text, s.options.kidSafeChat);
|
||||
if (why) return why;
|
||||
const mine = wordOf(s, actor);
|
||||
if (mine && saysWord(text, s.topic, mine)) return '제시어를 직접 말하면 안 돼요.';
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- validate
|
||||
@@ -331,13 +330,16 @@ function validate(s: LiarState, actor: PlayerId, a: LiarAction, ctx?: { now: num
|
||||
const block = chatBlock(s, p);
|
||||
if (block) return fail(block);
|
||||
const text = cleanChat(a.text);
|
||||
const max = ph.kind === 'describe' ? DESCRIBE_MAX : CHAT_MAX;
|
||||
if (ph.kind === 'describe' && [...text].length > max) return fail(`설명은 한 문장, ${max}자까지 쓸 수 있어요.`);
|
||||
const why = chatProblem(text, s.options.kidSafeChat);
|
||||
if (why) return fail(why);
|
||||
const mine = wordOf(s, actor);
|
||||
if (mine && saysWord(text, s.topic, mine)) return fail('제시어를 직접 말하면 안 돼요.');
|
||||
return ok;
|
||||
const why = textProblem(s, actor, text);
|
||||
return why ? fail(why) : ok;
|
||||
}
|
||||
case 'describe': {
|
||||
if (ph.kind !== 'describe') return fail('지금은 설명하는 때가 아니에요.');
|
||||
if (speakerOf(s) !== actor) return fail('지금은 설명 차례인 사람만 설명할 수 있어요.');
|
||||
const text = cleanChat(a.text);
|
||||
if ([...text].length > DESCRIBE_MAX) return fail(`설명은 한 문장, ${DESCRIBE_MAX}자까지 쓸 수 있어요.`);
|
||||
const why = textProblem(s, actor, text);
|
||||
return why ? fail(why) : ok;
|
||||
}
|
||||
case 'ready':
|
||||
if (ph.kind !== 'reveal' && ph.kind !== 'discussion') return fail('지금은 넘길 수 있는 때가 아니에요.');
|
||||
@@ -504,17 +506,15 @@ export const liar: Def = {
|
||||
case 'leave':
|
||||
leave(s, now, p);
|
||||
break;
|
||||
case 'chat': {
|
||||
const text = cleanChat(a.text);
|
||||
if (ph.kind === 'describe') {
|
||||
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.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);
|
||||
}
|
||||
case 'chat':
|
||||
s.chat.push({ n: (s.chat.at(-1)?.n ?? 0) + 1, from: actor, text: cleanChat(a.text), at: now });
|
||||
if (s.chat.length > CHAT_KEEP) s.chat.splice(0, s.chat.length - CHAT_KEEP);
|
||||
break;
|
||||
case 'describe':
|
||||
if (ph.kind !== 'describe') throw new Error('liar: describe outside the describe phase');
|
||||
s.descriptions.push({ n: s.descriptions.length + 1, round: ph.round, from: actor, text: cleanChat(a.text), at: now });
|
||||
nextTurn(s, now, ph.round, ph.turn + 1);
|
||||
break;
|
||||
}
|
||||
case 'ready':
|
||||
if (ph.kind !== 'reveal' && ph.kind !== 'discussion') throw new Error('liar: ready outside reveal/discussion');
|
||||
ph.ready.push(actor);
|
||||
@@ -587,6 +587,7 @@ export const liar: Def = {
|
||||
if (p.left) return out.filter((a) => validate(s, player, a).ok);
|
||||
const me = myView(s, p);
|
||||
if (me.canChat) out.push({ type: 'chat', text: `m${s.seq}-${player}` });
|
||||
if (me.canDescribe) out.push({ type: 'describe', text: `d${s.seq}-${player}` });
|
||||
if (me.canReady) out.push({ type: 'ready' });
|
||||
for (const t of me.voteTargets) out.push({ type: 'vote', target: t });
|
||||
if (me.canGuess) {
|
||||
|
||||
@@ -156,7 +156,7 @@ describe('준비와 비밀 (§4, §8.3)', () => {
|
||||
b = f(b);
|
||||
};
|
||||
step(tick);
|
||||
step((s) => act(s, speaker(s)!, { type: 'chat', text: '여름에 생각나요' }));
|
||||
step((s) => act(s, speaker(s)!, { type: 'describe', text: '여름에 생각나요' }));
|
||||
step(tick);
|
||||
step((s) => until(s, 'discussion'));
|
||||
step((s) => act(s, 'P1', { type: 'chat', text: '다들 애매하네요' }));
|
||||
@@ -205,8 +205,8 @@ describe('차례대로 설명 (§5.2)', () => {
|
||||
while (s.phase.kind === 'describe') {
|
||||
const sp = speaker(s)!;
|
||||
spoken.push(sp);
|
||||
for (const other of ids(3).filter((x) => x !== sp)) expect(reject(s, other, { type: 'chat', text: '저도요' })).toBe('지금은 설명 차례인 사람만 말할 수 있어요.');
|
||||
s = act(s, sp, { type: 'chat', text: `설명 ${spoken.length}` });
|
||||
for (const other of ids(3).filter((x) => x !== sp)) expect(reject(s, other, { type: 'describe', text: '저도요' })).toBe('지금은 설명 차례인 사람만 설명할 수 있어요.');
|
||||
s = act(s, sp, { type: 'describe', text: `설명 ${spoken.length}` });
|
||||
}
|
||||
expect(spoken).toEqual(['P0', 'P1', 'P2', 'P2', 'P1', 'P0']);
|
||||
expect(roundOrder(s, 2)).toEqual(['P2', 'P1', 'P0']);
|
||||
@@ -223,40 +223,54 @@ describe('차례대로 설명 (§5.2)', () => {
|
||||
|
||||
test('첫 바퀴 마지막 사람은 바로 이어서 두 번째 바퀴 첫 설명을 할 수 있어요(채팅 간격 제한 없음)', () => {
|
||||
let s = tick(rig(3));
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'chat', text: `${p} 설명` }, T0 + 20_000);
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'describe', text: `${p} 설명` }, T0 + 20_000);
|
||||
expect(speaker(s)).toBe('P2');
|
||||
s = act(s, 'P2', { type: 'chat', text: '또 설명' }, T0 + 20_000);
|
||||
s = act(s, 'P2', { type: 'describe', text: '또 설명' }, T0 + 20_000);
|
||||
expect(speaker(s)).toBe('P1');
|
||||
});
|
||||
|
||||
test('한 바퀴 옵션, 시간 초과는 넘김, 설명은 80자까지', () => {
|
||||
let s = tick(rig(3, { rounds: 1, describeSeconds: 15 }));
|
||||
expect(s.phase.kind === 'describe' && s.phase.endsAt! - s.phase.startedAt).toBe(15_000);
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '가'.repeat(81) })).toContain('80자');
|
||||
expect(reject(s, 'P0', { type: 'describe', text: '가'.repeat(81) })).toContain('80자');
|
||||
s = tick(s);
|
||||
expect(s.descriptions[0]).toMatchObject({ from: 'P0', text: null });
|
||||
s = act(s, 'P1', { type: 'chat', text: '좋아요' });
|
||||
s = act(s, 'P1', { type: 'describe', text: '좋아요' });
|
||||
s = tick(s);
|
||||
expect(s.phase.kind).toBe('discussion');
|
||||
});
|
||||
|
||||
test('제시어를 직접 말하면 안 돼요(띄어쓰기 무시). 라이어는 막지 않아요(막으면 정답이 새요)', () => {
|
||||
let s = tick(rig(3, { rounds: 1 }, { liarIdx: 1 }));
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '수 박 맛있어요' })).toBe('제시어를 직접 말하면 안 돼요.');
|
||||
s = act(s, 'P0', { type: 'chat', text: '여름이면 생각나요' });
|
||||
s = act(s, 'P1', { type: 'chat', text: '수박 같아요' }); // the liar's guess-like line goes through
|
||||
expect(reject(s, 'P0', { type: 'describe', text: '수 박 맛있어요' })).toBe('제시어를 직접 말하면 안 돼요.');
|
||||
expect(reject(s, 'P2', { type: 'chat', text: '수 박 맛있어요' })).toBe('제시어를 직접 말하면 안 돼요.');
|
||||
s = act(s, 'P0', { type: 'describe', text: '여름이면 생각나요' });
|
||||
s = act(s, 'P1', { type: 'describe', text: '수박 같아요' }); // the liar's guess-like line goes through
|
||||
expect(s.descriptions.at(-1)!.text).toBe('수박 같아요');
|
||||
});
|
||||
|
||||
test('바보 모드 라이어는 자기 단어를 직접 말하면 막혀요(시민과 똑같이)', () => {
|
||||
const s = tick(rig(3, { foolMode: true, rounds: 1 }, { liarIdx: 0 }));
|
||||
expect(reject(s, 'P0', { type: 'describe', text: '참외' })).toBe('제시어를 직접 말하면 안 돼요.');
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '참외' })).toBe('제시어를 직접 말하면 안 돼요.');
|
||||
});
|
||||
|
||||
test('확인 시간·정답 맞히기 중에는 채팅을 못 쓰고, 토론·투표 중에는 모두 써요', () => {
|
||||
test('토론 채팅은 게임 내내 열려 있어요: 확인 시간·설명 중(말하는 사람 포함)에도 쓰고, 설명으로 치지 않아요', () => {
|
||||
let s = rig(3);
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '안녕' })).toContain('확인하는 중');
|
||||
s = act(s, 'P0', { type: 'chat', text: '안녕' });
|
||||
expect(s.phase.kind).toBe('reveal');
|
||||
s = tick(s);
|
||||
expect(speaker(s)).toBe('P0');
|
||||
s = act(s, 'P1', { type: 'chat', text: '첫 사람 누구예요' });
|
||||
s = act(s, 'P0', { type: 'chat', text: '저요 잠깐만요' });
|
||||
expect(speaker(s)).toBe('P0');
|
||||
expect(s.descriptions).toEqual([]);
|
||||
expect(liar.view(s, 'P2').my).toMatchObject({ canChat: true, chatWhy: null, canDescribe: false });
|
||||
expect(reject(s, 'P1', { type: 'describe', text: '저도요' })).toBe('지금은 설명 차례인 사람만 설명할 수 있어요.');
|
||||
expect(s.chat.map((m) => m.text)).toEqual(['안녕', '첫 사람 누구예요', '저요 잠깐만요']);
|
||||
s = until(s, 'discussion');
|
||||
expect(reject(s, 'P0', { type: 'describe', text: '늦은 설명' })).toBe('지금은 설명하는 때가 아니에요.');
|
||||
s = { ...s, chat: [] };
|
||||
const t = at(s);
|
||||
// No pace limit: any number of lines at the same moment all go through.
|
||||
for (let i = 0; i < 20; i++) s = act(s, 'P1', { type: 'chat', text: `누구지 ${i}` }, t);
|
||||
@@ -324,7 +338,8 @@ describe('토론과 투표 (§5.3~5.5)', () => {
|
||||
expect(s.phase.kind).toBe('guess');
|
||||
expect(lastEv(s, 'accused')).toMatchObject({ p: 'P3', liar: true });
|
||||
expect(reject(s, 'P0', { type: 'guess', text: '수박' })).toBe('라이어만 맞힐 수 있어요.');
|
||||
expect(reject(s, 'P0', { type: 'chat', text: '힌트' })).toContain('맞히는 중');
|
||||
s = act(s, 'P0', { type: 'chat', text: '못 맞힐걸요' }); // the chat stays open while the liar guesses
|
||||
expect(s.phase.kind).toBe('guess');
|
||||
const right = act(s, 'P3', { type: 'guess', text: ' 수 박 ' });
|
||||
expect(right.final).toMatchObject({ winner: 'liar', reason: 'guessed', guess: '수 박' });
|
||||
expect(liar.result(right)!.ranking).toEqual([['P3'], ['P0', 'P1', 'P2']]);
|
||||
@@ -391,7 +406,7 @@ describe('시간 무제한 (§8.5)', () => {
|
||||
expect(liar.deadline!(s)).toBeNull();
|
||||
expect(liar.timeoutPlayers!(s)).toEqual(['P0']);
|
||||
expect(reject(s, 'P1', { type: 'phaseTimeout' })).toBe('아직 기다리는 중이에요.');
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'chat', text: `${p} 설명` }, T0 + 3_600_000);
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'describe', text: `${p} 설명` }, T0 + 3_600_000);
|
||||
expect(s.phase.kind).toBe('discussion');
|
||||
expect(liar.timeoutPlayers!(s)).toEqual(['P0', 'P1', 'P2']);
|
||||
for (const p of ['P0', 'P1', 'P2']) s = act(s, p, { type: 'ready' });
|
||||
@@ -409,7 +424,7 @@ describe('시간 무제한 (§8.5)', () => {
|
||||
let s = tick(rig(4, { ...U, rounds: 1 }));
|
||||
s = act(s, 'P0', liar.onTimeout(s, 'P0'));
|
||||
expect(s.descriptions[0]).toMatchObject({ from: 'P0', text: null });
|
||||
for (const p of ['P1', 'P2', 'P3']) s = act(s, p, { type: 'chat', text: `${p} 설명` });
|
||||
for (const p of ['P1', 'P2', 'P3']) s = act(s, p, { type: 'describe', text: `${p} 설명` });
|
||||
for (const p of ['P1', 'P2', 'P3']) s = act(s, p, { type: 'ready' });
|
||||
s = act(s, 'P0', liar.onTimeout(s, 'P0'));
|
||||
expect(s.phase.kind).toBe('vote');
|
||||
|
||||
@@ -43,8 +43,10 @@ export type LiarOptions = z.infer<typeof liarOptionsSchema>;
|
||||
|
||||
const pid = z.string().min(1).max(64);
|
||||
export const liarActionSchema = z.discriminatedUnion('type', [
|
||||
/** Describe phase: the speaker's one sentence. Discussion / vote: free talk. */
|
||||
/** Free talk: open to every player for the whole game. */
|
||||
z.object({ type: z.literal('chat'), text: z.string().max(400) }),
|
||||
/** Describe phase: the speaker's one sentence. */
|
||||
z.object({ type: z.literal('describe'), text: z.string().max(400) }),
|
||||
z.object({ type: z.literal('ready') }),
|
||||
z.object({ type: z.literal('vote'), target: pid }),
|
||||
z.object({ type: z.literal('guess'), text: z.string().max(60) }),
|
||||
|
||||
Reference in New Issue
Block a user