home · contact · privacy
Save thing installation status.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 7 Dec 2020 02:10:26 +0000 (03:10 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 7 Dec 2020 02:10:26 +0000 (03:10 +0100)
plomrogue/commands.py
plomrogue/game.py
rogue_chat.py

index 07bfae0e1b905f8141fe281d1c475b44fcd400e0..373d32931beaa587dc3bd8f453e4274c5fdf6f60 100644 (file)
@@ -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'
index fbfec6e6c5981687e4ba24c41930a82ada1c1a7d..647332452fdd3c94ecbf9e6f9fe0a7fea975dc1f 100755 (executable)
@@ -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':
index 37edc7ad2ff43ff78a396116fb2c9785bfd257f4..8aeaf811b762ba4faac35ac049a0f842670ef2bc 100755 (executable)
@@ -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)