fix: UI prevents players from playing blank, blank tiles
This commit is contained in:
parent
0d43ed61c4
commit
eeb80d3c86
1 changed files with 62 additions and 53 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue