You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
961 B
JavaScript
36 lines
961 B
JavaScript
// To set the server data to related client data
|
|
|
|
// Update all the relevent game data from the server's data response
|
|
function updateGameData(data){
|
|
console.log(data);
|
|
|
|
updatePlayers(data.players);
|
|
updatePlayerId(data.playerId);
|
|
updateOpponentId(data.opponentId);
|
|
updateRoomId(data.roomId);
|
|
updateTurn(data.component.turn, data.component.playerTurn);
|
|
|
|
console.log(gameData);
|
|
}
|
|
|
|
// Individual or minor updates
|
|
// This will ideally be how each game function updates the data
|
|
// e.g. drawACard() would update the hand, deck, cardData, effects?
|
|
function updatePlayers(players = null){
|
|
gameData.players = players;
|
|
}
|
|
function updatePlayerId(playerId = null){
|
|
gameData.playerId = playerId;
|
|
}
|
|
function updateOpponentId(opponentId = null){
|
|
gameData.opponentId = opponentId;
|
|
}
|
|
function updateRoomId(roomId = null){
|
|
gameData.roomId = roomId;
|
|
}
|
|
function updateTurn(turn = null, playersTurn = null){
|
|
gameData.turn = turn;
|
|
gameData.playerTurn = playersTurn;
|
|
}
|
|
|