Fix end-of-game UI bugs
This commit is contained in:
parent
7bca436012
commit
79610b958b
1 changed files with 16 additions and 7 deletions
|
@ -370,11 +370,11 @@ export function Game(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
trayDispatch({action: TileDispatchActionType.RETRIEVE});
|
||||||
|
setConfirmedScorePoints(-1);
|
||||||
if(!isGameOver){
|
if(!isGameOver){
|
||||||
logDispatch(<h4>Turn {turnCount}</h4>);
|
logDispatch(<h4>Turn {turnCount}</h4>);
|
||||||
logDispatch(<div>{playerTurnName}'s turn</div>)
|
logDispatch(<div>{playerTurnName}'s turn</div>);
|
||||||
setConfirmedScorePoints(-1);
|
|
||||||
trayDispatch({action: TileDispatchActionType.RETRIEVE});
|
|
||||||
if(playerTurnName != props.settings.playerName && !isGameOver) {
|
if(playerTurnName != props.settings.playerName && !isGameOver) {
|
||||||
runAI();
|
runAI();
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ export function Game(props: {
|
||||||
{props.settings.aiName} has {remainingAITiles} tiles
|
{props.settings.aiName} has {remainingAITiles} tiles
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
disabled={remainingTiles == 0}
|
disabled={remainingTiles == 0 || isGameOver}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
trayDispatch({action: TileDispatchActionType.RETURN}); // want all tiles back on tray for tile exchange
|
trayDispatch({action: TileDispatchActionType.RETURN}); // want all tiles back on tray for tile exchange
|
||||||
setIsTileExchangeOpen(true);
|
setIsTileExchangeOpen(true);
|
||||||
|
@ -430,7 +430,10 @@ export function Game(props: {
|
||||||
|
|
||||||
<TileTray letters={playerLetters} trayLength={props.settings.trayLength} trayDispatch={trayDispatch}/>
|
<TileTray letters={playerLetters} trayLength={props.settings.trayLength} trayDispatch={trayDispatch}/>
|
||||||
<div className="player-controls">
|
<div className="player-controls">
|
||||||
<button className="check" onClick={() => {
|
<button
|
||||||
|
className="check"
|
||||||
|
disabled={isGameOver}
|
||||||
|
onClick={() => {
|
||||||
const playedTiles = playerLetters.map((i) => {
|
const playedTiles = playerLetters.map((i) => {
|
||||||
if (i === undefined) {
|
if (i === undefined) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -485,10 +488,16 @@ export function Game(props: {
|
||||||
|
|
||||||
|
|
||||||
}}>{confirmedScorePoints > -1 ? `Score ${confirmedScorePoints} points` : "Check"}</button>
|
}}>{confirmedScorePoints > -1 ? `Score ${confirmedScorePoints} points` : "Check"}</button>
|
||||||
<button className="return" onClick={() => {
|
<button
|
||||||
|
className="return"
|
||||||
|
disabled={isGameOver}
|
||||||
|
onClick={() => {
|
||||||
trayDispatch({action: TileDispatchActionType.RETURN});
|
trayDispatch({action: TileDispatchActionType.RETURN});
|
||||||
}}>Return Tiles</button>
|
}}>Return Tiles</button>
|
||||||
<button className="pass" onClick={() => {
|
<button
|
||||||
|
className="pass"
|
||||||
|
disabled={isGameOver}
|
||||||
|
onClick={() => {
|
||||||
if (window.confirm("Are you sure you want to pass?")) {
|
if (window.confirm("Are you sure you want to pass?")) {
|
||||||
const result = props.wasm.skip_turn() as MyResult<string>;
|
const result = props.wasm.skip_turn() as MyResult<string>;
|
||||||
handlePlayerAction({type: "Pass"}, props.settings.playerName);
|
handlePlayerAction({type: "Pass"}, props.settings.playerName);
|
||||||
|
|
Loading…
Reference in a new issue