So far, we just set a name field, then we access this name field from
a game instance in each of the implementations of the route handler
for the root path. In each case this is to provide the name of the
game as context for the rendering of the choose-nickname template.
The reason for all of this is to enable convergence of the code
handling that route, (since as soon as the code is precisely common
between both games the code can move up into the base class).
It's close here, but will also need to be able to select the proper
template in the case where a nickname is already chosen.
}
router.get('/', (request, response) => {
+ const game = request.game;
+
if (! request.session.nickname)
- response.render('choose-nickname.html', { game_name: "Empires" });
+ response.render('choose-nickname.html', { game_name: game.meta.name });
else
response.render('empires-game.html');
});
exports.router = router;
exports.name = engine_name;
exports.Game = Empires;
+
+Empires.meta = {
+ name: "Empires"
+};
+
+exports.meta = Empires.meta;
const game = request.game;
if (! request.session.nickname)
- response.render('choose-nickname.html', { game_name: "Tic Tac Toe" });
+ response.render('choose-nickname.html', { game_name: game.meta.name });
else
response.render('tictactoe-game.html');
});
exports.router = router;
exports.name = engine_name;
exports.Game = TicTacToe;
+
+TicTacToe.meta = {
+ name: "Tic Tac Toe"
+};
+
+exports.meta = TicTacToe.meta;