X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=plomrogue%2Fcommands.py;h=c86aebe402ad5c1c6d5fadc776ad6e429d5092ed;hb=cfb8df3d49ecb0bbdf55de23d31a2a33a7c20edc;hp=653fc74ff7ecb3c0d4d44f2570f3fe03df7c30ea;hpb=44ebe11030d1f2c6faf5cf57b83e950318893500;p=plomrogue2 diff --git a/plomrogue/commands.py b/plomrogue/commands.py index 653fc74..c86aebe 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -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,31 @@ 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' + +def cmd_THING_CRATE_ITEM(game, crate_id, item_id): + crate = game.get_thing(crate_id) + if not crate: + raise GameError('thing of ID %s not found' % crate_id) + if crate.type_ != 'Crate': + raise GameError('thing of ID %s not a crate' % crate_id) + item = game.get_thing(item_id) + if not item: + raise GameError('thing of ID %s not found' % item_id) + if item.type_ == 'Crate': + raise GameError('thing of ID %s is a crate' % item_id) + crate.accept(item) +cmd_THING_CRATE_ITEM.argtypes = 'int:pos int:pos'