]> git.cworth.org Git - empires-server/commitdiff
Return the actual game object from create_game, not just the ID
authorCarl Worth <cworth@cworth.org>
Mon, 1 Jun 2020 01:01:00 +0000 (18:01 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 1 Jun 2020 01:01:00 +0000 (18:01 -0700)
It was confusing for "create_game" to not return the obvious thing,
(the game that it just created). And now that a game has an "id"
property, it's easy enough to use that when needed.

lmno.js

diff --git a/lmno.js b/lmno.js
index 5d7d5687522a214c7c8a82633d74c8930eee45b2..9998c734a2dc63b8f0f0943a928a1d76c73e4102 100644 (file)
--- a/lmno.js
+++ b/lmno.js
@@ -72,7 +72,7 @@ class LMNO {
 
     this.games[id] = game;
 
-    return id;
+    return game;
   }
 }
 
@@ -108,8 +108,8 @@ function lmno_canonize(id) {
 
 app.post('/new/:game_engine', (request, response) =>  {
   const game_engine = request.params.game_engine;
-  const game_id = lmno.create_game(game_engine);
-  response.send(JSON.stringify(game_id));
+  const game = lmno.create_game(game_engine);
+  response.send(JSON.stringify(game.id));
 });
 
 /* Redirect any requests to a game ID at the top-level.