home · contact · privacy
Add door keys and door locking.
[plomrogue2] / plomrogue / commands.py
index 653fc74ff7ecb3c0d4d44f2570f3fe03df7c30ea..074cc343873a80b17e6383b604c7e109217210c6 100644 (file)
@@ -277,14 +277,16 @@ def cmd_GOD_THING_PROTECTION(game, thing_id, protection_char):
     t.protection = protection_char
 cmd_GOD_THING_PROTECTION.argtypes = 'int:pos char'
 
-def cmd_THING_DOOR_CLOSED(game, thing_id):
+def cmd_THING_DOOR_CLOSED(game, thing_id, locked):
     t = game.get_thing(thing_id)
     if not t:
         raise GameError('thing of ID %s not found' % thing_id)
     if not t.type_ == 'Door':
         raise GameError('thing of ID %s not door' % thing_id)
     t.close()
-cmd_THING_DOOR_CLOSED.argtypes = 'int:pos'
+    if locked:
+        t.lock()
+cmd_THING_DOOR_CLOSED.argtypes = 'int:pos bool'
 
 def cmd_THING_MUSICPLAYER_SETTINGS(game, thing_id, playing, index, repeat):
     t = game.get_thing(thing_id)
@@ -380,3 +382,17 @@ def cmd_THING_HAT_DESIGN(game, thing_id, design):
         raise GameError('thing of ID %s not a hat' % thing_id)
     t.design = design
 cmd_THING_HAT_DESIGN.argtypes = 'int:pos string'
+
+def cmd_THING_DOOR_KEY(game, key_id, door_id):
+    key = game.get_thing(key_id)
+    if not key:
+        raise GameError('thing of ID %s not found' % key_id)
+    if key.type_ != 'DoorKey':
+        raise GameError('thing of ID %s not a door key' % key_id)
+    door = game.get_thing(door_id)
+    if not door:
+        raise GameError('thing of ID %s not found' % door_id)
+    if door.type_ != 'Door':
+        raise GameError('thing of ID %s not a door' % key_id)
+    key.door = door
+cmd_THING_DOOR_KEY.argtypes = 'int:pos int:pos'