From 7913133c663e5f338ba2ad81acd0d36a1cb45739 Mon Sep 17 00:00:00 2001 From: mehbark Date: Thu, 20 Jul 2023 14:40:25 -0400 Subject: [PATCH] chess skeleton almost? --- html/chessboard.tsx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/html/chessboard.tsx b/html/chessboard.tsx index d359a6a..3418785 100644 --- a/html/chessboard.tsx +++ b/html/chessboard.tsx @@ -1,4 +1,5 @@ -import { Main, mk_class_wrapper, render_and_copy } from "./common.tsx"; +import { Fragment } from "preact"; +import { Main, render_and_copy } from "./common.tsx"; // const Movable @@ -20,9 +21,10 @@ const piece_names = { wq: "white queen", wr: "white rook", } as const; +type PieceName = keyof typeof piece_names; // there's some dedup that could be done but eh -const start_pos: Record = { +const start_pos: Record = { br: [ [0, 0], [7, 0], @@ -55,10 +57,10 @@ const start_pos: Record = { wp: new Array(8).fill(null).map((_, i) => [i, 6]), }; -const get_src = (piece: keyof typeof piece_names): string => +const get_src = (piece: PieceName): string => `https://elo-worldle.pyrope.net/piece-${piece}.png`; -const get_alt = (piece: keyof typeof piece_names): string => +const get_alt = (piece: PieceName): string => `the ${piece_names[piece]}, lovinly pixeled by tom7`; const Piece = ({ @@ -75,6 +77,22 @@ const Piece = ({ ); +const Pieces = () => { + const pieces = []; + for (const [piece, poss] of Object.entries(start_pos)) { + for (const [x, y] of poss) { + pieces.push( + + ); + } + } + return ; +}; + render_and_copy(
@@ -85,6 +103,7 @@ render_and_copy( +
, true );