게임 결과 화면: 등수 옆에 그 판의 최종 점수 표시
- GameResult/GameResultView에 scoreText(게임별 표시 문구) 추가 - 점수가 있는 18개 게임이 결과에 최종 점수 문구를 넣음 (n점, n칩, 총자산 nP, 난 말 n개, 카드 n장 등) - 점수가 없는 게임(오목·체스·쿼리도·다빈치 코드·99·뱅·마피아·바퀴벌레 포커)은 등수만 - 결과 창 각 줄 오른쪽에 최종 점수(진하게), 그 아래 이 방 전적 - 전 게임 무작위 진행 테스트, 요트 기권 E2E, docs/06·09 갱신 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -715,8 +715,16 @@ function ResultPanel({ room, me, players, onLeave, onAgain }: { room: RoomView;
|
||||
<strong style={{ width: 40 }}>{i + 1}등</strong>
|
||||
{players[u] && <Avatar user={players[u]!} size={28} />}
|
||||
<span style={{ minWidth: 0 }}>{players[u] ? <PlayerName user={players[u]!} gameId={room.gameId} session={room.sessionStats[u]} /> : '나간 사람'}</span>
|
||||
<span className="muted small" style={{ marginLeft: 'auto' }}>
|
||||
이 방에서 {room.sessionStats[u]?.wins ?? 0}승 / {room.sessionStats[u]?.played ?? 0}판
|
||||
<span style={{ marginLeft: 'auto', textAlign: 'right' }}>
|
||||
{/* Final score of this game, in the game's own words (35점, +1,200칩, 카드 12장). */}
|
||||
{result.scoreText?.[u] && (
|
||||
<strong className="result-score" style={{ display: 'block' }}>
|
||||
{result.scoreText[u]}
|
||||
</strong>
|
||||
)}
|
||||
<span className="muted small">
|
||||
이 방에서 {room.sessionStats[u]?.wins ?? 0}승 / {room.sessionStats[u]?.played ?? 0}판
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
)),
|
||||
|
||||
@@ -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패) 표시.
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface GameEvent { type: string; [k: string]: unknown } // 애니메
|
||||
export interface GameResult {
|
||||
ranking: PlayerId[][]; // [[1등], [공동 2등, 공동 2등], ...]
|
||||
scores?: Record<PlayerId, number>;
|
||||
scoreText?: Record<PlayerId, string>; // 결과 화면의 최종 점수 "35점", "1,200칩", "카드 12장" (점수 없는 게임은 생략)
|
||||
summary: string; // "흑 5목 완성으로 OO님 승리"
|
||||
reason: 'normal' | 'resign' | 'timeout' | 'abandoned' | 'draw-agreed';
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -15,6 +15,8 @@ export interface GameResult {
|
||||
/** Groups of tied players, best first: [[winner], [second, second], ...]. */
|
||||
ranking: PlayerId[][];
|
||||
scores?: Record<PlayerId, number>;
|
||||
/** Final score as shown on the result screen, e.g. "35점", "+1,200칩", "카드 12장". Omitted when the game has no score. */
|
||||
scoreText?: Record<PlayerId, string>;
|
||||
/** Korean, user-facing summary line. */
|
||||
summary: string;
|
||||
reason: ResultReason;
|
||||
|
||||
@@ -845,7 +845,12 @@ export const baduk: GameDefinition<BadukState, BadukAction, BadukView, BadukOpti
|
||||
ranking,
|
||||
summary: summaryKo,
|
||||
reason: map[reason],
|
||||
...(sc ? { scores: { [s.players.black]: sc.black.total, [s.players.white]: sc.white.total } } : {}),
|
||||
...(sc
|
||||
? {
|
||||
scores: { [s.players.black]: sc.black.total, [s.players.white]: sc.white.total },
|
||||
scoreText: { [s.players.black]: marginKo(sc.black.total, sc.method), [s.players.white]: marginKo(sc.white.total, sc.method) },
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -744,6 +744,7 @@ export const catchmind: GameDefinition<S, A, CatchmindView, CatchmindOptions> =
|
||||
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',
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<S, A, DobbleView, DobbleOptions>;
|
||||
|
||||
/** Result-screen score per mini game: what decided the rank. */
|
||||
const SCORE_TEXT: Record<MiniGame, (r: RankRow) => 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',
|
||||
};
|
||||
|
||||
@@ -573,7 +573,13 @@ export const gostop: GameDefinition<GostopState, GostopAction, GostopView, Gosto
|
||||
|
||||
result(s): GameResult | null {
|
||||
if (!s.final) return null;
|
||||
return { ranking: s.final.ranking, scores: s.final.scores, summary: s.final.summary, reason: 'normal' };
|
||||
return {
|
||||
ranking: s.final.ranking,
|
||||
scores: s.final.scores,
|
||||
scoreText: Object.fromEntries(Object.entries(s.final.scores).map(([p, n]) => [p, `${n > 0 ? '+' : ''}${n.toLocaleString('ko-KR')}점`])),
|
||||
summary: s.final.summary,
|
||||
reason: 'normal',
|
||||
};
|
||||
},
|
||||
|
||||
legalActions(s, player) {
|
||||
|
||||
@@ -585,6 +585,7 @@ export const halliGalli: GameDefinition<S, A, HalliGalliView, HalliGalliOptions>
|
||||
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',
|
||||
};
|
||||
|
||||
@@ -752,6 +752,7 @@ export const janggi: GameDefinition<JanggiState, JanggiAction, JanggiView, Jangg
|
||||
return {
|
||||
ranking,
|
||||
scores: { [s.players.cho]: scores.cho, [s.players.han]: scores.han },
|
||||
scoreText: { [s.players.cho]: `기물 ${fmt(scores.cho)}점`, [s.players.han]: `기물 ${fmt(scores.han)}점` },
|
||||
summary: summaryKo,
|
||||
reason: map[reason] ?? 'normal',
|
||||
};
|
||||
|
||||
@@ -471,7 +471,7 @@ export const lasVegas: GameDefinition<LasVegasState, LasVegasAction, LasVegasVie
|
||||
for (const row of r.ranking) groups.set(row.rank, [...(groups.get(row.rank) ?? []), row.player]);
|
||||
const scores: Record<PlayerId, number> = {};
|
||||
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). */
|
||||
|
||||
@@ -1585,6 +1585,9 @@ export const mahjong: GameDefinition<MahjongState, MahjongAction, MahjongView, M
|
||||
return {
|
||||
ranking: s.final.ranking.map((r) => [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',
|
||||
};
|
||||
|
||||
@@ -510,6 +510,7 @@ export const marble: GameDefinition<MarbleState, MarbleAction, MarbleView, Marbl
|
||||
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}P`])),
|
||||
summary: f.summary,
|
||||
reason: resign ? 'resign' : 'normal',
|
||||
};
|
||||
|
||||
@@ -1007,7 +1007,13 @@ export const oneCard: GameDefinition<OneCardState, OneCardAction, OneCardView, O
|
||||
|
||||
result(s): GameResult | null {
|
||||
if (!s.final) return null;
|
||||
return { ranking: s.final.ranking, ...(s.final.scores ? { scores: s.final.scores } : {}), summary: s.final.summary, reason: 'normal' };
|
||||
const sc = s.final.scores;
|
||||
return {
|
||||
ranking: s.final.ranking,
|
||||
...(sc ? { scores: sc, scoreText: Object.fromEntries(Object.entries(sc).map(([p, n]) => [p, `${n}점`])) } : {}),
|
||||
summary: s.final.summary,
|
||||
reason: 'normal',
|
||||
};
|
||||
},
|
||||
|
||||
legalActions(s, p) {
|
||||
|
||||
@@ -489,6 +489,7 @@ export const othello: GameDefinition<OthelloState, OthelloAction, OthelloView, O
|
||||
return {
|
||||
ranking,
|
||||
scores: { [s.players.black]: displayScore.black, [s.players.white]: displayScore.white },
|
||||
scoreText: { [s.players.black]: `${displayScore.black}점`, [s.players.white]: `${displayScore.white}점` },
|
||||
summary,
|
||||
reason: map[reason],
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@ describe('passes and game end', () => {
|
||||
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([]);
|
||||
});
|
||||
|
||||
@@ -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' });
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<PlayerId, number>; summary: string; abandoned: boolean } | null;
|
||||
result: {
|
||||
ranking: PlayerId[][];
|
||||
scores: Record<PlayerId, number>;
|
||||
/** Result-screen score: chips at the end (re-buys taken back unless the game ran to the last player standing). */
|
||||
scoreText?: Record<PlayerId, string>;
|
||||
summary: string;
|
||||
abandoned: boolean;
|
||||
} | null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- view
|
||||
|
||||
38
packages/games/src/result-score.test.ts
Normal file
38
packages/games/src/result-score.test.ts
Normal file
@@ -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<string, object> = { '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);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -764,7 +764,13 @@ export const rummikub: GameDefinition<RummikubState, RummikubAction, RummikubVie
|
||||
|
||||
result(s): GameResult | null {
|
||||
if (!s.final) return null;
|
||||
return { ranking: s.final.ranking, scores: s.final.scores, summary: s.final.summary, reason: s.final.reason };
|
||||
return {
|
||||
ranking: s.final.ranking,
|
||||
scores: s.final.scores,
|
||||
scoreText: Object.fromEntries(Object.entries(s.final.scores).map(([p, n]) => [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. */
|
||||
|
||||
@@ -206,6 +206,8 @@ export interface HandRecord {
|
||||
export interface SeotdaFinal {
|
||||
ranking: PlayerId[][];
|
||||
scores: Record<PlayerId, number>;
|
||||
/** Result-screen score: chips at the end (re-buys taken back when the game ends by hand count). */
|
||||
scoreText?: Record<PlayerId, string>;
|
||||
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<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
|
||||
result(s): GameResult | null {
|
||||
if (!s.final) return null;
|
||||
return { ranking: s.final.ranking, scores: s.final.scores, summary: s.final.summary, reason: 'normal' };
|
||||
const { ranking, scores, scoreText, summary } = s.final;
|
||||
return { ranking, scores, ...(scoreText ? { scoreText } : {}), summary, reason: 'normal' };
|
||||
},
|
||||
|
||||
legalActions(s, p) {
|
||||
|
||||
@@ -877,7 +877,7 @@ export const splendor: GameDefinition<SplendorState, SplendorAction, SplendorVie
|
||||
for (const row of r.ranking) groups.set(row.rank, [...(groups.get(row.rank) ?? []), row.player]);
|
||||
const scores: Record<PlayerId, number> = {};
|
||||
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 };
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -459,7 +459,7 @@ export const yacht: GameDefinition<YachtState, YachtAction, YachtView, YachtOpti
|
||||
for (const row of r.ranking) groups.set(row.rank, [...(groups.get(row.rank) ?? []), row.player]);
|
||||
const scores: Record<PlayerId, number> = {};
|
||||
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). */
|
||||
|
||||
@@ -814,6 +814,7 @@ export const yut: GameDefinition<YutState, YutAction, YutView, YutOptions> = {
|
||||
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,
|
||||
};
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
@@ -61,6 +61,8 @@ export interface RoomView {
|
||||
export interface GameResultView {
|
||||
ranking: string[][];
|
||||
scores?: Record<string, number>;
|
||||
/** Final score shown next to each rank on the result screen (per game wording). */
|
||||
scoreText?: Record<string, string>;
|
||||
summary: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user