Fix blank letter at end-of-game bug
This commit is contained in:
parent
22d7ce969e
commit
edeac3b2fd
2 changed files with 2 additions and 19 deletions
|
@ -47,7 +47,6 @@ export function Game(props: {
|
||||||
|
|
||||||
const [isGameOver, setGameOver] = useState<boolean>(false);
|
const [isGameOver, setGameOver] = useState<boolean>(false);
|
||||||
const [confirmedScorePoints, setConfirmedScorePoints] = useState<number>(-1);
|
const [confirmedScorePoints, setConfirmedScorePoints] = useState<number>(-1);
|
||||||
const [isResetTrayButtonEnabled, setIsResetTrayButtonEnabled] = useState<boolean>(false);
|
|
||||||
|
|
||||||
const [boardLetters, setBoardLetters] = useState<HighlightableLetterData[]>(() => {
|
const [boardLetters, setBoardLetters] = useState<HighlightableLetterData[]>(() => {
|
||||||
const newLetterData = [] as HighlightableLetterData[];
|
const newLetterData = [] as HighlightableLetterData[];
|
||||||
|
@ -179,14 +178,6 @@ export function Game(props: {
|
||||||
} else if (update.action === TileDispatchActionType.SET_BLANK) {
|
} else if (update.action === TileDispatchActionType.SET_BLANK) {
|
||||||
const blankLetter = playerLetters[update.blankIndex];
|
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) {
|
if(blankLetter.text !== update.newBlankValue) {
|
||||||
blankLetter.text = update.newBlankValue;
|
blankLetter.text = update.newBlankValue;
|
||||||
if (blankLetter.location == LocationType.GRID) {
|
if (blankLetter.location == LocationType.GRID) {
|
||||||
|
@ -531,12 +522,6 @@ export function Game(props: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}>Pass</button>
|
}}>Pass</button>
|
||||||
{isResetTrayButtonEnabled && <button onClick={() => {
|
|
||||||
trayDispatch({action: TileDispatchActionType.RETRIEVE, override: true});
|
|
||||||
setConfirmedScorePoints(-1);
|
|
||||||
}}>
|
|
||||||
Reset Tray
|
|
||||||
</button>}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -130,9 +130,8 @@ export function TileTray(props: { letters: Array<PlayableLetterData>, trayLength
|
||||||
}
|
}
|
||||||
|
|
||||||
props.letters
|
props.letters
|
||||||
.filter((x) => {return x !== undefined;})
|
|
||||||
.forEach((letter, i) => {
|
.forEach((letter, i) => {
|
||||||
if (letter.location === LocationType.TRAY) {
|
if (letter != null && letter.location === LocationType.TRAY) {
|
||||||
elements[letter.index] =
|
elements[letter.index] =
|
||||||
<TileSlot
|
<TileSlot
|
||||||
tile={<Letter
|
tile={<Letter
|
||||||
|
@ -208,9 +207,8 @@ export function Grid(props: {
|
||||||
});
|
});
|
||||||
|
|
||||||
props.playerLetters
|
props.playerLetters
|
||||||
.filter((letter) => {return letter !== undefined})
|
|
||||||
.forEach((letter, i) => {
|
.forEach((letter, i) => {
|
||||||
if (letter.location === LocationType.GRID) {
|
if (letter != null && letter.location === LocationType.GRID) {
|
||||||
const ct = props.cellTypes[letter.index];
|
const ct = props.cellTypes[letter.index];
|
||||||
const {className} = cellTypeToDetails(ct);
|
const {className} = cellTypeToDetails(ct);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue