마피아: 단계별 시간 무제한(토론·지목 투표·반론·찬반·밤, 모두 마치면 넘어감·연결 끊긴 사람은 유예 뒤 넘김), 밤·아침·판결 소리, 움직임

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 13:14:54 +09:00
parent b8966db2a6
commit 743e5dc05e
11 changed files with 494 additions and 99 deletions

View File

@@ -280,7 +280,7 @@ function ClueBoard({ view: v, me, players, act, pending }: BoardProps<ClueView>)
const a = v.accusations[v.accusations.length - 1]!;
const who = a.by === me ? '내' : `${nick(players, a.by)}님의`;
if (a.correct) {
sfx.fanfare();
// The game ends here: the room plays win / lose.
setBanner({ key: `a${v.accusations.length}`, kind: 'ok', text: `⚖️ ${who} 고발이 맞았어요!` });
} else {
sfx.bad();

View File

@@ -55,3 +55,16 @@ test('마피아: 지목 투표 → 찬반 투표, 탈락한 사람', () => {
const dead = { ...confirm, players: g.state.players.map((p: any) => (p.id === g.doctor ? { ...p, alive: false, diedDay: 1, diedBy: 'mafia' } : p)) };
expect(helpNow(view(dead, g.doctor), g.doctor, users)).toContain('[죽은 사람] 채팅');
});
test('마피아: 시간 무제한이면 [밤 마치기]·[반론 마치기]·모두 투표 안내', () => {
const g = game();
const night = { kind: 'night', startedAt: T, endsAt: null, ready: [], mafiaTarget: null, mafiaPickedBy: null, investigate: null, heal: null, mediumPeek: null };
const s = { ...g.state, day: 2, phase: night };
const c = helpNow(view(s, g.citizen), g.citizen, users);
expect(c).toContain('[밤 마치기]');
expect(c).toContain('(0/7)');
const def = { ...g.state, day: 2, phase: { kind: 'defense', startedAt: T, endsAt: null, accused: g.citizen } };
expect(helpNow(view(def, g.citizen), g.citizen, users)).toContain('[반론 마치기]를 눌러요');
const vote = { ...g.state, day: 2, phase: { kind: 'vote', startedAt: T, endsAt: null, votes: {} } };
expect(helpNow(view(vote, g.police), g.police, users)).toContain('모두 투표(기권 포함)하면 바로 결과가 나와요(0/7)');
});

View File

@@ -50,6 +50,8 @@ export function helpNow(v: MafiaView, me: string | null, players: Record<string,
}
const idle = my.idleWarning ? '\n오늘도 아무것도 하지 않으면 자리 비움으로 탈락해요.' : '';
const unl = ph.endsAt === null;
const count = `(${ph.readyCount}/${ph.readyNeeded})`;
if (!my.alive) {
const see = v.options.deadSeeAll ? ' 이 방에서는 탈락하면 모든 직업과 마피아 채팅도 볼 수 있어요.' : '';
@@ -63,23 +65,28 @@ export function helpNow(v: MafiaView, me: string | null, players: Record<string,
return `${head} [전체] 채팅으로 인사해요. 오늘은 투표가 없고, 끝나면 밤이 와요.\n다 됐으면 [인사 끝내기]를 눌러요. 살아 있는 사람이 모두 누르면 바로 넘어가요(${ph.readyCount}/${ph.readyNeeded}).${idle}`;
case 'discussion': {
const adj = my.canAdjust ? '\n[+15초]·[−15초]로 토론 시간을 하루 한 번 바꿀 수 있어요.' : '';
return `${head} [전체] 채팅으로 누가 마피아 같은지 이야기해요. 직업을 밝힐지는 내 선택이에요.${adj}\n다 이야기했으면 [토론 끝내기]를 눌러요. 모두 누르면 바로 지목 투표로 넘어가요(${ph.readyCount}/${ph.readyNeeded}).${idle}`;
return `${head} [전체] 채팅으로 누가 마피아 같은지 이야기해요. 직업을 밝힐지는 내 선택이에요.${adj}\n${unl ? '토론 시간은 무제한이에요. ' : ''}다 이야기했으면 [토론 끝내기]를 눌러요. 모두 누르면 바로 지목 투표로 넘어가요${count}.${idle}`;
}
case 'vote': {
const now = my.vote === null ? '아직 고르지 않았어요(안 고르면 기권).' : my.vote === 'abstain' ? '지금은 기권으로 되어 있어요.' : `지금 ${n(my.vote)}을 골랐어요.`;
return `${head} '사람들' 목록에서 초록 테두리 사람을 눌러 마피아로 의심되는 사람을 골라요. 시간 안에는 바꿀 수 있고, [기권]도 돼요.\n${now} 표가 가장 많은 한 명이 지목돼요. 같은 표가 나오면 아무도 지목되지 않아요.${idle}`;
const now = my.vote === null ? `아직 고르지 않았어요${unl ? '' : '(안 고르면 기권)'}.` : my.vote === 'abstain' ? '지금은 기권으로 되어 있어요.' : `지금 ${n(my.vote)}을 골랐어요.`;
const when = unl ? `시간 제한이 없어요. 모두 투표(기권 포함)하면 바로 결과가 나와요${count}. 그 전에는 바꿀 수 있어요.` : '시간 안에는 바꿀 수 있고, [기권]도 돼요.';
return `${head} '사람들' 목록에서 초록 테두리 사람을 눌러 마피아로 의심되는 사람을 골라요. ${when}\n${now} 표가 가장 많은 한 명이 지목돼요. 같은 표가 나오면 아무도 지목되지 않아요.${idle}`;
}
case 'defense':
if (ph.accused === me) return `${head} 내가 지목됐어요! [전체] 채팅으로 내가 왜 마피아가 아닌지 마지막으로 말해요. 지금은 나만 말할 수 있어요.`;
return `${head} ${ph.accused ? n(ph.accused) : '지목된 사람'}의 마지막 변론을 들어요. 지금은 지목된 사람만 채팅할 수 있어요. 곧 찬반 투표를 해요.`;
if (ph.accused === me) return `${head} 내가 지목됐어요! [전체] 채팅으로 내가 왜 마피아가 아닌지 마지막으로 말해요. 지금은 나만 말할 수 있어요.${unl ? '\n시간 제한이 없어요. 다 말했으면 [반론 마치기]를 눌러요.' : ''}`;
return `${head} ${ph.accused ? n(ph.accused) : '지목된 사람'}의 마지막 변론을 들어요. 지금은 지목된 사람만 채팅할 수 있어요. ${unl ? '지목된 사람이 [반론 마치기]를 누르면 찬반 투표를 해요.' : '곧 찬반 투표를 해요.'}`;
case 'confirm': {
const who = ph.accused ? n(ph.accused) : '지목된 사람';
if (!my.canConfirm) return `${head} 다른 사람들이 나를 탈락시킬지 찬반 투표를 하고 있어요. 결과를 기다려 주세요.`;
const now = my.ballot ? `지금 ${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 시간 안에는 바꿀 수 있어요.` : '안 누르면 집계에서 빠져요.';
const now = unl
? `${my.ballot ? `지금 ${my.ballot === 'yes' ? '찬성' : '반대'}했어요. ` : ''}시간 제한이 없어요. 모두 고르면 바로 결과가 나와요${count}.`
: my.ballot
? `지금 ${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 시간 안에는 바꿀 수 있어요.`
: '안 누르면 집계에서 빠져요.';
return `${head} ${who}을 탈락시킬지 정해요. [찬성 (탈락)] 또는 [반대 (살리기)]를 눌러요.\n찬성이 반대보다 많아야 탈락해요. ${now}${idle}`;
}
case 'night':
return nightHelp(v, me, n) + idle;
return nightHelp(v, me, n) + (unl ? `\n밤 시간은 무제한이에요. ${my.ready ? '[밤 마치기]를 눌렀어요. 다른 사람을 기다려요' : '할 일을 마쳤으면 [밤 마치기]를 눌러요. 살아 있는 사람이 모두 누르면 아침이 와요'}${count}.` : '') + idle;
}
return head;
}

View File

@@ -11,7 +11,7 @@ import type { Channel, ChatView, MafiaOptions, MafiaView, PlayerView, PrivateRes
import type { PublicUser } from '@bg/shared/lite';
import { Avatar } from '../../components/ui';
import { useServerNow } from '../../components/TurnTimer';
import { haptic, sounds } from '../../lib/feedback';
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import { ChatMessage, sameRun } from '../../components/ChatMessage';
import { useStickToBottom } from '../../lib/useStickToBottom';
import type { BoardProps, GameUI, OptionsProps } from '../types';
@@ -56,6 +56,28 @@ const PHASE_EVENT: Record<Exclude<MafiaView['phase']['kind'], 'ended'>, string>
};
const nick = (players: Record<string, PublicUser>, id: string) => players[id]?.nickname ?? '알 수 없음';
/** Game sounds on top of the shared palette (site volume applies). */
const mfSound = {
/** Night falls: a low falling hum. */
night: () => {
tone(392, 520, 'sine', 0.1, 0, { slideTo: 196 });
tone(294, 620, 'sine', 0.06, 180, { slideTo: 147 });
},
/** Morning: a small rising chime. */
morning: () => [523, 659, 784].forEach((f, i) => tone(f, 160, 'triangle', 0.09, i * 110)),
/** Judge's gavel (executed). */
gavel: () => {
noise(70, 0.35, 0, 'lowpass', 500);
tone(120, 160, 'square', 0.08);
noise(60, 0.25, 220, 'lowpass', 500);
},
/** Someone was taken in the night. */
death: () => {
tone(220, 380, 'sawtooth', 0.06, 0, { slideTo: 110 });
tone(233, 380, 'sawtooth', 0.04, 40, { slideTo: 116 });
},
};
const userOf = (players: Record<string, PublicUser>, id: string): PublicUser => players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' };
const isNight = (v: MafiaView) => v.phase.kind === 'night' || v.phase.kind === 'roleReveal';
@@ -135,6 +157,11 @@ button.mf-tile { cursor: pointer; }
.mf-log { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; max-height: 320px; overflow: auto; }
.mf-rules td, .mf-rules th { padding: 4px 6px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
@keyframes mf-pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.mf-unl { font-size: 1.6rem; }
.mf-unl small { display: block; font-size: .7rem; font-weight: 800; }
.mf-tile[aria-pressed='true'] { animation: mf-pick .28s ease-out; }
@keyframes mf-pick { 50% { transform: scale(1.07); } }
.mf-rolecard[data-show='true'] { animation: anim-flip .35s ease both; }
@keyframes mf-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (max-width: 1099px) {
.mf { height: auto; }
@@ -154,14 +181,20 @@ button.mf-tile { cursor: pointer; }
}
@media (prefers-reduced-motion: reduce) {
.mf-banner { transition: none; }
.mf-news, .mf-bar .tr i { animation: none; }
.mf-news, .mf-bar .tr i, .mf-tile[aria-pressed='true'], .mf-rolecard[data-show='true'] { animation: none; }
}
`;
// ---------------------------------------------------------------- small parts
function Clock({ endsAt }: { endsAt: number | null }) {
function Clock({ endsAt, unlimited }: { endsAt: number | null; unlimited: boolean }) {
const now = useServerNow(500);
if (unlimited)
return (
<span className="mf-clock mf-unl" role="timer" aria-label="시간 제한 없음">
∞<small>무제한</small>
</span>
);
if (endsAt === null) return null;
const sec = Math.max(0, Math.ceil((endsAt - now) / 1000));
const text = sec >= 60 ? `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, '0')}` : `${sec}`;
@@ -537,7 +570,7 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
body = (
<>
<p className="mf-prompt">{ph.kind === 'greeting' ? '인사 시간이에요. 오늘은 투표가 없어요.' : '토론 시간이에요. 마피아가 누구일까요?'}</p>
{ph.kind === 'discussion' && v.options.timeAdjust && (
{ph.kind === 'discussion' && v.options.timeAdjust && ph.endsAt !== null && (
<div className="mf-big" role="group" aria-label="토론 시간 바꾸기">
<button type="button" className="btn btn-secondary" disabled={pending || !my.canAdjust} onClick={() => act({ type: 'adjustTime', delta: 15 })} aria-label="토론 시간 15초 늘리기">
+15초
@@ -547,21 +580,24 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
</button>
</div>
)}
{ph.kind === 'discussion' && !my.canAdjust && v.options.timeAdjust && <span className="small muted">시간 바꾸기는 하루에 한 번만 할 수 있어요.</span>}
{ph.kind === 'discussion' && !my.canAdjust && v.options.timeAdjust && ph.endsAt !== null && <span className="small muted">시간 바꾸기는 하루에 한 번만 할 수 있어요.</span>}
<div className="mf-big">
<button type="button" className="btn btn-primary" disabled={pending || !my.canReady} onClick={() => act({ type: 'readyEarly' })}>
{my.ready ? `기다리는 중 (${ph.readyCount}/${ph.readyNeeded})` : `${ph.kind === 'greeting' ? '인사 끝내기' : '토론 끝내기'} (${ph.readyCount}/${ph.readyNeeded})`}
{my.ready ? '기다리는 중' : ph.kind === 'greeting' ? '인사 끝내기' : '토론 끝내기'} <Count v={v} />
</button>
</div>
<span className="small muted">살아 있는 사람이 모두 누르면 바로 다음으로 넘어가요.</span>
<span className="small muted">{ph.endsAt === null ? '토론 시간이 무제한이에요. ' : ''}살아 있는 사람이 모두 누르면 바로 다음으로 넘어가요.</span>
</>
);
} else if (ph.kind === 'vote') {
body = (
<>
<p className="mf-prompt">마피아로 의심되는 사람을 골라 주세요</p>
<span className="small">초록 테두리 사람을 누르면 지목해요. 시간 안에는 바꿀 수 있어요.</span>
<strong>{my.vote === null ? '아직 고르지 않았어요 (안 고르면 기권)' : my.vote === 'abstain' ? '기권했어요' : `${n(my.vote)}을 지목했어요`}</strong>
<span className="small">
{ph.endsAt === null ? '초록 테두리 사람을 누르면 지목해요. 모두 투표하면 바로 결과가 나와요. ' : '초록 테두리 사람을 누르면 지목해요. 시간 안에는 바꿀 수 있어요.'}
{ph.endsAt === null && <Count v={v} />}
</span>
<strong>{my.vote === null ? `아직 고르지 않았어요${ph.endsAt === null ? '' : ' (안 고르면 기권)'}` : my.vote === 'abstain' ? '기권했어요' : `${n(my.vote)}을 지목했어요`}</strong>
<div className="mf-big">
<button type="button" className="btn btn-secondary" disabled={pending || my.vote === 'abstain'} onClick={() => act({ type: 'vote', target: 'abstain' })}>
기권
@@ -570,7 +606,19 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
</>
);
} else if (ph.kind === 'defense') {
body = <p className="mf-prompt">{ph.accused === me ? '지목됐어요. 전체 채팅으로 최후의 반론을 해 주세요!' : `${n(ph.accused!)}의 최후의 반론을 들어 주세요.`}</p>;
body = (
<>
<p className="mf-prompt">{ph.accused === me ? '지목됐어요. 전체 채팅으로 최후의 반론을 해 주세요!' : `${n(ph.accused!)}의 최후의 반론을 들어 주세요.`}</p>
{ph.endsAt === null && my.canReady && (
<div className="mf-big">
<button type="button" className="btn btn-primary" disabled={pending} onClick={() => act({ type: 'readyEarly' })}>
반론 마치기
</button>
</div>
)}
{ph.endsAt === null && <span className="small muted">시간 제한이 없어요. {ph.accused === me ? '다 말했으면 [반론 마치기]를 눌러요.' : '지목된 사람이 [반론 마치기]를 누르면 찬반 투표로 넘어가요.'}</span>}
</>
);
} else if (ph.kind === 'confirm') {
body = my.canConfirm ? (
<>
@@ -583,7 +631,16 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
반대 (살리기)
</button>
</div>
<span className="small muted">{my.ballot ? `${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 시간 안에는 바꿀 수 있어요.` : '고르지 않으면 집계에서 빠져요.'}</span>
<span className="small muted">
{ph.endsAt === null
? my.ballot
? `${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 모두 고르면 바로 결과가 나와요. `
: '모두 고르면 바로 결과가 나와요. '
: my.ballot
? `${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 시간 안에는 바꿀 수 있어요.`
: '고르지 않으면 집계에서 빠져요.'}
{ph.endsAt === null && <Count v={v} />}
</span>
</>
) : (
<p className="mf-prompt">다른 사람들이 찬반 투표를 하고 있어요.</p>
@@ -595,7 +652,7 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
<p className="mf-prompt">{nv.prompt}</p>
{nv.action && nv.targets.length > 0 && (
<>
<span className="small">초록 테두리 사람을 누르면 골라요. 밤이 끝날 때 고른 사람으로 정해져요.</span>
<span className="small">초록 테두리 사람을 누르면 골라요. 밤이 끝날 때 고른 사람으로 정해져요.{ph.endsAt === null ? ' 고른 다음 [밤 마치기]를 눌러요.' : ''}</span>
<strong>{nv.choice ? `고른 사람: ${n(nv.choice)}${nv.pickedBy && nv.pickedBy !== me ? ` (${n(nv.pickedBy)}이 골랐어요)` : ''}` : '아직 고르지 않았어요'}</strong>
{nv.action === 'mafiaTarget' && nv.choice && (
<div className="mf-big">
@@ -607,6 +664,16 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
</>
)}
{!nv.action && <span className="small muted">밤이 지나면 아침 발표가 있어요.</span>}
{ph.endsAt === null && (
<>
<div className="mf-big">
<button type="button" className="btn btn-primary" disabled={pending || !my.canReady} onClick={() => act({ type: 'readyEarly' })}>
{my.ready ? '아침을 기다리는 중' : '밤 마치기'} <Count v={v} />
</button>
</div>
<span className="small muted">밤 시간이 무제한이에요. 살아 있는 사람이 모두 누르면 아침이 와요.</span>
</>
)}
</>
);
}
@@ -629,6 +696,17 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco
);
}
/** "(3/5)": how many are done in this phase; bumps when it changes (someone else pressed / voted). */
function Count({ v }: { v: MafiaView }) {
const { readyCount: c, readyNeeded: n } = v.phase;
if (!n) return null;
return (
<span key={c} className="anim-bump" style={{ display: 'inline-block' }}>
({c}/{n})
</span>
);
}
function FinalReveal({ v, players }: { v: MafiaView; players: Record<string, PublicUser> }) {
const f = v.final!;
return (
@@ -670,6 +748,39 @@ function FinalReveal({ v, players }: { v: MafiaView; players: Record<string, Pub
// ---------------------------------------------------------------- board
/** Sounds for what anyone did: announcements (votes, deaths, saves, the end), choices, the done count. */
function useMafiaSounds(v: MafiaView): void {
const prev = useRef(v);
useEffect(() => {
const p = prev.current;
prev.current = v;
if (p === v) return;
const last = p.events.at(-1)?.n ?? 0;
const fresh = v.events.filter((e) => e.n > last);
let played = false;
const play = (f: () => void) => {
if (played) return;
played = true;
f();
};
// The most telling announcement wins (one sound per update); the room plays win / lose at the end.
if (fresh.some((e) => e.t === 'end')) return;
for (const e of fresh) {
if (e.t === 'death') play(e.by === 'mafia' ? mfSound.death : e.by === 'vote' ? mfSound.gavel : sfx.whoosh);
else if (e.t === 'confirm' && e.outcome !== 'executed') play(sfx.good);
else if (e.t === 'healed' || e.t === 'soldier') play(sfx.good);
}
if (fresh.some((e) => e.t === 'vote')) play(() => sfx.chips(3));
if (fresh.some((e) => e.t === 'adjust')) play(sfx.tick);
if (fresh.length) return;
// Same phase: my own pick (vote, ballot, night target incl. a mafia mate's) or someone else being done.
const my = v.my;
const pm = p.my;
if (my && pm && (my.vote !== pm.vote || my.ballot !== pm.ballot || my.night?.choice !== pm.night?.choice)) return play(sfx.select);
if (v.phase.readyCount > p.phase.readyCount && v.phase.kind === p.phase.kind) play(sfx.chip);
}, [v]);
}
function MafiaBoard({ view: v, me, players, act, pending }: BoardProps<MafiaView>) {
const ph = v.phase;
const my = v.my;
@@ -682,11 +793,13 @@ function MafiaBoard({ view: v, me, players, act, pending }: BoardProps<MafiaView
return;
}
setAnnounce(`${v.day}일차 ${PHASE_KO[ph.kind]}`);
if (my?.alive && (ph.kind === 'vote' || (ph.kind === 'confirm' && my.canConfirm) || ph.kind === 'night' || ph.kind === 'discussion')) {
haptic(40);
sounds.myTurn();
}
if (my?.alive && (ph.kind === 'vote' || (ph.kind === 'confirm' && my.canConfirm) || ph.kind === 'night' || ph.kind === 'discussion')) haptic(40);
// Night and morning have their own sound; a vote I must cast gets the "my turn" sound.
if (ph.kind === 'night') mfSound.night();
else if (ph.kind === 'discussion' || ph.kind === 'greeting') mfSound.morning();
else if (my?.alive && (ph.kind === 'vote' || (ph.kind === 'confirm' && my.canConfirm) || (ph.kind === 'defense' && ph.accused === me))) sounds.myTurn();
}, [phaseKey]); // eslint-disable-line react-hooks/exhaustive-deps
useMafiaSounds(v);
let pick: Pick = null;
if (my?.alive && ph.kind === 'vote') pick = { ids: my.voteTargets, chosen: my.vote === 'abstain' ? null : my.vote, onPick: (id) => act({ type: 'vote', target: id }) };
@@ -711,10 +824,12 @@ function MafiaBoard({ view: v, me, players, act, pending }: BoardProps<MafiaView
<span className="d">
{time === 'night' ? '🌙' : time === 'end' ? '🏁' : '☀️'} {v.day}일차
</span>
<strong>{PHASE_KO[ph.kind]}</strong>
<strong key={phaseKey} className="anim-slide-up">
{PHASE_KO[ph.kind]}
</strong>
<span className="s">{sub}</span>
</span>
<Clock endsAt={ph.endsAt} />
<Clock endsAt={ph.endsAt} unlimited={ph.endsAt === null && ph.kind !== 'ended'} />
{my && <RoleCard role={my.role} mates={my.mates} players={players} always={!!v.winner || !my.alive} />}
</section>
<News v={v} players={players} />
@@ -824,7 +939,7 @@ function statusText(v: MafiaView, me: string | null, players: Record<string, Pub
// ---------------------------------------------------------------- options
function Seg<T extends string | number | boolean>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
function Seg<T extends string | number | boolean | null>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
return (
<div className="segmented" role="group" aria-label={label}>
{options.map(([k, l]) => (
@@ -851,6 +966,8 @@ const onOff: [boolean, string][] = [
[false, '끄기'],
];
const secs = <T extends number>(...v: T[]): [T, string][] => v.map((x) => [x, `${x}초`]);
/** Seconds plus 무제한 (null). */
const secsU = <T extends number>(...v: T[]): [T | null, string][] => [...secs(...v), [null, '무제한']];
const EXTRA_KO: Record<keyof MafiaOptions['extraRoles'], string> = { soldier: '군인', politician: '정치인', medium: '영매', lovers: '연인(2명)' };
function Options({ value: o, onChange }: OptionsProps<MafiaOptions>) {
@@ -893,7 +1010,8 @@ function Options({ value: o, onChange }: OptionsProps<MafiaOptions>) {
/>
</Field>
<Field label="밤 시간">
<Seg label="밤 시간" value={o.nightSeconds} options={secs(15, 20, 30, 45, 60, 90)} onChange={(nightSeconds) => set({ nightSeconds })} />
<Seg label="밤 시간" value={o.nightSeconds} options={secsU(15, 20, 30, 45, 60, 90)} onChange={(nightSeconds) => set({ nightSeconds })} />
{o.nightSeconds === null && <span className="small muted">살아 있는 사람이 모두 [밤 마치기]를 누르면 아침이 와요(직업과 상관없이 모두 눌러요).</span>}
</Field>
<Field label="탈락한 사람 공개">
<Seg
@@ -913,26 +1031,34 @@ function Options({ value: o, onChange }: OptionsProps<MafiaOptions>) {
{more && (
<>
<Field label="토론 시간(살아 있는 사람 1명당)">
<Seg label="토론 시간(1명당)" value={o.discussionPerAlive} options={secs(10, 15, 20)} onChange={(discussionPerAlive) => set({ discussionPerAlive })} />
<Seg label="토론 시간(1명당)" value={o.discussionPerAlive} options={secsU(10, 15, 20)} onChange={(discussionPerAlive) => set({ discussionPerAlive })} />
</Field>
<Field label="토론 시간 최소">
<Seg label="토론 시간 최소" value={o.discussionMin} options={secs(30, 45, 60, 90, 120)} onChange={(discussionMin) => set({ discussionMin })} />
{o.discussionPerAlive === null ? (
<span className="small muted">토론 시간이 무제한이에요. 살아 있는 사람이 모두 [토론 끝내기]를 누르면 투표로 넘어가요(최소·최대·±15초는 쓰지 않아요).</span>
) : (
<>
<Field label="토론 시간 최소">
<Seg label="토론 시간 최소" value={o.discussionMin} options={secs(30, 45, 60, 90, 120)} onChange={(discussionMin) => set({ discussionMin })} />
</Field>
<Field label="토론 시간 최대">
<Seg label="토론 시간 최대" value={o.discussionMax} options={secs(60, 120, 180, 240, 300)} onChange={(discussionMax) => set({ discussionMax })} />
</Field>
</>
)}
<Field label="지목 투표 시간" help={o.voteSeconds === null ? '모두 투표(기권 포함)하면 바로 결과가 나와요.' : undefined}>
<Seg label="지목 투표 시간" value={o.voteSeconds} options={secsU(10, 15, 20, 30, 45, 60)} onChange={(voteSeconds) => set({ voteSeconds })} />
</Field>
<Field label="토론 시간 최대">
<Seg label="토론 시간 최대" value={o.discussionMax} options={secs(60, 120, 180, 240, 300)} onChange={(discussionMax) => set({ discussionMax })} />
<Field label="최후의 반론 시간" help={o.defenseSeconds === null ? '지목된 사람이 [반론 마치기]를 누르면 찬반 투표로 넘어가요.' : undefined}>
<Seg label="최후의 반론 시간" value={o.defenseSeconds} options={secsU(10, 15, 20, 30, 45, 60)} onChange={(defenseSeconds) => set({ defenseSeconds })} />
</Field>
<Field label="지목 투표 시간">
<Seg label="지목 투표 시간" value={o.voteSeconds} options={secs(10, 15, 20, 30, 45, 60)} onChange={(voteSeconds) => set({ voteSeconds })} />
</Field>
<Field label="최후의 반론 시간">
<Seg label="최후의 반론 시간" value={o.defenseSeconds} options={secs(10, 15, 20, 30, 45, 60)} onChange={(defenseSeconds) => set({ defenseSeconds })} />
</Field>
<Field label="찬반 투표 시간">
<Seg label="찬반 투표 시간" value={o.confirmSeconds} options={secs(5, 10, 15, 20, 30)} onChange={(confirmSeconds) => set({ confirmSeconds })} />
</Field>
<Field label="하루 한 번 토론 시간 ±15초">
<Seg label="토론 시간 바꾸기" value={o.timeAdjust} options={onOff} onChange={(timeAdjust) => set({ timeAdjust })} />
<Field label="찬반 투표 시간" help={o.confirmSeconds === null ? '지목된 사람을 뺀 모두가 고르면 바로 결과가 나와요.' : undefined}>
<Seg label="찬반 투표 시간" value={o.confirmSeconds} options={secsU(5, 10, 15, 20, 30)} onChange={(confirmSeconds) => set({ confirmSeconds })} />
</Field>
{o.discussionPerAlive !== null && (
<Field label="하루 한 번 토론 시간 ±15초">
<Seg label="토론 시간 바꾸기" value={o.timeAdjust} options={onOff} onChange={(timeAdjust) => set({ timeAdjust })} />
</Field>
)}
<Field label="지목 투표에서 누가 누구를 골랐는지 공개">
<Seg label="투표 공개" value={o.openVote} options={onOff} onChange={(openVote) => set({ openVote })} />
</Field>
@@ -975,7 +1101,8 @@ function optionsSummary(o: MafiaOptions): string {
const extras = (Object.keys(EXTRA_KO) as (keyof MafiaOptions['extraRoles'])[]).filter((k) => o.extraRoles[k]).map((k) => EXTRA_KO[k]);
const parts = [o.mafiaCount === 'auto' ? '마피아 자동' : `마피아 ${o.mafiaCount}명`];
if (extras.length) parts.push(`추가: ${extras.join('·')}`);
parts.push(o.firstPhase === 'day' ? '낮부터' : '밤부터', `밤 ${o.nightSeconds}초`, `투표 ${o.voteSeconds}초`);
parts.push(o.firstPhase === 'day' ? '낮부터' : '밤부터', o.nightSeconds === null ? '밤 무제한' : `밤 ${o.nightSeconds}초`, o.voteSeconds === null ? '투표 무제한' : `투표 ${o.voteSeconds}초`);
if (o.discussionPerAlive === null) parts.push('토론 무제한');
parts.push(o.deathReveal === 'none' ? '탈락자 비공개' : o.deathReveal === 'team' ? '탈락 시 마피아 여부 공개' : '탈락 시 직업 공개');
return parts.join(' · ');
}
@@ -996,6 +1123,10 @@ function Rules() {
<p>
밤에는 낮 채팅이 잠겨요. 마피아는 마피아 채팅으로, 연인은 연인 채팅으로 몰래 이야기해요. 탈락한 사람은 죽은 사람 채팅에서만 이야기할 수 있어요(영매는 밤에 함께해요).
</p>
<p>
<strong>시간 무제한</strong>: 단계마다 시간을 무제한으로 할 수 있어요. 그러면 토론은 모두 [토론 끝내기], 투표는 모두 투표, 반론은 지목된 사람이 [반론 마치기], 밤은 모두 [밤 마치기]를 누를 때
넘어가요. 연결이 끊긴 채 돌아오지 않는 사람은 잠시 뒤 기권·마침으로 처리돼요.
</p>
<table className="mf-rules small" style={{ borderCollapse: 'collapse', width: '100%' }}>
<tbody>
{ROLE_ORDER.map((r) => (