From: Carl Worth Date: Mon, 1 Jun 2020 14:51:59 +0000 (-0700) Subject: Give the "/events" route a common implementation X-Git-Url: https://git.cworth.org/git?p=empires-server;a=commitdiff_plain;h=63492ece678da23ef0e9652b86313e6c824376af 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. --- 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;