From: Carl Worth Date: Mon, 1 Jun 2020 21:24:29 +0000 (-0700) Subject: Add some documentation about the Game import interface X-Git-Url: https://git.cworth.org/git?p=empires-server;a=commitdiff_plain;h=c88f2e245843fb925a1da1474ffc56aa1c03b36f 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). --- 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")