From 63492ece678da23ef0e9652b86313e6c824376af Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 1 Jun 2020 07:51:59 -0700 Subject: [PATCH] Give the "/events" route a common implementation 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 | 5 ----- lmno.js | 6 ++++++ tictactoe.js | 6 ------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/empires.js b/empires.js index 8d57543..8007f93 100644 --- a/empires.js +++ b/empires.js @@ -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 9998c73..5e67350 100644 --- 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); } diff --git a/tictactoe.js b/tictactoe.js index 9140b89..89ad5d2 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -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; -- 2.43.0