Fix blank letter at end-of-game bug

This commit is contained in:
Joel Therrien 2023-10-13 21:55:34 -07:00
parent 22d7ce969e
commit edeac3b2fd
2 changed files with 2 additions and 19 deletions

View file

@ -47,7 +47,6 @@ export function Game(props: {
const [isGameOver, setGameOver] = useState<boolean>(false);
const [confirmedScorePoints, setConfirmedScorePoints] = useState<number>(-1);
const [isResetTrayButtonEnabled, setIsResetTrayButtonEnabled] = useState<boolean>(false);
const [boardLetters, setBoardLetters] = useState<HighlightableLetterData[]>(() => {
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</button>
{isResetTrayButtonEnabled && <button onClick={() => {
trayDispatch({action: TileDispatchActionType.RETRIEVE, override: true});
setConfirmedScorePoints(-1);
}}>
Reset Tray
</button>}
</div>
</div>

View file

@ -130,9 +130,8 @@ export function TileTray(props: { letters: Array<PlayableLetterData>, 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] =
<TileSlot
tile={<Letter
@ -208,9 +207,8 @@ export function Grid(props: {
});
props.playerLetters
.filter((letter) => {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);