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.
cardGame/public/js/game/socket.js

42 lines
1.1 KiB
JavaScript

// Any socket request/responses for the actual game (when in a match)
function requestPassTurn(){
console.log('>> passTurn');
socket.emit('passTurn', gameData.roomId, gameData.playerId);
}
socket.on('responsePassTurn', function (data) {
console.log('<< passTurn');
// Set turn data for clients (bolds their name)
updateTurn(data.turn, data.playerTurn);
drawGameBoard();
});
function requestDrawACard(){
console.log('>> drawACard');
socket.emit('drawACard', gameData.roomId, gameData.playerId);
}
// Functions like this would be elsewhere, do client-side
// validation THEN request stuff from the server?
// This is here for now, as it's used by the button
function passTurn(){
requestPassTurn();
}
// Draw Card
// Both players get new hand + deck counts updated
socket.on('responseDrawCard', function (data) {
console.log('<< drawCard');
updateCardCount(data);
drawGameBoard();
});
// Player drew card
// Player that drew the card (atm) gets the cardData, listPosition
// TODO: related attack, cost, effects, etc.
socket.on('responsePlayerDrewCard', function (data) {
console.log('<< playerDrewCard');
updatePlayerHand(data);
drawGameBoard();
});