home · contact · privacy
Generalize ThingPlayer.nickname to Thing.name.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 14 Nov 2020 00:57:47 +0000 (01:57 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 14 Nov 2020 00:57:47 +0000 (01:57 +0100)
plomrogue/commands.py
plomrogue/game.py
plomrogue/things.py

index 229285fb8c7f291ff02458367b11e40f89cdb6a9..3b2464b42baa6d7c429832ea34138c970d00570d 100644 (file)
@@ -67,7 +67,7 @@ def cmd_ALL(game, msg, connection_id):
         listener_vol = dijkstra_map[game.map.get_position_index(listener.position)]
         volume = 1 / max(1, listener_vol)
         lowered_msg = lower_msg_by_volume(msg, volume)
-        lowered_nick = lower_msg_by_volume(speaker.nickname, volume)
+        lowered_nick = lower_msg_by_volume(speaker.name, volume)
         game.io.send('CHAT ' +
                      quote('(volume: %.2f) %s: %s' % (volume, lowered_nick,
                                                       lowered_msg)),
@@ -75,7 +75,7 @@ def cmd_ALL(game, msg, connection_id):
 cmd_ALL.argtypes = 'string'
 
 def cmd_LOGIN(game, nick, connection_id):
-    for t in [t for t in game.things if t.type_ == 'Player' and t.nickname == nick]:
+    for t in [t for t in game.things if t.type_ == 'Player' and t.name == nick]:
         raise GameError('name already in use')
     if connection_id in game.sessions:
         raise GameError('cannot log in twice')
@@ -85,21 +85,21 @@ def cmd_LOGIN(game, nick, connection_id):
     t.player_char = game.get_next_player_char()
     game.sessions[connection_id] = t.id_
     game.io.send('LOGIN_OK', connection_id)
-    t.nickname = nick
-    game.io.send('CHAT ' + quote(t.nickname + ' entered the map.'))
+    t.name = nick
+    game.io.send('CHAT ' + quote(t.name + ' entered the map.'))
     game.io.send('PLAYER_ID %s' % t.id_, connection_id)
     game.changed = True
 cmd_LOGIN.argtypes = 'string'
 
 def cmd_NICK(game, nick, connection_id):
-    for t in [t for t in game.things if t.type_ == 'Player' and t.nickname == nick]:
+    for t in [t for t in game.things if t.type_ == 'Player' and t.name == nick]:
         raise GameError('name already in use')
     if not connection_id in game.sessions:
         raise GameError('can only rename when already logged in')
     t_id = game.sessions[connection_id]
     t = game.get_thing(t_id)
-    old_nick = t.nickname
-    t.nickname = nick
+    old_nick = t.name
+    t.name = nick
     game.io.send('CHAT ' + quote(old_nick + ' renamed themselves to ' + nick))
     game.changed = True
 cmd_NICK.argtypes = 'string'
@@ -112,8 +112,8 @@ cmd_GET_GAMESTATE.argtypes = ''
 #    if not connection_id in game.sessions:
 #        raise GameError('can only query when logged in')
 #    t = game.get_thing(game.sessions[connection_id], False)
-#    source_nick = t.nickname
-#    for t in [t for t in game.things if t.type_ == 'Player' and t.nickname == target_nick]:
+#    source_nick = t.name
+#    for t in [t for t in game.things if t.type_ == 'Player' and t.name == target_nick]:
 #        for c_id in game.sessions:
 #            if game.sessions[c_id] == t.id_:
 #                game.io.send('CHAT ' + quote(source_nick+ '->' + target_nick + ': ' + msg), c_id)
index 29e2de15fe605f92f11cebc967815927ea9b7fd8..483dd346e2a837a1c61f65fa265f1f3b592faabb 100755 (executable)
@@ -109,9 +109,8 @@ class Game(GameBase):
             for t in [t for t in self.things
                       if player.fov_stencil[t.position] == '.']:
                 self.io.send('THING %s %s %s' % (t.position, t.type_, t.id_), c_id)
-                if hasattr(t, 'nickname'):
-                    self.io.send('THING_NAME %s %s' % (t.id_,
-                                                       quote(t.nickname)), c_id)
+                if hasattr(t, 'name'):
+                    self.io.send('THING_NAME %s %s' % (t.id_, quote(t.name)), c_id)
                 if hasattr(t, 'player_char'):
                     self.io.send('THING_CHAR %s %s' % (t.id_,
                                                        quote(t.player_char)), c_id)
@@ -130,8 +129,8 @@ class Game(GameBase):
                     break
             if not connection_id_found:
                 t = self.get_thing(self.sessions[connection_id])
-                if hasattr(t, 'nickname'):
-                    self.io.send('CHAT ' + quote(t.nickname + ' left the map.'))
+                if hasattr(t, 'name'):
+                    self.io.send('CHAT ' + quote(t.name + ' left the map.'))
                 self.things.remove(t)
                 to_delete += [connection_id]
         for connection_id in to_delete:
index b6fe5e15e5e919483962b87f63fdfa4a99a380e5..98a5995cf5d46824d5f9fee9ebb2ff1a50cc1510 100644 (file)
@@ -107,5 +107,4 @@ class Thing_Player(ThingAnimate):
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
-        self.nickname = 'undefined'
         self.carrying = None