// Any socket request/responses for the actual game (when in a match) // PASS TURN 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(); }); // DRAW A CARD function requestDrawACard(){ console.log('>> drawACard'); socket.emit('drawACard', gameData.roomId, gameData.playerId); } // 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(); }); // SHUFFLE DECK function requestShuffleDeck(){ console.log('>> shuffleDeck'); socket.emit('shuffleDeck', gameData.roomId, gameData.playerId); } // Both players get an emit that the deck has been shuffled // but do not recieve any other data (not needed) // Only need to know a deck has been shuffled to perform animation in future socket.on('responseShuffleDeck', function (data) { console.log('<< shuffleDeck'); alert(data[0] + ' shuffled'); // TODO // animateDeckShuffle(playerX from data); // drawGameBoard(); // From this point drawGameBoard should be a 60FPS loop // not a one off draw after emits }); function requestPlayFromHand(listPosition){ console.log('>> playFromHand'); socket.emit('playFromHand', gameData.roomId, gameData.playerId, listPosition); } socket.on('responsePlayFromHand', function (data) { console.log('<< playFromHand'); }); // 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(); }