Confirm player death, fix join bug

This commit is contained in:
Alec Maier
2020-04-18 17:09:46 -04:00
parent 3d953b990b
commit 0a583c01cb
4 changed files with 11 additions and 6 deletions

View File

@@ -109,7 +109,7 @@ io.on('connection', function(socket) {
});
socket.on('joinGame', function(playerInfo) {
const game = activeGames[Object.keys(activeGames).find((key) => key === playerInfo.code)];
if (game && game.players.length < game.size) {
if (game && game.players.length < game.size && !game.players.find((player) => player.id === playerInfo.id)) {
game.players.push({name: playerInfo.name, id: playerInfo.id});
console.log(playerInfo.name + " joined the game!");
socket.emit('success');