From edeac3b2fdc601c34dd485a98b4efa400fe83c8b Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Fri, 13 Oct 2023 21:55:34 -0700 Subject: [PATCH] Fix blank letter at end-of-game bug --- ui/src/Game.tsx | 15 --------------- ui/src/UI.tsx | 6 ++---- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/ui/src/Game.tsx b/ui/src/Game.tsx index d7f5472..91d84f2 100644 --- a/ui/src/Game.tsx +++ b/ui/src/Game.tsx @@ -47,7 +47,6 @@ export function Game(props: { const [isGameOver, setGameOver] = useState(false); const [confirmedScorePoints, setConfirmedScorePoints] = useState(-1); - const [isResetTrayButtonEnabled, setIsResetTrayButtonEnabled] = useState(false); const [boardLetters, setBoardLetters] = useState(() => { const newLetterData = [] as HighlightableLetterData[]; @@ -179,14 +178,6 @@ export function Game(props: { } else if (update.action === TileDispatchActionType.SET_BLANK) { const blankLetter = playerLetters[update.blankIndex]; - // FIXME DEBUG code - if(blankLetter == null || !blankLetter.is_blank){ - window.alert("Bug was triggered!! Doing nothing."); - console.warn({playerLetters}); - setIsResetTrayButtonEnabled(true); - return playerLetters.slice(); - } - if(blankLetter.text !== update.newBlankValue) { blankLetter.text = update.newBlankValue; if (blankLetter.location == LocationType.GRID) { @@ -531,12 +522,6 @@ export function Game(props: { } } }}>Pass - {isResetTrayButtonEnabled && } diff --git a/ui/src/UI.tsx b/ui/src/UI.tsx index c4f8bd3..b056a2e 100644 --- a/ui/src/UI.tsx +++ b/ui/src/UI.tsx @@ -130,9 +130,8 @@ export function TileTray(props: { letters: Array, trayLength } props.letters - .filter((x) => {return x !== undefined;}) .forEach((letter, i) => { - if (letter.location === LocationType.TRAY) { + if (letter != null && letter.location === LocationType.TRAY) { elements[letter.index] = {return letter !== undefined}) .forEach((letter, i) => { - if (letter.location === LocationType.GRID) { + if (letter != null && letter.location === LocationType.GRID) { const ct = props.cellTypes[letter.index]; const {className} = cellTypeToDetails(ct);