From 3ae3ab730faab3f357a52d20ea4718f22e2c243e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 6 Mar 2026 07:50:02 -0500 Subject: [PATCH] Add logging for any non-alphabetic tile that might show up I saw a bug where a tile was diplayed with a value of '1' which was unexpected. If this happens again, this logging should help us determine what happened. --- letterrip/letterrip.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/letterrip/letterrip.jsx b/letterrip/letterrip.jsx index c5538b8..0c5b656 100644 --- a/letterrip/letterrip.jsx +++ b/letterrip/letterrip.jsx @@ -457,6 +457,14 @@ class Game extends React.Component { const letter = existing ? existing.letter : tile_char; const isBlank = existing ? existing.isBlank : is_blank; + if (typeof letter !== "string" || (!/^[A-Z]$/.test(letter) && letter !== "_")) { + console.error("Bad tile placement:", JSON.stringify({ + letter, tile_index, tile_char, isBlank, + source_from: source.from, existing, + tiles_length: this.state.tiles.length + })); + } + new_grid[grid_key] = { letter, tileIndex: tile_index, isBlank }; this.setState({ @@ -666,10 +674,14 @@ class Game extends React.Component { onDrop={(e) => this.on_rack_drop(e)}> {rack.map((tile_index, rack_index) => { const char = tiles[tile_index]; - const is_blank = char === "_"; + const is_blank = (char === "_" || char === undefined); + if (char !== undefined && char !== "_" && !/^[A-Z]$/.test(char)) { + console.error("Unexpected tile character:", JSON.stringify(char), + "at index", tile_index, "tiles:", JSON.stringify(tiles)); + } return (