From c88f2e245843fb925a1da1474ffc56aa1c03b36f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 1 Jun 2020 14:24:29 -0700 Subject: [PATCH] Add some documentation about the Game import interface Having some notes here will simplify the task of making a new Game by copying an existing game, (since the game logic itself may obscure some of the details of this interface). --- lmno.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lmno.js b/lmno.js index 6651adf..a22f958 100644 --- a/lmno.js +++ b/lmno.js @@ -46,7 +46,37 @@ nunjucks.configure("templates", { express: app }); -/* Load each of our game mini-apps. */ +/* Load each of our game mini-apps. + * + * Each "engine" we load here must have a property .Game on the + * exports object that should be a class that extends the common base + * class Game. + * + * In turn, each engine's Game must have the following properties: + * + * .meta: An object with .name and .identifier properties. + * + * Here, .name is a string giving a human-readable name + * for the game, such as "Tic Tac Toe" while .identifier + * is the short, single-word, all-lowercase identifier + * that is used in the path of the URL, such as + * "tictactoe". + * + * .router: An express Router object + * + * Any game-specific routes should already be on the + * router. Then, LMNO will add common routes including: + * + * / Serves -game.html template + * + * /events Serves a stream of events. Game can override + * the handle_events method, call super() first, + * and then have code to add custom events. + * + * /moves Receives move data from clients. This route + * is only added if the Game class has an + * add_move method. + */ const engines = { empires: require("./empires"), tictactoe: require("./tictactoe") -- 2.45.2