Skip to content

Commit

Permalink
Added some null pointer catchers
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsa committed Jul 5, 2017
1 parent b3efe5c commit e1bc38a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,23 @@ io.sockets.on('connection', (socket) => {

socket.on('forfeit', () => {
let game = getGame(socket.id);
if (game == null) {
return;
}
let player = game.getPlayer(socket.id);
let opponent = game.getOpponent(player);
game.forfeit(player);
handleFinishedGame(game, player, opponent);
});

socket.on('i know the word', (data) => {

// todo add validation if player can really do this!
let game = getGame(socket.id);

if (game == null) {
return;
}
let player = game.getPlayer(socket.id);
// let user = getUserById(player.userId);
let opponent = game.getOpponent(player);
Expand Down

0 comments on commit e1bc38a

Please sign in to comment.