]> git.cworth.org Git - lmno.games/commitdiff
Add logging for any non-alphabetic tile that might show up
authorCarl Worth <cworth@cworth.org>
Fri, 6 Mar 2026 12:50:02 +0000 (07:50 -0500)
committerCarl Worth <cworth@cworth.org>
Fri, 6 Mar 2026 16:29:48 +0000 (11:29 -0500)
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

index c5538b8b6cd9c2830f2ef88f7f495591943dffec..0c5b656266fb37e125f7f7629f3f626c3757c40c 100644 (file)
@@ -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 (
             <Tile key={tile_index}
-                  letter={is_blank ? " " : char}
+                  letter={is_blank ? "\u00A0" : char}
                   isBlank={is_blank}
                   invalid={false}
                   unconnected={false}