This commit is contained in:
Ben
2021-05-10 21:41:10 +01:00
parent ab85155a90
commit f89b11f6aa
4 changed files with 115 additions and 126 deletions

View File

@@ -156,3 +156,34 @@ function processTurn(turn)
removeStagedPieces();
renderBoardState(turn.boardtiles);
}
function newPieces(pieces)
{
removePiecesFromDrawer('*');
let drawerStructure = [];
for (const tile of pieces)
{
let points = 0;
for (const pointband of TileSet)
{
if (tile === '_')
{
points = '_';
break;
}
if (pointband.letters.includes(tile))
{
points = pointband.points;
break;
}
}
const piece = {
letter: tile,
score: points
}
drawerStructure.push(piece);
}
addPiecesToDrawer(drawerStructure);
}

View File

@@ -49,7 +49,7 @@ function initMultiplayer()
socket.on('game-turn-processed', args => onturnProcessed(socket, args)); // server returns turn (to all users)
socket.on('game-turn-start', args => onTurnStart(socket, args)); // others turn
socket.on('game-new-pieces', args => onTurnStart(socket, args));
socket.on('game-new-pieces', args => gameNewPieces(socket, args));
console.log('multiplayer ready');
}
@@ -296,6 +296,12 @@ function onTurnStart(socket, args)
startOthersTurn(args.turninfo.turnplayer.uid);
}
function gameNewPieces(socket, args)
{
console.log(args);
newPieces(args.pieces)
}
// is game singleplayer?
let isSingleplayer = false;
if (urlParser.get('uid') === null)