scoreing
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user