X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;ds=sidebyside;f=plomrogue%2Fcommands.py;h=8422161b26c6b95bc372c51614acef6a3fc124e6;hb=69849fbd3ecdf9f937d1353a8ffbd96bfb44b742;hp=c86aebe402ad5c1c6d5fadc776ad6e429d5092ed;hpb=509d9ca8e54529b5d728b1635df4ba4bbb0bcc23;p=plomrogue2 diff --git a/plomrogue/commands.py b/plomrogue/commands.py index c86aebe..8422161 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -383,6 +383,37 @@ def cmd_THING_HAT_DESIGN(game, thing_id, design): t.design = design cmd_THING_HAT_DESIGN.argtypes = 'int:pos string' +def cmd_THING_DESIGN(game, design, 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 re-draw it') + if not game.can_do_thing_with_pw(player.carrying, pw): + raise GameError('wrong password for thing') + if not hasattr(player.carrying, 'design'): + raise GameError('carried thing not designable') + size = player.carrying.design_size + if len(design) != size.y * size.x: + raise GameError('design for carried thing of wrong length') + player.carrying.design = design + game.changed = True + game.record_change(player.carrying.position, 'other') +cmd_THING_DESIGN.argtypes = 'string string' + +def cmd_GOD_THING_DESIGN(game, thing_id, design): + t = game.get_thing(thing_id) + if not t: + raise GameError('thing of ID %s not found' % thing_id) + if not hasattr(t, 'design'): + raise GameError('thing of ID %s not designable' % thing_id) + if len(design) != t.design_size.y * t.design_size.x: + raise GameError('design for thing of ID %s of wrong length' % thing_id) + t.design = design +cmd_GOD_THING_DESIGN.argtypes = 'int:pos string' + +# TODO: refactor similar god and player commands + def cmd_THING_DOOR_KEY(game, key_id, door_id): key = game.get_thing(key_id) if not key: @@ -410,3 +441,21 @@ def cmd_THING_CRATE_ITEM(game, crate_id, item_id): raise GameError('thing of ID %s is a crate' % item_id) crate.accept(item) cmd_THING_CRATE_ITEM.argtypes = 'int:pos int:pos' + +def cmd_MAP_CONTROL_PRESETS(game, draw_control_presets): + game.draw_control_presets = draw_control_presets +cmd_MAP_CONTROL_PRESETS.argtypes = 'bool' + +def cmd_THING_SPAWNPOINT_CREATED(game, spawnpoint_id, timestamp): + import datetime + spawnpoint = game.get_thing(spawnpoint_id) + if not spawnpoint: + raise GameError('thing of ID %s not found' % spawnpoint_id) + if spawnpoint.type_ != 'SpawnPoint': + raise GameError('thing of ID %s not a SpawnPoint' % spawnpoint_id) + if timestamp == 0: + spawnpoint.temporary = False + else: + spawnpoint.temporary = True + spawnpoint.created_at = datetime.datetime.fromtimestamp(timestamp) +cmd_THING_SPAWNPOINT_CREATED.argtypes = 'int:pos int:nonneg'