const game = request.game;
const move = request.body.move;
- const legal = game.add_move(move);
+ const result = game.add_move(move);
- /* Inform this client whether the move was legal. */
- response.send(JSON.stringify(legal));
+ /* Feed move response back to the client. */
+ response.json(result);
/* And only if legal, inform all clients. */
- if (! legal)
+ if (! result.legal)
return;
game.broadcast_move(move);