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>
|
}}>{confirmedScorePoints > -1 ? `Score ${confirmedScorePoints} points ✅` : "Check"}</button>
|
||||||
<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>
|
>Open Tile Exchange</button>
|
||||||
<button onClick={(e) => {
|
<button onClick={(e) => {
|
||||||
trayDispatch({action: TileDispatchActionType.RETURN});
|
trayDispatch({action: TileDispatchActionType.RETURN});
|
||||||
|
@ -538,6 +541,10 @@ function TilesExchangedTray(props: {
|
||||||
}){
|
}){
|
||||||
|
|
||||||
const divContent = [];
|
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++){
|
for(let i = 0; i<props.trayLength; i++){
|
||||||
const tileData = props.tray[i];
|
const tileData = props.tray[i];
|
||||||
|
|
||||||
|
@ -547,11 +554,9 @@ function TilesExchangedTray(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tileData != null){
|
if(tileData != null){
|
||||||
divContent.push(
|
divContent[tileData.index] =
|
||||||
<DummyExchangeTile key={i} letter={tileData} isSelected={props.selectedArray[i]} onClick={toggleFunction}/>
|
<DummyExchangeTile key={tileData.index} letter={tileData} isSelected={props.selectedArray[i]} onClick={toggleFunction}/>;
|
||||||
);
|
|
||||||
} else{
|
|
||||||
divContent.push(<span key={i} />);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue