|
|
|
@ -1,5 +1,6 @@
|
|
|
|
// Any socket request/responses for the actual game (when in a match)
|
|
|
|
// Any socket request/responses for the actual game (when in a match)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PASS TURN
|
|
|
|
function requestPassTurn(){
|
|
|
|
function requestPassTurn(){
|
|
|
|
console.log('>> passTurn');
|
|
|
|
console.log('>> passTurn');
|
|
|
|
socket.emit('passTurn', gameData.roomId, gameData.playerId);
|
|
|
|
socket.emit('passTurn', gameData.roomId, gameData.playerId);
|
|
|
|
@ -10,18 +11,13 @@ socket.on('responsePassTurn', function (data) {
|
|
|
|
updateTurn(data.turn, data.playerTurn);
|
|
|
|
updateTurn(data.turn, data.playerTurn);
|
|
|
|
drawGameBoard();
|
|
|
|
drawGameBoard();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DRAW A CARD
|
|
|
|
function requestDrawACard(){
|
|
|
|
function requestDrawACard(){
|
|
|
|
console.log('>> drawACard');
|
|
|
|
console.log('>> drawACard');
|
|
|
|
socket.emit('drawACard', gameData.roomId, gameData.playerId);
|
|
|
|
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
|
|
|
|
// Draw Card
|
|
|
|
// Both players get new hand + deck counts updated
|
|
|
|
// Both players get new hand + deck counts updated
|
|
|
|
socket.on('responseDrawCard', function (data) {
|
|
|
|
socket.on('responseDrawCard', function (data) {
|
|
|
|
@ -39,3 +35,29 @@ socket.on('responsePlayerDrewCard', function (data) {
|
|
|
|
drawGameBoard();
|
|
|
|
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
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|