home · contact · privacy
Generalize ThingPlayer.nickname to Thing.name.
[plomrogue2] / plomrogue / commands.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)