From 009214c9f356d03e5688cc7ad3788492c2f7ad34 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Sun, 11 Oct 2026 02:07:02 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=EA=B2=B0=EA=B3=BC=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4:=20=EB=93=B1=EC=88=98=20=EC=98=86=EC=97=90?= =?UTF-8?q?=20=EA=B7=B8=20=ED=8C=90=EC=9D=98=20=EC=B5=9C=EC=A2=85=20?= =?UTF-8?q?=EC=A0=90=EC=88=98=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GameResult/GameResultView에 scoreText(게임별 표시 문구) 추가 - 점수가 있는 18개 게임이 결과에 최종 점수 문구를 넣음 (n점, n칩, 총자산 nP, 난 말 n개, 카드 n장 등) - 점수가 없는 게임(오목·체스·쿼리도·다빈치 코드·99·뱅·마피아·바퀴벌레 포커)은 등수만 - 결과 창 각 줄 오른쪽에 최종 점수(진하게), 그 아래 이 방 전적 - 전 게임 무작위 진행 테스트, 요트 기권 E2E, docs/06·09 갱신 Co-Authored-By: Claude Opus 5.5 --- apps/web/src/pages/RoomPage.tsx | 12 +++++-- docs/06-lobby-rooms.md | 1 + docs/09-game-engine.md | 1 + e2e/bots.e2e.ts | 24 +++++++++++++- packages/engine/src/types.ts | 2 ++ packages/games/src/baduk/index.ts | 7 +++- packages/games/src/catchmind/index.ts | 1 + packages/games/src/dalmuti/index.ts | 9 ++++- packages/games/src/dobble/index.ts | 10 ++++++ packages/games/src/gostop/index.ts | 8 ++++- packages/games/src/halli-galli/index.ts | 1 + packages/games/src/janggi/index.ts | 1 + packages/games/src/las-vegas/index.ts | 2 +- packages/games/src/mahjong/index.ts | 3 ++ packages/games/src/marble/index.ts | 1 + packages/games/src/one-card/index.ts | 8 ++++- packages/games/src/othello/index.ts | 1 + packages/games/src/othello/othello.test.ts | 2 +- packages/games/src/poker/hand.ts | 3 +- packages/games/src/poker/index.ts | 1 + packages/games/src/poker/types.ts | 9 ++++- packages/games/src/result-score.test.ts | 38 ++++++++++++++++++++++ packages/games/src/rummikub/index.ts | 8 ++++- packages/games/src/seotda/index.ts | 8 +++-- packages/games/src/splendor/index.ts | 2 +- packages/games/src/yacht/index.ts | 2 +- packages/games/src/yut/index.ts | 1 + packages/games/src/yut/yut.test.ts | 1 + packages/shared/src/types.ts | 2 ++ 29 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 packages/games/src/result-score.test.ts diff --git a/apps/web/src/pages/RoomPage.tsx b/apps/web/src/pages/RoomPage.tsx index e298eef..5350195 100644 --- a/apps/web/src/pages/RoomPage.tsx +++ b/apps/web/src/pages/RoomPage.tsx @@ -715,8 +715,16 @@ function ResultPanel({ room, me, players, onLeave, onAgain }: { room: RoomView; {i + 1}등 {players[u] && } {players[u] ? : '나간 사람'} - - 이 방에서 {room.sessionStats[u]?.wins ?? 0}승 / {room.sessionStats[u]?.played ?? 0}판 + + {/* Final score of this game, in the game's own words (35점, +1,200칩, 카드 12장). */} + {result.scoreText?.[u] && ( + + {result.scoreText[u]} + + )} + + 이 방에서 {room.sessionStats[u]?.wins ?? 0}승 / {room.sessionStats[u]?.played ?? 0}판 + )), diff --git a/docs/06-lobby-rooms.md b/docs/06-lobby-rooms.md index 0119bab..3d91da4 100644 --- a/docs/06-lobby-rooms.md +++ b/docs/06-lobby-rooms.md @@ -66,6 +66,7 @@ ## 9. 게임 끝 - 결과 화면: 순위, 점수, 핵심 장면 요약(예: "흑 5목 완성"), [한 판 더] [게임 바꾸기] [나가기]. +- 최종 점수(2026-10-11): 등수 줄마다 오른쪽에 그 판의 최종 점수를 진하게, 그 아래 "이 방에서 n승 / n판"을 작게 둔다. 문구는 게임이 `GameResult.scoreText`로 정한다. 점수 계열 요트·스플렌더·라스베가스·캐치마인드·달무티(누적 점수 방식)·원카드(색깔 카드)는 "n점", 고스톱·루미큐브는 "+n점/-n점", 마작 "35,000점(+25.0)", 오델로 "n점", 바둑 "n집 반"(중국식 "n점", 계가했을 때만), 장기 "기물 n점", 섯다·포커 "n칩", 부루마블 "총자산 nP", 윷놀이 "난 말 n개", 할리갈리 "카드 n장", 도블 "모은/남은/받은 카드 n장"·"벌점 n장". 점수가 없는 오목·체스·쿼리도·다빈치 코드·99·뱅·마피아·바퀴벌레 포커는 등수만 보인다. - [한 판 더]는 누른 사람을 그 방 대기실로 돌려보낸다(2026-10-11, 전에는 모두 눌러야 시작하는 투표라 한 명이 안 누르면 결과 창에서 계속 기다렸다). 자리에 앉은 사람이 누르면 "준비 완료"가 되어 방장이 누가 또 하고 싶은지 본다. 대기실에서 자리·컴퓨터·설정을 바꾼 뒤 방장이 [게임 시작]. 아직 결과 창을 보는 사람은 방장이 시작하면 새 판으로 넘어간다. 어느 판 뒤에 대기실로 왔는지는 탭마다 기억해서(`sessionStorage`) 새로고침해도 대기실에 남는다. 서버의 `rematch` 투표 메시지는 남아 있지만 화면에서는 쓰지 않는다. - 기록: 끝난 게임은 `game_results`에 저장, 방 안에서 "이번 방 전적"(예: OO 3승 2패) 표시. diff --git a/docs/09-game-engine.md b/docs/09-game-engine.md index 056ecdc..afe6de4 100644 --- a/docs/09-game-engine.md +++ b/docs/09-game-engine.md @@ -19,6 +19,7 @@ export interface GameEvent { type: string; [k: string]: unknown } // 애니메 export interface GameResult { ranking: PlayerId[][]; // [[1등], [공동 2등, 공동 2등], ...] scores?: Record; + scoreText?: Record; // 결과 화면의 최종 점수 "35점", "1,200칩", "카드 12장" (점수 없는 게임은 생략) summary: string; // "흑 5목 완성으로 OO님 승리" reason: 'normal' | 'resign' | 'timeout' | 'abandoned' | 'draw-agreed'; } diff --git a/e2e/bots.e2e.ts b/e2e/bots.e2e.ts index b0ed69f..59ac2a5 100644 --- a/e2e/bots.e2e.ts +++ b/e2e/bots.e2e.ts @@ -70,7 +70,7 @@ try { const pc = await browser.newContext({ viewport: { width: 1440, height: 900 }, locale: 'ko-KR' }); const phone = await browser.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true, locale: 'ko-KR' }); // The first-game "30초 규칙 요약" cards are tested in e2e/tutorial.e2e.ts; mark them seen here. - for (const ctx of [pc, phone]) await ctx.addInitScript(() => { for (const g of ['omok', 'one-card']) localStorage.setItem(`bg:qs:${g}`, '1'); }); + for (const ctx of [pc, phone]) await ctx.addInitScript(() => { for (const g of ['omok', 'one-card', 'yacht']) localStorage.setItem(`bg:qs:${g}`, '1'); }); const a = await pc.newPage(); const b = await phone.newPage(); const errors: string[] = []; @@ -244,6 +244,28 @@ try { if (app.rooms.get(code)) throw new Error('room still open after leaving the lobby'); }); + await step('요트(연습): 기권 → 결과 창에 등수와 최종 점수', async () => { + await b.goto(`${ORIGIN}/g/yacht`); + await b.getByRole('button', { name: '🤖 컴퓨터와 연습하기' }).click(); + await b.waitForURL(/\/r\/\d{6}$/); + await b.getByLabel('자리').getByText('컴퓨터 1').waitFor(); + await b.getByRole('button', { name: '▶ 게임 시작' }).click(); + await b.getByRole('button', { name: '🏳 기권' }).click(); + await b.getByRole('button', { name: '기권하기' }).click(); + const result = b.getByRole('dialog', { name: '게임 결과' }); + await result.waitFor(); + const ranks = await result.locator('strong', { hasText: /^\d+등$/ }).allInnerTexts(); + const scores = await result.locator('.result-score').allInnerTexts(); + if (ranks.length !== 2 || scores.length !== 2 || !scores.every((t) => /^\d+점$/.test(t))) { + throw new Error(`ranks ${JSON.stringify(ranks)} scores ${JSON.stringify(scores)}`); + } + await Bun.sleep(400); // let the sheet finish sliding in + await b.screenshot({ path: join(SHOTS, 'bots-5-yacht-result-phone.png') }); + console.log(` yacht result: ${ranks.map((r, i) => `${r} ${scores[i]}`).join(', ')}`); + await result.getByRole('button', { name: '방 나가기' }).click(); + await b.waitForURL(`${ORIGIN}/`); + }); + await step('게스트 로그아웃 → 계정 삭제', async () => { const id = userId('호랑이')!; await a.getByRole('button', { name: '내 계정: 호랑이' }).click(); diff --git a/packages/engine/src/types.ts b/packages/engine/src/types.ts index 5b287db..16610b4 100644 --- a/packages/engine/src/types.ts +++ b/packages/engine/src/types.ts @@ -15,6 +15,8 @@ export interface GameResult { /** Groups of tied players, best first: [[winner], [second, second], ...]. */ ranking: PlayerId[][]; scores?: Record; + /** Final score as shown on the result screen, e.g. "35점", "+1,200칩", "카드 12장". Omitted when the game has no score. */ + scoreText?: Record; /** Korean, user-facing summary line. */ summary: string; reason: ResultReason; diff --git a/packages/games/src/baduk/index.ts b/packages/games/src/baduk/index.ts index 04a6fd7..080308d 100644 --- a/packages/games/src/baduk/index.ts +++ b/packages/games/src/baduk/index.ts @@ -845,7 +845,12 @@ export const baduk: GameDefinition = return { ranking: [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ids]) => ids), scores: { ...s.scores }, + scoreText: Object.fromEntries(f.ranking.map((r) => [r.id, `${s.scores[r.id] ?? 0}점`])), summary: f.summary, reason: 'normal', }; diff --git a/packages/games/src/dalmuti/index.ts b/packages/games/src/dalmuti/index.ts index 55af68c..14d5056 100644 --- a/packages/games/src/dalmuti/index.ts +++ b/packages/games/src/dalmuti/index.ts @@ -698,7 +698,14 @@ export const dalmuti: Def = { result(s): GameResult | null { if (!s.final) return null; - return { ranking: s.final.ranking, scores: Object.fromEntries(s.final.players.map((p) => [p.player, p.total])), summary: s.final.summary, reason: 'normal' }; + const lastRoundOnly = s.options.scoring === 'last-round'; + return { + ranking: s.final.ranking, + scores: Object.fromEntries(s.final.players.map((p) => [p.player, p.total])), + ...(lastRoundOnly ? {} : { scoreText: Object.fromEntries(s.final.players.map((p) => [p.player, `${p.total}점`])) }), + summary: s.final.summary, + reason: 'normal', + }; }, legalActions(s, p) { diff --git a/packages/games/src/dobble/index.ts b/packages/games/src/dobble/index.ts index 618c697..6feb0bb 100644 --- a/packages/games/src/dobble/index.ts +++ b/packages/games/src/dobble/index.ts @@ -18,6 +18,7 @@ import { type DobbleView, type Feedback, type LogEntry, + type MiniGame, type PendingClaim, type RankRow, type SeatStatus, @@ -640,6 +641,14 @@ function playerCountError(o: DobbleOptions, count: number): string | null { type Def = GameDefinition; +/** Result-screen score per mini game: what decided the rank. */ +const SCORE_TEXT: Record string> = { + tower: (r) => `모은 카드 ${r.cards ?? 0}장`, + well: (r) => `남은 카드 ${r.cards ?? 0}장`, + poisonedGift: (r) => `받은 카드 ${r.cards ?? 0}장`, + hotPotato: (r) => `벌점 ${r.penalty ?? 0}장`, +}; + export const dobble: Def = { id: 'dobble', nameKo: '도블', @@ -816,6 +825,7 @@ export const dobble: Def = { return { ranking: [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ids]) => ids), scores, + scoreText: Object.fromEntries(f.ranking.map((r) => [r.id, SCORE_TEXT[f.miniGame](r)])), summary: f.summary, reason: 'normal', }; diff --git a/packages/games/src/gostop/index.ts b/packages/games/src/gostop/index.ts index 7758608..2668354 100644 --- a/packages/games/src/gostop/index.ts +++ b/packages/games/src/gostop/index.ts @@ -573,7 +573,13 @@ export const gostop: GameDefinition [p, `${n > 0 ? '+' : ''}${n.toLocaleString('ko-KR')}점`])), + summary: s.final.summary, + reason: 'normal', + }; }, legalActions(s, player) { diff --git a/packages/games/src/halli-galli/index.ts b/packages/games/src/halli-galli/index.ts index b3579ff..f1224ec 100644 --- a/packages/games/src/halli-galli/index.ts +++ b/packages/games/src/halli-galli/index.ts @@ -585,6 +585,7 @@ export const halliGalli: GameDefinition return { ranking: [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ids]) => ids), scores, + scoreText: Object.fromEntries(f.ranking.map((r) => [r.id, `카드 ${r.cards}장`])), summary: f.summary, reason: 'normal', }; diff --git a/packages/games/src/janggi/index.ts b/packages/games/src/janggi/index.ts index ff96c44..d428bb0 100644 --- a/packages/games/src/janggi/index.ts +++ b/packages/games/src/janggi/index.ts @@ -752,6 +752,7 @@ export const janggi: GameDefinition = {}; for (const row of r.ranking) scores[row.player] = row.total; - return { ranking: [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ps]) => ps), scores, summary: r.summary, reason: r.reason }; + return { ranking: [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ps]) => ps), scores, scoreText: Object.fromEntries(Object.entries(scores).map(([p, n]) => [p, `${n}점`])), summary: r.summary, reason: r.reason }; }, /** Test helper: ROLL, or one PLACE per rolled number (CONCEDE left out). */ diff --git a/packages/games/src/mahjong/index.ts b/packages/games/src/mahjong/index.ts index ea4a078..967eb6e 100644 --- a/packages/games/src/mahjong/index.ts +++ b/packages/games/src/mahjong/index.ts @@ -1585,6 +1585,9 @@ export const mahjong: GameDefinition [r.player]), scores: Object.fromEntries(s.final.ranking.map((r) => [r.player, r.score])), + scoreText: Object.fromEntries( + s.final.ranking.map((r) => [r.player, `${r.points.toLocaleString('en-US')}점(${r.score > 0 ? '+' : ''}${r.score.toFixed(1)})`]), + ), summary: s.final.summary, reason: 'normal', }; diff --git a/packages/games/src/marble/index.ts b/packages/games/src/marble/index.ts index 766a451..b3512f0 100644 --- a/packages/games/src/marble/index.ts +++ b/packages/games/src/marble/index.ts @@ -510,6 +510,7 @@ export const marble: GameDefinition a[0] - b[0]).map(([, ps]) => ps), scores, + scoreText: Object.fromEntries(Object.entries(scores).map(([p, n]) => [p, `총자산 ${n}P`])), summary: f.summary, reason: resign ? 'resign' : 'normal', }; diff --git a/packages/games/src/one-card/index.ts b/packages/games/src/one-card/index.ts index 87c85c7..bd49d84 100644 --- a/packages/games/src/one-card/index.ts +++ b/packages/games/src/one-card/index.ts @@ -1007,7 +1007,13 @@ export const oneCard: GameDefinition [p, `${n}점`])) } : {}), + summary: s.final.summary, + reason: 'normal', + }; }, legalActions(s, p) { diff --git a/packages/games/src/othello/index.ts b/packages/games/src/othello/index.ts index f739d64..4ff848a 100644 --- a/packages/games/src/othello/index.ts +++ b/packages/games/src/othello/index.ts @@ -489,6 +489,7 @@ export const othello: GameDefinition { expect(s.result).toMatchObject({ winner: 'black', reason: 'noMoves', discs: { black: 7, white: 0, empty: 57 } }); expect(s.result!.summary).toBe('흑 승 (흑 7 : 백 0)'); expect(r.events.at(-1)).toMatchObject({ type: 'gameEnded', winner: 'black' }); - expect(othello.result(s)).toEqual({ ranking: [['A'], ['B']], scores: { A: 7, B: 0 }, summary: '흑 승 (흑 7 : 백 0)', reason: 'normal' }); + expect(othello.result(s)).toEqual({ ranking: [['A'], ['B']], scores: { A: 7, B: 0 }, scoreText: { A: '7점', B: '0점' }, summary: '흑 승 (흑 7 : 백 0)', reason: 'normal' }); expect(othello.deadline!(s)).toBeNull(); expect(othello.activePlayers(s)).toEqual([]); }); diff --git a/packages/games/src/poker/hand.ts b/packages/games/src/poker/hand.ts index 2efe0a9..7208b58 100644 --- a/packages/games/src/poker/hand.ts +++ b/packages/games/src/poker/hand.ts @@ -700,7 +700,8 @@ export function finishGame(s: PokerState, ctx: Ctx): void { if (abandoned) summary = `다른 참가자가 모두 나가서 ${s.handsPlayed}판 만에 끝났어요`; else if (lastStanding) summary = `${s.handsPlayed}판 만에 최후의 1인이 정해졌어요`; else summary = `${s.handsPlayed}판 끝 · ${top.length > 1 ? '공동 1위' : '1위'} ${fmt(net(top[0]!))}`; - s.result = { ranking: groups.map((g) => g.map((x) => x.id)), scores, summary, abandoned }; + const scoreText = Object.fromEntries(s.seats.map((x) => [x.id, `${(lastStanding ? x.stack : net(x)).toLocaleString('ko-KR')}칩`])); + s.result = { ranking: groups.map((g) => g.map((x) => x.id)), scores, scoreText, summary, abandoned }; ctx.events.push({ type: 'gameEnd' }); } diff --git a/packages/games/src/poker/index.ts b/packages/games/src/poker/index.ts index 867688b..8eee67b 100644 --- a/packages/games/src/poker/index.ts +++ b/packages/games/src/poker/index.ts @@ -355,6 +355,7 @@ function result(s: PokerState): (GameResult & { stats: PokerState['stats']; hand return { ranking: s.result.ranking, scores: s.result.scores, + ...(s.result.scoreText ? { scoreText: s.result.scoreText } : {}), summary: s.result.summary, reason: s.result.abandoned ? 'abandoned' : 'normal', stats: s.stats, diff --git a/packages/games/src/poker/types.ts b/packages/games/src/poker/types.ts index bf5c83c..4251459 100644 --- a/packages/games/src/poker/types.ts +++ b/packages/games/src/poker/types.ts @@ -155,7 +155,14 @@ export interface PokerState { stats: PokerStats; /** Total chips ever handed out (start + rebuys) — conservation check. */ chipsIssued: number; - result: { ranking: PlayerId[][]; scores: Record; summary: string; abandoned: boolean } | null; + result: { + ranking: PlayerId[][]; + scores: Record; + /** Result-screen score: chips at the end (re-buys taken back unless the game ran to the last player standing). */ + scoreText?: Record; + summary: string; + abandoned: boolean; + } | null; } // ---------------------------------------------------------------- view diff --git a/packages/games/src/result-score.test.ts b/packages/games/src/result-score.test.ts new file mode 100644 index 0000000..6b44519 --- /dev/null +++ b/packages/games/src/result-score.test.ts @@ -0,0 +1,38 @@ +/** Result screen: games with a score give every ranked player a final score text (docs/06 §9). */ +import { describe, expect, test } from 'bun:test'; +import { randomPlayout, seedN } from '@bg/engine'; +import { GAMES } from './index'; + +/** Games without a score (win/lose only, or survival) leave `scoreText` out. */ +const NO_SCORE = new Set(['omok', 'chess', 'quoridor', 'davinci-code', 'ninety-nine', 'bang', 'mafia', 'cockroach-poker']); +/** Options under which the game keeps score (원카드: only the 색깔 카드 mode has points). */ +const SCORED_OPTIONS: Record = { 'one-card': { mode: 'uno-style' } }; + +describe('final score text', () => { + for (const def of Object.values(GAMES)) { + if (!def.legalActions) continue; + test(def.id, () => { + const n = [3, 2, 4].find((k) => k >= def.minPlayers && k <= def.maxPlayers && !def.playerCountError?.(def.defaultOptions, k))!; + const players = Array.from({ length: n }, (_, i) => `p${i + 1}`); + let finished = 0; + let withText = 0; + for (let i = 1; i <= 6 && finished < 2; i++) { + const options = { ...def.defaultOptions, ...SCORED_OPTIONS[def.id] }; + const r = randomPlayout(def, { players, options, seed: seedN(i), maxSteps: 4000, maxApplyMs: 1000 }); // speed is checked in each game's own tests + if (!r.finished) continue; + const result = def.result(r.finalState); + if (!result || result.reason === 'abandoned') continue; + finished++; + if (NO_SCORE.has(def.id)) { + expect(result.scoreText).toBeUndefined(); + continue; + } + if (!result.scoreText) continue; // e.g. 바둑 by resignation, 원카드 without points, 달무티 last-round mode + withText++; + for (const p of result.ranking.flat()) expect(result.scoreText[p]).toMatch(/\S/); + } + expect(finished).toBeGreaterThan(0); + if (!NO_SCORE.has(def.id)) expect(withText).toBeGreaterThan(0); + }); + } +}); diff --git a/packages/games/src/rummikub/index.ts b/packages/games/src/rummikub/index.ts index 2ebcd3a..d76cfdf 100644 --- a/packages/games/src/rummikub/index.ts +++ b/packages/games/src/rummikub/index.ts @@ -764,7 +764,13 @@ export const rummikub: GameDefinition [p, `${n > 0 ? '+' : ''}${n}점`])), + summary: s.final.summary, + reason: s.final.reason, + }; }, /** Test helper: draw / play rack-only sets / extend a table set / an invalid try, then commit or undo. */ diff --git a/packages/games/src/seotda/index.ts b/packages/games/src/seotda/index.ts index 79e34a0..02c6465 100644 --- a/packages/games/src/seotda/index.ts +++ b/packages/games/src/seotda/index.ts @@ -206,6 +206,8 @@ export interface HandRecord { export interface SeotdaFinal { ranking: PlayerId[][]; scores: Record; + /** Result-screen score: chips at the end (re-buys taken back when the game ends by hand count). */ + scoreText?: Record; summary: string; } @@ -740,7 +742,8 @@ function finishGame(s: SeotdaState, events: GameEvent[]): void { } else { summary = `${s.handsPlayed}판 만에 끝났어요. 1위 ${(seatOf(s, top[0]!)?.stack ?? 0).toLocaleString('ko-KR')}칩${best}`; } - s.final = { ranking, scores, summary }; + const scoreText = Object.fromEntries(s.seats.map((x) => [x.id, `${(byScore ? scores[x.id]! : x.stack).toLocaleString('ko-KR')}칩`])); + s.final = { ranking, scores, scoreText, summary }; events.push({ type: 'gameEnd', ranking }); } @@ -1221,7 +1224,8 @@ export const seotda: GameDefinition = {}; for (const row of r.ranking) scores[row.player] = row.points; - return { ranking: [...groups.values()], scores, summary: r.summary, reason: r.reason }; + return { ranking: [...groups.values()], scores, scoreText: Object.fromEntries(Object.entries(scores).map(([p, n]) => [p, `${n}점`])), summary: r.summary, reason: r.reason }; }, /** diff --git a/packages/games/src/yacht/index.ts b/packages/games/src/yacht/index.ts index d40d8dc..5a43edf 100644 --- a/packages/games/src/yacht/index.ts +++ b/packages/games/src/yacht/index.ts @@ -459,7 +459,7 @@ export const yacht: GameDefinition = {}; for (const row of r.ranking) scores[row.player] = row.total; - return { ranking: [...groups.values()], scores, summary: r.summary, reason: r.reason }; + return { ranking: [...groups.values()], scores, scoreText: Object.fromEntries(Object.entries(scores).map(([p, n]) => [p, `${n}점`])), summary: r.summary, reason: r.reason }; }, /** Test helper: every hold pattern, roll and score for the current player (concede left out). */ diff --git a/packages/games/src/yut/index.ts b/packages/games/src/yut/index.ts index c8369ac..c3e3d23 100644 --- a/packages/games/src/yut/index.ts +++ b/packages/games/src/yut/index.ts @@ -814,6 +814,7 @@ export const yut: GameDefinition = { return { ranking: [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ps]) => ps), scores, + scoreText: Object.fromEntries(Object.entries(scores).map(([p, n]) => [p, `난 말 ${n}개`])), summary: f.summary, reason: f.reason, }; diff --git a/packages/games/src/yut/yut.test.ts b/packages/games/src/yut/yut.test.ts index 05a37dc..6a39d25 100644 --- a/packages/games/src/yut/yut.test.ts +++ b/packages/games/src/yut/yut.test.ts @@ -402,6 +402,7 @@ describe('차례·팀전·순위', () => { ['A', 'C', 'E'], ], scores: { B: 2, D: 2, F: 2, A: 0, C: 0, E: 0 }, + scoreText: { B: '난 말 2개', D: '난 말 2개', F: '난 말 2개', A: '난 말 0개', C: '난 말 0개', E: '난 말 0개' }, summary: '홍팀 승리! (말 2개 모두 남)', reason: 'normal', }); diff --git a/packages/shared/src/types.ts b/packages/shared/src/types.ts index a5ae747..8d60472 100644 --- a/packages/shared/src/types.ts +++ b/packages/shared/src/types.ts @@ -61,6 +61,8 @@ export interface RoomView { export interface GameResultView { ranking: string[][]; scores?: Record; + /** Final score shown next to each rank on the result screen (per game wording). */ + scoreText?: Record; summary: string; reason: string; }