X-Git-Url: https://plomlompom.com/repos/condition_titles?a=blobdiff_plain;f=plomrogue%2Fcommands.py;h=3a10a4c24e182aa6b72dd6a41ac575bcb2664d0e;hb=e6a3ab3471ae5a2be10bd64d694eef462d7f7cf6;hp=a2f98ed1bf989d3195096cf84456815e7da8fc0d;hpb=866ac7e6f0714ef7a0d97cd85d03dcee1e38f50f;p=plomrogue2 diff --git a/plomrogue/commands.py b/plomrogue/commands.py index a2f98ed..3a10a4c 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -118,6 +118,19 @@ def cmd_SET_TILE_CONTROL(game, yx, control_char, connection_id): game.changed = True cmd_SET_TILE_CONTROL.argtypes = 'yx_tuple:nonneg char' +def cmd_THING_PROTECTION(game, thing_id, protection_char, connection_id): + player = game.get_player(connection_id) + if not player: + raise GameError('need to be logged in for this') + if not game.sessions[connection_id]['status'] == 'admin': + raise GameError('need to be admin for this') + t = game.get_thing(thing_id) + if not t: + raise GameError('thing of ID %s not found' % thing_id) + t.protection = protection_char + game.changed = True +cmd_THING_PROTECTION.argtypes = 'int:pos char' + def cmd_SET_MAP_CONTROL_PASSWORD(game, tile_class, password, connection_id): player = game.get_player(connection_id) if not player: @@ -269,13 +282,16 @@ def cmd_THING(game, big_yx, little_yx, thing_type, thing_id): game.changed = True cmd_THING.argtypes = 'yx_tuple yx_tuple:nonneg string:thing_type int:nonneg' -def cmd_THING_NAME(game, thing_id, name, connection_id): +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 game.changed = True -cmd_THING_NAME.argtypes = 'int:pos string' +cmd_THING_NAME.argtypes = 'int:pos string string' def cmd_GOD_THING_NAME(game, thing_id, name): t = game.get_thing(thing_id) @@ -283,3 +299,10 @@ def cmd_GOD_THING_NAME(game, thing_id, name): raise GameError('thing of ID %s not found' % thing_id) t.name = name cmd_GOD_THING_NAME.argtypes = 'int:pos string' + +def cmd_GOD_THING_PROTECTION(game, thing_id, protection_char): + t = game.get_thing(thing_id) + if not t: + raise GameError('thing of ID %s not found' % thing_id) + t.protection = protection_char +cmd_GOD_THING_PROTECTION.argtypes = 'int:pos char'