From: Christian Heller Date: Mon, 7 Dec 2020 02:10:26 +0000 (+0100) Subject: Save thing installation status. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/copy_free?a=commitdiff_plain;h=875642f0ff9420b94f6399b05bb849b12118f6e2;p=plomrogue2 Save thing installation status. --- diff --git a/plomrogue/commands.py b/plomrogue/commands.py index 07bfae0..373d329 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -304,3 +304,12 @@ def cmd_THING_BOTTLE_EMPTY(game, thing_id): raise GameError('thing of ID %s not bottle' % thing_id) t.empty() cmd_THING_BOTTLE_EMPTY.argtypes = 'int:pos' + +def cmd_THING_INSTALLED(game, thing_id): + t = game.get_thing(thing_id) + if not t: + raise GameError('thing of ID %s not found' % thing_id) + if not hasattr(t, 'installable'): + raise GameError('thing of ID %s not installable' % thing_id) + t.install() +cmd_THING_INSTALLED.argtypes = 'int:pos' diff --git a/plomrogue/game.py b/plomrogue/game.py index fbfec6e..6473324 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -375,6 +375,8 @@ class Game(GameBase): write(f, 'GOD_THING_PROTECTION %s %s' % (t.id_, quote(t.protection))) if hasattr(t, 'name'): write(f, 'GOD_THING_NAME %s %s' % (t.id_, quote(t.name))) + if hasattr(t, 'installable') and (not t.portable): + write(f, 'THING_INSTALLED %s' % t.id_) if t.type_ == 'Door' and t.blocking: write(f, 'THING_DOOR_CLOSED %s' % t.id_) elif t.type_ == 'MusicPlayer': diff --git a/rogue_chat.py b/rogue_chat.py index 37edc7a..8aeaf81 100755 --- a/rogue_chat.py +++ b/rogue_chat.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from plomrogue.game import Game from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THING, - cmd_MAP, cmd_TURN, cmd_MAP_LINE, + cmd_MAP, cmd_TURN, cmd_MAP_LINE, cmd_THING_INSTALLED, cmd_ANNOTATE, cmd_PORTAL, cmd_GET_GAMESTATE, cmd_TASKS, cmd_MAP_CONTROL_LINE, cmd_MAP_CONTROL_PW, cmd_GOD_ANNOTATE, cmd_GOD_PORTAL, cmd_THING_TYPES, @@ -46,6 +46,7 @@ game.register_command(cmd_THING_PROTECTION) game.register_command(cmd_GOD_THING_PROTECTION) game.register_command(cmd_THING_NAME) game.register_command(cmd_THING_DOOR_CLOSED) +game.register_command(cmd_THING_INSTALLED) game.register_command(cmd_GOD_THING_NAME) game.register_command(cmd_ADMIN_PASSWORD) game.register_command(cmd_SET_TILE_CONTROL)