feat(game): finished-game export as a PNG image behind a format chooser
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 59s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m16s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 59s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m16s
The history header's export button now opens a chooser — Telegram's native popup inside Telegram, the app's own modal elsewhere — offering the GCG file and a new client-rendered PNG of the final position (lib/gameimage, Canvas 2D, lazy dynamic import, zero dependencies): light theme, classic A..O/1..15 axes, label-free premium fills, and a fixed-typography per-seat scoresheet with GCG-style move coordinates, multi-word sub-lines, endgame rack-settlement row, winner trophy and a hostname + device-locale finish date footer; a long game stretches the board, never the typography. Delivery mirrors the GCG rules (Web Share with no blob fallback, else download) except on Android Telegram/VK WebViews and the desktop VK iframe, where a binary PNG has no clipboard-text fallback: those get a preview modal with a long-press/right-click save hint and a copy-image button where ClipboardItem exists.
This commit is contained in:
+16
-1
@@ -16,11 +16,26 @@ export interface HistoryCell {
|
||||
words?: string[];
|
||||
/** Points scored by the move — set for kind 'play'. */
|
||||
score?: number;
|
||||
/** The main word's board coordinate in classic notation (see moveCoord) — set for kind
|
||||
* 'play'. The in-game panel does not show it; the game-image export does. */
|
||||
coord?: string;
|
||||
/** The non-play action ('pass' | 'exchange' | 'resign' | 'timeout' | …) — set for kind
|
||||
* 'action'; the component localizes it. */
|
||||
action?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* moveCoord renders a play's board coordinate in the classic notation the GCG export uses
|
||||
* (the backend's gcgPos): row-then-column (e.g. "8G") for an across play, column-then-row
|
||||
* ("H8") for a down play. Rows are 1-based numbers top to bottom, columns letters from "A"
|
||||
* left to right.
|
||||
*/
|
||||
export function moveCoord(mv: Pick<MoveRecord, 'dir' | 'mainRow' | 'mainCol'>): string {
|
||||
const col = String.fromCharCode(65 + mv.mainCol);
|
||||
const row = String(mv.mainRow + 1);
|
||||
return mv.dir === 'V' ? col + row : row + col;
|
||||
}
|
||||
|
||||
/**
|
||||
* historyGrid arranges the move journal into a row-major matrix with one column per seat.
|
||||
* Each seat's moves fill its column top to bottom, so a seat's k-th move lands in row k of
|
||||
@@ -40,7 +55,7 @@ export function historyGrid(
|
||||
if (m.player < 0 || m.player >= seatCount) continue; // defensive: drop an out-of-range seat
|
||||
cols[m.player].push(
|
||||
m.action === 'play'
|
||||
? { kind: 'play', player: m.player, words: m.words, score: m.score }
|
||||
? { kind: 'play', player: m.player, words: m.words, score: m.score, coord: moveCoord(m) }
|
||||
: { kind: 'action', player: m.player, action: m.action },
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user