]> git.cworth.org Git - empires-server/commitdiff
Give the "/events" route a common implementation
authorCarl Worth <cworth@cworth.org>
Mon, 1 Jun 2020 14:51:59 +0000 (07:51 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 1 Jun 2020 14:51:59 +0000 (07:51 -0700)
At this point, both the empires and the tictactoe implementation have
an identical implementation of the "/events" route so we push this up
to the lmno.js file.

empires.js
lmno.js
tictactoe.js

index 8d57543817e659a515922134915c8bd65d877677..8007f932a41c4e6b599cf85d0e4fe6105f2b64ee 100644 (file)
@@ -339,11 +339,6 @@ router.get('/players', (request, response) => {
   response.send(game.players);
 });
 
-router.get('/events', (request, response) => {
-  const game = request.game;
-  game.handle_events(request, response);
-});
-
 exports.router = router;
 exports.Game = Empires;
 
diff --git a/lmno.js b/lmno.js
index 9998c734a2dc63b8f0f0943a928a1d76c73e4102..5e67350992497abacf41247720d0b304fc8cab8e 100644 (file)
--- a/lmno.js
+++ b/lmno.js
@@ -258,6 +258,12 @@ for (let key in engines) {
       response.render(`${game.meta.identifier}-game.html`);
   });
 
+  engine.router.get('/events', (request, response) => {
+    const game = request.game;
+
+    game.handle_events(request, response);
+  });
+
   /* And mount the whole router at the path for the game. */
   app.use(`/${engine.Game.meta.identifier}/[a-zA-Z0-9]{4}/`, engine.router);
 }
index 9140b89da9bad2d2b69e2aca9e3f53ff1c2372f9..89ad5d2b4685224ed4766447cea4eef9f4c437bb 100644 (file)
@@ -51,12 +51,6 @@ router.post('/move', (request, response) => {
   game.broadcast_move(square);
 });
 
-router.get('/events', (request, response) => {
-  const game = request.game;
-
-  game.handle_events(request, response);
-});
-
 exports.router = router;
 exports.Game = TicTacToe;