add live game UI with board rendering, timers, and SAN move list

This commit is contained in:
2026-02-27 12:27:02 +01:00
parent 0c3ef7da4a
commit 36727cdb24
5 changed files with 853 additions and 16 deletions
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
export const PIECE_IMAGE_PATHS = {
P: "/static/board_pieces/wp.png",
N: "/static/board_pieces/wn.png",
B: "/static/board_pieces/wb.png",
R: "/static/board_pieces/wr.png",
Q: "/static/board_pieces/wq.png",
K: "/static/board_pieces/wk.png",
p: "/static/board_pieces/bp.png",
n: "/static/board_pieces/bn.png",
b: "/static/board_pieces/bb.png",
r: "/static/board_pieces/br.png",
q: "/static/board_pieces/bq.png",
k: "/static/board_pieces/bk.png",
};
export const START_COUNTS = {
P: 8,
N: 2,
B: 2,
R: 2,
Q: 1,
K: 1,
p: 8,
n: 2,
b: 2,
r: 2,
q: 1,
k: 1,
};
+32
View File
@@ -0,0 +1,32 @@
export function formatClock(ms) {
if (!Number.isFinite(ms) || ms < 0) {
return "--:--";
}
const totalSeconds = Math.floor(ms / 1000);
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
}
export function parseFenBoard(fen) {
const boardPart = (fen || "").split(" ")[0] || "8/8/8/8/8/8/8/8";
const rows = boardPart.split("/");
const board = {};
for (let r = 0; r < 8; r += 1) {
let file = 0;
for (const fenChar of rows[r]) {
const num = Number(fenChar);
if (!Number.isNaN(num)) {
file += num;
continue;
}
const square = `${"abcdefgh"[file]}${8 - r}`;
board[square] = fenChar;
file += 1;
}
}
return board;
}