]> git.cworth.org Git - empires-server/blobdiff - tictactoe.js
Generalize the handling of the /move request
[empires-server] / tictactoe.js
index 15216952b3577ceb7cdee0dc4b20c924b67181f3..2a8dd06f9d580398e483e7a554883beee54bcc4e 100644 (file)
@@ -29,28 +29,8 @@ class TicTacToe extends Game {
 
     return true;
   }
-
-  broadcast_move(move) {
-    this.broadcast_event("move", move);
-  }
 }
 
-router.post('/move', (request, response) => {
-  const game = request.game;
-  const move = request.body.move;
-
-  const legal = game.add_move(move);
-
-  /* Inform this client whether the move was legal. */
-  response.send(JSON.stringify(legal));
-
-  /* And only if legal, inform all clients. */
-  if (! legal)
-    return;
-
-  game.broadcast_move(move);
-});
-
 exports.router = router;
 exports.Game = TicTacToe;