home · contact · privacy
Whitelist legal input characters.
[plomrogue2] / plomrogue / commands.py
index 0638cb86e7517445511873a678feed95ad89d368..f2e479e17cc0bfbecac54c8f485f9e1d8ddfcb3f 100644 (file)
@@ -36,6 +36,7 @@ def cmd_SPAWN_POINT(game, big_yx, little_yx):
 cmd_SPAWN_POINT.argtypes = 'yx_tuple yx_tuple:nonneg'
 
 def cmd_LOGIN(game, nick, connection_id):
+    # TODO filter newlines
     for t in [t for t in game.things if t.type_ == 'Player' and t.name == nick]:
         raise GameError('name already in use')
     if game.get_player(connection_id):
@@ -96,7 +97,7 @@ def cmd_THING_PROTECTION(game, thing_id, protection_char, connection_id):
     if not t:
         raise GameError('thing of ID %s not found' % thing_id)
     t.protection = protection_char
-    game.changed = True
+    #game.changed = True
 cmd_THING_PROTECTION.argtypes = 'int:pos char'
 
 def cmd_SET_MAP_CONTROL_PASSWORD(game, tile_class, password, connection_id):
@@ -108,7 +109,7 @@ def cmd_SET_MAP_CONTROL_PASSWORD(game, tile_class, password, connection_id):
     if tile_class == '.':
         raise GameError('tile class "." must remain unprotected')
     game.map_control_passwords[tile_class] = password
-    game.changed = True
+    #game.changed = True
 cmd_SET_MAP_CONTROL_PASSWORD.argtypes = 'char string'
 
 def cmd_NICK(game, nick, connection_id):
@@ -305,3 +306,12 @@ def cmd_THING_MUSICPLAYER_PLAYLIST_ITEM(game, thing_id, title, length):
         raise GameError('thing of ID %s not music player' % thing_id)
     t.playlist += [(title, length)]
 cmd_THING_MUSICPLAYER_PLAYLIST_ITEM.argtypes = 'int:pos string int:pos'
+
+def cmd_THING_BOTTLE_EMPTY(game, thing_id):
+    t = game.get_thing(thing_id)
+    if not t:
+        raise GameError('thing of ID %s not found' % thing_id)
+    if not t.type_ == 'Bottle':
+        raise GameError('thing of ID %s not bottle' % thing_id)
+    t.empty()
+cmd_THING_BOTTLE_EMPTY.argtypes = 'int:pos'