]> git.cworth.org Git - empires-server/commitdiff
empires: Add a response of the player ID from /register
authorCarl Worth <cworth@cworth.org>
Sun, 31 May 2020 22:59:44 +0000 (15:59 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 31 May 2020 22:59:44 +0000 (15:59 -0700)
This tracks the change in Empires API version 0.8.

empires.js

index f95bba9f48da600bb68ae46aec66e436ff4fed6b..38d892bde64620d7e4a6e4c0ff186f79813c222d 100644 (file)
@@ -85,6 +85,8 @@ class Empires extends Game {
       want. */
     const player_data = JSON.stringify((({id, name}) => ({id, name}))(new_player));
     this.broadcast_event("player-join", player_data);
+
+    return new_player;
   }
 
   remove_player(id) {
@@ -280,8 +282,8 @@ router.post('/register', (request, response) => {
   if (request.body.name)
     name = request.body.name;
 
-  game.add_player(name, request.body.character);
-  response.send();
+  const player = game.add_player(name, request.body.character);
+  response.send(JSON.stringify(player.id));
 });
 
 router.post('/deregister/:id', (request, response) => {