fix: UI prevents players from playing blank, blank tiles

This commit is contained in:
Joel Therrien 2025-03-02 15:12:00 -08:00
parent 0d43ed61c4
commit eeb80d3c86

View file

@ -456,6 +456,7 @@ export function Game(props: {
className="check"
disabled={isGameOver || !isPlayersTurn}
onClick={async () => {
try {
const playedTiles = playerLetters.map((i) => {
if (i == null) {
return null;
@ -468,6 +469,9 @@ export function Game(props: {
};
if (i.is_blank) {
result.character = i.text;
if(result.character == null || result.character == " " || result.character == "") {
throw new Error("Blank tiles must contain a letter");
}
}
return result;
@ -476,6 +480,7 @@ export function Game(props: {
return null;
});
const committing = confirmedScorePoints > -1;
const result = props.api.play(playedTiles, committing);
@ -517,6 +522,10 @@ export function Game(props: {
});
}
catch(e) {
logDispatch(<div>{e.message}</div>)
}
}}>{confirmedScorePoints > -1 ? `Score ${confirmedScorePoints} points` : "Check"}</button>
<button