-def cmd_THING_NAME(game, thing_id, name, pw, connection_id):
- # TODO check if thing in FOV
- t = game.get_thing(thing_id)
- if not t:
- raise GameError('thing of ID %s not found' % thing_id)
- if not game.can_do_thing_with_pw(t, pw):
- raise GameError('wrong password for tile')
- t.name = name
+def cmd_THING_NAME(game, name, pw, connection_id):
+ player = game.get_player(connection_id)
+ if not player:
+ raise GameError('need to be logged in for this')
+ if not player.carrying:
+ raise GameError('need to carry a thing to rename it')
+ if not game.can_do_thing_with_pw(player.carrying, pw):
+ raise GameError('wrong password for thing')
+ if name == ' ':
+ if hasattr(player.carrying.__class__, 'name'):
+ raise GameError('cannot un-name things of this type')
+ if hasattr(player.carrying, 'name'):
+ del player.carrying.name
+ else:
+ player.carrying.name = name