]> git.cworth.org Git - empires-server/commitdiff
empires: Rename add_player to register_player
authorCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 12:54:35 +0000 (05:54 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 12:54:35 +0000 (05:54 -0700)
We still haven't yet ported the Empires implementation to play nicely
with all of the new functionality in the base Game class. In
particular, Game now has a base "add_player" method with different
semantics than the older "add_player" method in Empires.

To avoid Empires.add_player from being inadvertently called, we rename
it here to register_player.

This fixes, for the moment, a failure when trying to create a new
Empires game of:

    TypeError: player.remove_connection is not a function

empires.js

index 5b9df829e252e9ef42b9ee4d8338007fb1463bc3..839f5f8be8dc56460b4c6165d4378d99de56f095 100644 (file)
@@ -65,7 +65,7 @@ class Empires extends Game {
     this.broadcast_event("spectator-leave", `{"id": ${id}}`);
   }
 
-  add_player(name, character) {
+  register_player(name, character) {
     const new_player = {id: this.next_player_id,
                        name: name,
                        character: character,
@@ -278,7 +278,7 @@ router.post('/register', (request, response) => {
   if (request.body.name)
     name = request.body.name;
 
-  const player = game.add_player(name, request.body.character);
+  const player = game.register_player(name, request.body.character);
   response.send(JSON.stringify(player.id));
 });