diff --git a/apps/server/src/rooms/case-file.room.test.ts b/apps/server/src/rooms/case-file.room.test.ts new file mode 100644 index 0000000..77ccf85 --- /dev/null +++ b/apps/server/src/rooms/case-file.room.test.ts @@ -0,0 +1,89 @@ +/** 사건 파일 through a real Room: briefing clock, captain passes, report clock, race clock, and views that keep unread texts on the server (docs/games/case-file.md §8.5). */ +import { describe, expect, test } from 'bun:test'; +import type { ServerMessage } from '@bg/shared'; +import { GAMES } from '@bg/games'; +import { CASES, type CaseFileOptions, type CaseFileState } from '@bg/games/case-file'; +import { openDb } from '../db'; +import { Room, type Conn, type RoomConfig } from './room'; +import { RoomStore } from './store'; + +function harness(players: string[], opts: Partial = {}) { + const db = openDb(':memory:'); + const store = new RoomStore(db); + let now = 1_000_000; + const clock = { now: () => now, set: (t: number) => (now = t), advance: (ms: number) => (now += ms) }; + const games = { 'case-file': GAMES['case-file']! }; + const deps = { store, games, users: { publicUser: (id: string) => ({ id, nickname: id, avatar: null, kind: 'guest' as const }) }, now: clock.now }; + const config: RoomConfig = { gameId: 'case-file', options: games['case-file'].optionsSchema.parse(opts), maxPlayers: players.length, visibility: 'private', allowSpectators: true, chatEnabled: true, chatFilter: true, graceSec: 60 }; + const room = new Room('room1', '482913', config, players[0]!, deps); + store.insertRoom({ id: 'room1', code: '482913', hostId: players[0]!, gameId: 'case-file', status: 'lobby', visibility: 'private', config, stateJson: '{}', now }); + const conns: Record = {}; + for (const p of players) { + const msgs: ServerMessage[] = []; + conns[p] = { userId: p, msgs, send: (m) => msgs.push(m), close: () => {} }; + room.join(conns[p], 'player'); + } + expect(room.start(players[0]!)).toBeNull(); + room.clearTimer(); + const state = () => room.game!.state as CaseFileState; + /** Jumps to the current deadline and lets the room fire it. */ + const expire = () => { + clock.set(Math.max(clock.now(), room.effectiveDeadline()!)); + room.onTimer(); + room.clearTimer(); + }; + let cs = 0; + /** Sends an action like the client and fails on a reject. */ + const act = (p: string, a: unknown) => { + const before = conns[p]!.msgs.length; + room.act(p, ++cs, a); + room.clearTimer(); + const rej = conns[p]!.msgs.slice(before).find((m) => m.t === 'reject'); + if (rej) throw new Error(`${p} ${JSON.stringify(a)} rejected: ${JSON.stringify(rej)}`); + }; + return { room, clock, conns, state, expire, act }; +} + +const allText = (msgs: ServerMessage[]) => JSON.stringify(msgs); + +describe('사건 파일 room flow', () => { + test('의뢰 60초 → 수사, 반장 시간 초과는 넘기기만, 보고서 시간 초과 → 채점', () => { + const { room, state, expire, conns, act } = harness(['A', 'B'], { turnSeconds: 60, reportSeconds: 180 }); + expect(state().phase).toBe('briefing'); + expire(); + expect(state().phase).toBe('investigate'); + const cap = state().players[state().decider]!.id; + expire(); + expect(state().players[state().decider]!.id).not.toBe(cap); + expect(state().investigations.team!.visited).toHaveLength(0); + const now = state().players[state().decider]!.id; + act(now, { type: 'pick', lead: 'c1-03' }); + // The read text went out; texts nobody read did not. + const c = CASES.c1; + expect(allText(conns.A!.msgs)).toContain(JSON.stringify(c.leads[2]!.text).slice(1, 40)); + expect(allText(conns.B!.msgs)).not.toContain(JSON.stringify(c.leads[10]!.text).slice(1, 40)); + expect(allText(conns.B!.msgs)).not.toContain(JSON.stringify(c.solution).slice(1, 40)); + const next = state().players[state().decider]!.id; + act(next, { type: 'report' }); + expect(state().phase).toBe('report'); + act('A', { type: 'answer', q: 'q1', choice: 0 }); + expire(); + expire(); + expect(room.game!.finished).toBe(true); + expect(room.lastResult!.summary).toContain('범인은 강민재였어요'); + }); + + test('따로 겨루기: 전체 시간이 끝나면 모두 보고서, 끝나면 순위', () => { + const { room, state, expire, act } = harness(['A', 'B'], { mode: 'race', raceMinutes: 30, reportSeconds: 180 }); + expire(); + expect(state().raceEndsAt).not.toBeNull(); + act('A', { type: 'pick', lead: 'c1-01' }); + expire(); + expect(state().phase).toBe('report'); + act('B', { type: 'answer', q: 'q1', choice: 0 }); + act('B', { type: 'submit' }); + expire(); + expect(room.game!.finished).toBe(true); + expect(room.lastResult!.ranking).toEqual([['B'], ['A']]); + }); +}); diff --git a/apps/web/src/games/case-file/help.ts b/apps/web/src/games/case-file/help.ts new file mode 100644 index 0000000..0d819eb --- /dev/null +++ b/apps/web/src/games/case-file/help.ts @@ -0,0 +1,37 @@ +/** 사건 파일 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view (never the case data). */ +import type { CaseFileView } from '@bg/games/case-file'; +import type { PublicUser } from '@bg/shared/lite'; + +const nm = (players: Record, id: string | null | undefined) => `${(id && players[id]?.nickname) || '다른 사람'}님`; +export const clock = (h: number) => `${String(Math.floor(h)).padStart(2, '0')}:00`; + +export function helpNow(v: CaseFileView, me: string | null, players: Record): string { + const goal = '정해진 날짜와 시간 안에 단서를 골라 읽고, 마지막에 수사 보고서 문제를 풀어 점수를 받아요.'; + if (v.phase === 'ended') { + return `수사가 끝났어요. ${v.final?.summary ?? ''}`.trim() + '\n[결과] 탭에서 정답과 풀이, [놓친 단서 보기]로 못 본 단서를 모두 읽을 수 있어요.'; + } + if (v.phase === 'briefing') { + return v.can.ready + ? `의뢰를 읽고 [수사 시작]을 눌러요. 모두 누르거나 60초가 지나면 수사가 시작돼요.\n${goal}` + : `의뢰를 읽는 중이에요. 다른 사람이 [수사 시작]을 누르길 기다려요.\n${goal}`; + } + const inv = v.inv; + const time = inv ? `지금 ${inv.day}일째 ${clock(inv.hour)}, ${inv.placeName}에 있어요(하루는 ${clock(inv.dayEnd)}까지).` : ''; + if (v.can.answer) { + return `보고서를 쓸 차례예요. 문제마다 답을 고르고 [보고서 내기]를 두 번 눌러 확정해요. 낸 뒤에는 고칠 수 없어요.\n[기록]·[자료] 탭에서 읽은 단서를 다시 볼 수 있어요.`; + } + if (v.phase === 'report' || inv?.reported) return '보고서를 냈어요. 다른 사람이 다 낼 때까지 기다려요. 끝나면 정답과 풀이가 나와요.'; + if (!me || !v.seats.some((s) => s.id === me)) return `관전 중이에요. ${time}\n${goal}`; + const travel = '다른 동네로 가면 이동 시간이 더 들어요. 하루 끝을 넘기면 야근이에요(1시간마다 −1점).'; + if (v.mode === 'race') return `따로 겨루기예요. 내 속도로 단서를 고르고, 다 됐으면 [보고서 쓰기]를 눌러요. ${time}\n${travel}`; + if (v.decision === 'vote') { + return v.myVote + ? `투표했어요. 모두 투표하거나 시간이 끝나면 가장 많이 고른 칸을 해요. ${time}` + : `다 같이 투표로 정해요. 단서 카드나 아래 칸에서 [투표]를 눌러요. ${time}\n${travel}`; + } + if (v.can.control) { + const free = v.decision === 'free' ? ' 누르면 [정말 이걸로 해요]로 한 번 더 확인해요. 보고서는 모두 [보고서 쓰자]를 눌러야 써요.' : ''; + return `${v.decision === 'rotate' ? '내가 반장이에요. ' : ''}다음 단서를 골라요.${free} ${time}\n${travel} 읽은 단서에 🔍가 있으면 돋보기로 깊이 볼 수 있어요.`; + } + return `지금 반장은 ${nm(players, v.decider)}이에요. 단서 카드의 [추천]을 누르거나 채팅으로 의견을 내요. 단서를 하나 읽으면 반장이 넘어가요. ${time}`; +} diff --git a/apps/web/src/games/case-file/index.tsx b/apps/web/src/games/case-file/index.tsx new file mode 100644 index 0000000..356b655 --- /dev/null +++ b/apps/web/src/games/case-file/index.tsx @@ -0,0 +1,781 @@ +/** + * 사건 파일 화면 (docs/games/case-file.md §9). Imports only types and labels from the engine: the case texts reach + * the browser through the view, one read lead at a time (no-case-text.test.ts checks the built bundle). + */ +import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react'; +import type { CaseFileOptions, CaseFileView, Choice, ChoiceView, LeadCardView, LogEntryView, PlayerScore } from '@bg/games/case-file'; +import { CASE_LIST } from '@bg/games/case-file/types'; +import type { PublicUser } from '@bg/shared/lite'; +import { Sheet } from '../../components/ui'; +import { TurnTimer } from '../../components/TurnTimer'; +import { sfx, sounds } from '../../lib/feedback'; +import type { BoardProps, GameUI, OptionsProps } from '../types'; +import { clock, helpNow } from './help'; +import { quickStart } from './quick'; + +type Players = Record; +const nick = (players: Players, id: string | null | undefined) => (id && players[id]?.nickname) || '알 수 없음'; + +const CSS = ` +.cf { width: 100%; max-width: 860px; display: flex; flex-direction: column; gap: 12px; align-self: stretch; margin: 0 auto; } +@media (min-width: 1100px) { .cf { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; } } +.cf.ended { padding-bottom: 96px; } +.cf-bar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 14px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); } +.cf-bar h2 { font-size: 1.05rem; margin: 0; flex: 1 1 100%; } +.cf-bar .cf-clock { font-weight: 800; font-variant-numeric: tabular-nums; } +.cf-dots { display: inline-flex; gap: 4px; } +.cf-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); display: inline-block; } +.cf-dots i.on { background: var(--primary); } +.cf-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius); position: sticky; top: 0; z-index: 2; } +.cf-tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; padding: 0 4px; } +.cf-tabs button[aria-selected='true'] { background: var(--surface); box-shadow: var(--shadow); color: var(--primary); } +.cf-paper { background: #fffaf0; color: #2b2116; border: 1px solid #e7d9bd; border-radius: 6px; padding: 16px; box-shadow: 0 2px 8px rgba(80,60,20,.12); position: relative; } +:root[data-theme='dark'] .cf-paper { background: #2a2620; color: #f1eadc; border-color: #4a4130; } +@media (prefers-color-scheme: dark) { :root[data-theme='auto'] .cf-paper { background: #2a2620; color: #f1eadc; border-color: #4a4130; } } +.cf-stamp { display: inline-block; font-size: .85rem; font-weight: 800; color: #b91c1c; border: 2px solid currentColor; border-radius: 6px; padding: 1px 8px; transform: rotate(-2deg); margin-bottom: 6px; } +.cf-doc { font-size: max(16px, 1.05rem); line-height: 1.75; overflow-wrap: anywhere; } +.cf-doc p { margin: 0 0 .7em; } +.cf-doc ul { margin: 0 0 .7em; padding-left: 1.2em; } +.cf-doc table { border-collapse: collapse; margin: 0 0 .7em; font-size: max(16px, 1rem); } +.cf-doc td, .cf-doc th { border: 1px solid #d6c7a6; padding: 4px 10px; text-align: left; } +.cf-deep { border-left: 4px solid #2563eb; padding: 8px 12px; margin-top: 8px; background: rgba(37,99,235,.07); border-radius: 4px; } +.cf-leads { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; } +@media (max-width: 560px) { .cf-leads { grid-template-columns: minmax(0, 1fr); } } +.cf-lead { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); } +.cf-lead.mine { border-color: var(--primary); } +.cf-lead.no { opacity: .55; } +.cf-lead strong { font-size: max(16px, 1rem); } +.cf-cost { font-size: .95rem; color: var(--text-sub); } +.cf-tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); margin-right: 4px; } +.cf-tag.warn { background: var(--warning-soft); color: var(--warning); } +.cf-btns { display: flex; flex-wrap: wrap; gap: 6px; } +.cf-btns .btn { flex: 1 1 auto; min-height: 44px; } +.cf-place { font-size: .95rem; font-weight: 800; margin: 6px 0 2px; color: var(--text-sub); } +.cf-zones { display: flex; flex-wrap: wrap; gap: 6px; } +.cf-zone { padding: 4px 10px; border-radius: 999px; border: 2px solid var(--border); font-size: .95rem; } +.cf-zone.here { border-color: var(--primary); background: var(--primary-soft); font-weight: 800; } +.cf-log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; } +.cf-log button.cf-row { width: 100%; text-align: left; min-height: 48px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; } +.cf-person { padding: 10px 12px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); display: flex; gap: 8px; align-items: flex-start; } +.cf-person[data-sus='1'] { border-color: #eab308; } +.cf-person[data-sus='2'] { border-color: #dc2626; } +.cf-q { display: flex; flex-direction: column; gap: 8px; } +.cf-q .cf-choices { display: flex; flex-direction: column; gap: 6px; } +.cf-q .cf-choices button { text-align: left; justify-content: flex-start; min-height: 48px; font-size: max(16px, 1rem); } +.cf-grade { font-size: 2.6rem; font-weight: 900; color: #b91c1c; border: 5px double currentColor; border-radius: 12px; padding: 4px 18px; display: inline-block; transform: rotate(-6deg); animation: cf-stamp .5s ease-out; } +.cf-grade.ok { color: #15803d; } +@keyframes cf-stamp { from { transform: scale(2.4) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(-6deg); opacity: 1; } } +@media (prefers-reduced-motion: reduce) { .cf-grade { animation: none; } } +.cf-table { width: 100%; border-collapse: collapse; font-size: .95rem; } +.cf-table td, .cf-table th { border-bottom: 1px solid var(--border); padding: 6px 4px; text-align: left; vertical-align: top; } +.cf-memo { width: 100%; min-height: 220px; font: inherit; font-size: max(16px, 1rem); line-height: 1.6; padding: 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); } +`; + +// ---------------------------------------------------------------- device-only notes (§9) + +function roomCode(): string { + return /\/r\/(\d{6})/.exec(typeof location !== 'undefined' ? location.pathname : '')?.[1] ?? 'replay'; +} +function useStored(kind: string, startedAt: number, init: T): [T, (v: T) => void] { + const key = `bg:case-file:${kind}:${roomCode()}:${startedAt}`; + const [val, setVal] = useState(() => { + try { + const raw = localStorage.getItem(key); + return raw === null ? init : (JSON.parse(raw) as T); + } catch { + return init; + } + }); + const set = (v: T) => { + setVal(v); + try { + localStorage.setItem(key, JSON.stringify(v)); + } catch { + /* storage full or blocked: keep it in memory */ + } + }; + return [val, set]; +} + +// ---------------------------------------------------------------- text (a small markdown subset of the case doc) + +function Inline({ text, titles }: { text: string; titles: Record }) { + const parts = text.split(/(\*\*[^*]+\*\*|`c\d-\d\d`)/g); + return ( + <> + {parts.map((p, i) => { + if (p.startsWith('**') && p.endsWith('**')) return {p.slice(2, -2)}; + if (/^`c\d-\d\d`$/.test(p)) return 「{titles[p.slice(1, -1)] ?? p.slice(1, -1)}」; + return {p}; + })} + + ); +} + +function Doc({ text, titles = {} }: { text: string; titles?: Record }) { + const blocks = text.split(/\n\s*\n/); + return ( +
+ {blocks.map((b, i) => { + const lines = b.split('\n'); + if (lines.every((l) => l.startsWith('|'))) { + const rows = lines.filter((l) => !/^\|[-| ]+\|$/.test(l)).map((l) => l.slice(1, -1).split('|').map((c) => c.trim())); + return ( + + + {rows.map((r, ri) => ( + {r.map((c, ci) => (ri === 0 ? : ))} + ))} + +
{c}{c}
+ ); + } + if (lines.every((l) => l.startsWith('- '))) { + return ( +
    + {lines.map((l, li) => ( +
  • + ))} +
+ ); + } + return ( +

+ {lines.map((l, li) => ( + + {li > 0 &&
} + +
+ ))} +

+ ); + })} +
+ ); +} + +// ---------------------------------------------------------------- shared bits + +const actionOf = (ch: Choice): unknown => { + switch (ch.type) { + case 'lead': + return { type: 'pick', lead: ch.lead }; + case 'deep': + return { type: 'deep', lead: ch.lead }; + default: + return { type: ch.type }; + } +}; +const keyOf = (ch: Choice) => (ch.type === 'lead' || ch.type === 'deep' ? `${ch.type}:${ch.lead}` : ch.type); + +/** Runs a choice: a vote in vote mode, otherwise a direct action that needs a second press to confirm (§5.2 free). */ +function useChooser(v: CaseFileView, act: (a: unknown) => void) { + const [armed, setArmed] = useState(null); + useEffect(() => setArmed(null), [v.inv?.log.length, v.inv?.day, v.phase, v.decider]); + const voting = v.can.vote; + const mine = (key: string) => !!v.myVote && v.myVote !== 'pass' && keyOf(v.myVote) === key; + const press = (c: ChoiceView) => { + if (voting) { + sfx.select(); + act({ type: 'vote', choice: c.choice }); + return; + } + if (armed !== c.key) { + setArmed(c.key); + sfx.click(); + return; + } + setArmed(null); + if (c.choice.type === 'lead') sfx.cardFlip(); + act(actionOf(c.choice)); + }; + const label = (c: ChoiceView, base: string) => (voting ? (mine(c.key) ? `✓ 투표함: ${base}` : `투표: ${base}`) : armed === c.key ? '정말 이걸로 해요' : base); + return { press, label, armed, voting, mine }; +} + +function CaseBar({ v, players, deadline }: { v: CaseFileView; players: Players; deadline: number | null }) { + const inv = v.inv; + const mineTurn = v.can.control || (v.can.vote && !v.myVote) || v.can.answer || v.can.ready; + return ( +
+

🔍 {v.title} ({v.level})

+ {inv && v.phase === 'investigate' && !inv.reported && ( + <> + {inv.day}일째 {clock(inv.hour)} / {clock(inv.dayEnd)}까지 + + {Array.from({ length: v.days }, (_, i) => )} + + + )} + {inv && ( + + 🔍 {inv.magnifiers} · 💡 {inv.hintsLeft} · 😪 {inv.fatigue} + + )} + {v.phase === 'investigate' && v.mode === 'coop' && v.decision === 'rotate' && 지금 반장: {v.decider === v.me ? '나' : `${nick(players, v.decider)}님`}} + {v.phase === 'investigate' && v.mode === 'coop' && v.decision === 'vote' && 투표 {v.seats.filter((s) => s.voted).length}/{v.seats.filter((s) => !s.left).length}} + {deadline && v.phase !== 'ended' && } +
+ ); +} + +function ReadCard({ e, v, players, chooser, titles }: { e: LogEntryView; v: CaseFileView; players: Players; chooser?: ReturnType; titles: Record }) { + const deep = v.choices.find((c) => c.key === `deep:${e.lead}`); + return ( +
+ {e.day}일째 {clock(e.at)} · {e.placeName} +

{e.title}

+ {e.text !== null ? :

📖 {nick(players, e.by)}님이 읽고 있어요. 채팅으로 들려 달라고 해 보세요.

} + {e.deepUsed && (e.deepText !== null ? ( +
🔍 깊이 보기
+ ) : ( +

🔍 {nick(players, e.deepBy)}님이 깊이 봤어요.

+ ))} + {e.opened.length > 0 &&

새로 열린 단서: {e.opened.join(', ')}

} + {e.deepOpened.length > 0 &&

깊이 보기로 열린 단서: {e.deepOpened.join(', ')}

} + {deep && chooser && ( +
+ +
+ )} + {!deep && e.hasDeep && !e.deepUsed && v.phase === 'investigate' &&

🔍 이 단서는 깊이 볼 수 있어요{v.inv?.magnifiers ? '' : '(돋보기가 없어요)'}.

} +
+ ); +} + +function LeadCard({ l, v, players, chooser, onPin }: { l: LeadCardView; v: CaseFileView; players: Players; chooser: ReturnType; onPin: (lead: string | null) => void }) { + const c = v.choices.find((x) => x.key === `lead:${l.id}`); + const myPin = v.me ? v.seats.find((s) => s.id === v.me)?.pin === l.id : false; + const multi = v.seats.length > 1; + return ( +
+ {l.title} + + {l.travel > 0 ? `이동 ${l.travel} + ` : ''}단서 {l.hours}시간 = {l.total}시간 + + + {l.deep && 🔍 깊이 보기 있음} + {l.overtime > 0 && 야근 {l.overtime}시간} + {!l.ok && {l.why}} + + {l.pins.length > 0 && 👍 {l.pins.map((p) => (p === v.me ? '나' : nick(players, p))).join(', ')}} +
+ {c && } + {v.can.pin && multi && ( + + )} +
+
+ ); +} + +function LeadsTab({ v, players, act, titles }: { v: CaseFileView; players: Players; act: (a: unknown) => void; titles: Record }) { + const inv = v.inv!; + const chooser = useChooser(v, act); + const onPin = (lead: string | null) => act({ type: 'pin', lead }); + const last = inv.log.at(-1); + const today = inv.news.find((n) => n.day === inv.day); + const groups = new Map(); + for (const l of inv.leads) groups.set(l.placeName, [...(groups.get(l.placeName) ?? []), l]); + const extra = v.choices.filter((c) => c.choice.type === 'hint' || c.choice.type === 'endDay' || c.choice.type === 'report'); + const free = v.mode === 'coop' && v.decision === 'free'; + const meSeat = v.seats.find((s) => s.id === v.me); + const here = v.seats.filter((s) => !s.left && s.idle === 0); + return ( +
+ {today && inv.hour === 9 && ( +
📰 {today.day}일째 아침 소식
+ )} + {last && } +
+
📍 지금 위치: {inv.placeName} ({inv.zoneName})
+
+ {v.zones.map((z) => ( + + {z.name} {z.id === inv.zone ? '🕵️' : `· ${v.travel[inv.zone]?.[z.id] ?? 0}시간`} + + ))} +
+
+
+

고를 수 있는 단서 {inv.leads.length}개

+ {!v.can.control && !v.can.vote && v.mode === 'coop' &&

{v.decision === 'rotate' ? '반장이 골라요. 마음에 드는 단서에 [추천]을 눌러 주세요.' : '지금은 고를 수 없어요.'}

} + {[...groups].map(([place, list]) => ( +
+
{place}
+
+ {list.map((l) => )} +
+
+ ))} + {inv.leads.length === 0 &&

더 고를 단서가 없어요. 하루를 마치거나 보고서를 써요.

} +
+ {extra.length > 0 && ( +
+ {extra.map((c) => { + const base = c.choice.type === 'hint' ? `💡 ${c.label}(−2점, ${inv.hintsLeft}번 남음)` : c.choice.type === 'endDay' ? (inv.day >= v.days ? '🌙 마지막 날 마치기(보고서로)' : '🌙 하루 마치기') : '📝 보고서 쓰기'; + if (free && c.choice.type === 'report') { + const agreed = !!meSeat?.agree; + return ( + + ); + } + return ( + + ); + })} +
+ )} + {inv.hints.length > 0 && ( +
💡 반장님 조언
    {inv.hints.map((h, i) =>
  1. {h}
  2. )}
+ )} +
+ ); +} + +function LogTab({ v, players, startedAt, titles }: { v: CaseFileView; players: Players; startedAt: number; titles: Record }) { + const inv = v.inv; + const [open, setOpen] = useState(null); + const [stars, setStars] = useStored('star', startedAt, []); + if (!inv || inv.log.length === 0) return

아직 읽은 단서가 없어요.

; + const e = open === null ? null : inv.log[open - 1]; + return ( + <> +
    + {inv.log.map((x) => ( +
  1. + + +
  2. + ))} +
+ {e && ( + setOpen(null)} label={e.title}> + + + + )} + + ); +} + +const SUS = ['흰색', '노랑', '빨강']; +function PeopleTab({ v, startedAt }: { v: CaseFileView; startedAt: number }) { + const inv = v.inv; + const [sus, setSus] = useStored>('suspect', startedAt, {}); + return ( +
+

자료실 · 인물

+ {(inv?.people ?? []).map((p) => ( +
+
+ {p.name} +
{p.line}
+
{p.fromTitle ? `처음 나온 단서: ${p.fromTitle}` : '의뢰에서'}
+
+ +
+ ))} +

장소

+
    + {v.zones.map((z) => ( +
  • {z.name}: {v.places.filter((p) => p.zone === z.id).map((p) => p.name).join(', ')}
  • + ))} +
+ {inv && inv.news.length > 0 && ( + <> +

아침 소식

+ {inv.news.map((n) =>
{n.day}일째 아침
)} + + )} +
+ 의뢰 다시 읽기 +
+
+
+ ); +} + +function MemoTab({ startedAt }: { startedAt: number }) { + const [memo, setMemo] = useStored('note', startedAt, ''); + return ( +