Improve tile exchange to retain player order
This commit is contained in:
parent
e8cff060b0
commit
de2605af67
1 changed files with 11 additions and 6 deletions
|
@ -266,7 +266,10 @@ export function Game(props: {wasm: GameWasm, settings: Settings}) {
|
|||
|
||||
}}>{confirmedScorePoints > -1 ? `Score ${confirmedScorePoints} points ✅` : "Check"}</button>
|
||||
<button
|
||||
onClick={(e) => {setIsTileExchangeOpen(true);}}
|
||||
onClick={(e) => {
|
||||
trayDispatch({action: TileDispatchActionType.RETURN}); // want all tiles back on tray for tile exchange
|
||||
setIsTileExchangeOpen(true);
|
||||
}}
|
||||
>Open Tile Exchange</button>
|
||||
<button onClick={(e) => {
|
||||
trayDispatch({action: TileDispatchActionType.RETURN});
|
||||
|
@ -538,6 +541,10 @@ function TilesExchangedTray(props: {
|
|||
}){
|
||||
|
||||
const divContent = [];
|
||||
for(let i=0; i<props.trayLength; i++) {
|
||||
divContent.push(<span key={i} />); // empty tile elements
|
||||
}
|
||||
|
||||
for(let i = 0; i<props.trayLength; i++){
|
||||
const tileData = props.tray[i];
|
||||
|
||||
|
@ -547,11 +554,9 @@ function TilesExchangedTray(props: {
|
|||
}
|
||||
|
||||
if(tileData != null){
|
||||
divContent.push(
|
||||
<DummyExchangeTile key={i} letter={tileData} isSelected={props.selectedArray[i]} onClick={toggleFunction}/>
|
||||
);
|
||||
} else{
|
||||
divContent.push(<span key={i} />);
|
||||
divContent[tileData.index] =
|
||||
<DummyExchangeTile key={tileData.index} letter={tileData} isSelected={props.selectedArray[i]} onClick={toggleFunction}/>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue