home · contact · privacy
Turn Consumable into Bottle that may be full or empty.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 3 Dec 2020 04:39:16 +0000 (05:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 3 Dec 2020 04:39:16 +0000 (05:39 +0100)
plomrogue/commands.py
plomrogue/game.py
plomrogue/tasks.py
plomrogue/things.py
rogue_chat.py

index 0638cb86e7517445511873a678feed95ad89d368..dea4b63d4c4c69e0d42b8abc90a7c345c2945312 100644 (file)
@@ -305,3 +305,12 @@ def cmd_THING_MUSICPLAYER_PLAYLIST_ITEM(game, thing_id, title, length):
         raise GameError('thing of ID %s not music player' % thing_id)
     t.playlist += [(title, length)]
 cmd_THING_MUSICPLAYER_PLAYLIST_ITEM.argtypes = 'int:pos string int:pos'
+
+def cmd_THING_BOTTLE_EMPTY(game, thing_id):
+    t = game.get_thing(thing_id)
+    if not t:
+        raise GameError('thing of ID %s not found' % thing_id)
+    if not t.type_ == 'Bottle':
+        raise GameError('thing of ID %s not bottle' % thing_id)
+    t.full = False
+cmd_THING_BOTTLE_EMPTY.argtypes = 'int:pos'
index ba25ecad37313d12f688cb6758a9b1669b0b445e..453ee30dd84f968b6f3555b09f6d428722bb31c3 100755 (executable)
@@ -354,12 +354,14 @@ class Game(GameBase):
                     write(f, 'GOD_THING_NAME %s %s' % (t.id_, quote(t.name)))
                 if t.type_ == 'Door' and t.blocking:
                     write(f, 'THING_DOOR_CLOSED %s' % t.id_)
-                if t.type_ == 'MusicPlayer':
+                elif t.type_ == 'MusicPlayer':
                     write(f, 'THING_MUSICPLAYER_SETTINGS %s %s %s %s' %
                           (t.id_, int(t.playing), t.playlist_index, int(t.repeat)))
                     for item in t.playlist:
                         write(f, 'THING_MUSICPLAYER_PLAYLIST_ITEM %s %s %s' %
                               (t.id_, quote(item[0]), item[1]))
+                elif t.type_ == 'Bottle' and not t.full:
+                    write(f, 'THING_BOTTLE_EMPTY %s' % t.id_)
             write(f, 'SPAWN_POINT %s %s' % (self.spawn_point[0],
                                             self.spawn_point[1]))
 
index 0bc0d9cf23c30c29e0b675f20ba0c77f0debe59f..eca94003d6c8a5a52e3b6f15d13464f188c17d86 100644 (file)
@@ -128,13 +128,14 @@ class Task_INTOXICATE(Task):
 
     def check(self):
         if self.thing.carrying is None:
-            raise PlayError('nothing to consume')
-        if self.thing.carrying.type_ != 'Consumable':
-            raise PlayError('cannot consume non-consumable')
+            raise PlayError('carrying nothing to drink from')
+        if self.thing.carrying.type_ != 'Bottle':
+            raise PlayError('cannot drink from non-bottle')
+        if not self.thing.carrying.full:
+            raise PlayError('bottle is empty')
 
     def do(self):
-        self.thing.game.things.remove(self.thing.carrying)
-        self.thing.carrying = None
+        self.thing.carrying.full = False
         for c_id in self.thing.game.sessions:
             if self.thing.game.sessions[c_id]['thing_id'] == self.thing.id_:
                 self.thing.game.io.send('RANDOM_COLORS', c_id)
index 15216efe5fdbaa8309a6f5b48bd5e4dc971dce2e..67a3807fc939b88df98716d61392065d2511e496 100644 (file)
@@ -141,14 +141,15 @@ class Thing_Door(Thing):
 
 
 
-class Thing_Consumable(Thing):
+class Thing_Bottle(Thing):
     symbol_hint = 'B'
     portable = True
+    full = True
 
 
 
-class Thing_ConsumableSpawner(ThingSpawner):
-    child_type = 'Consumable'
+class Thing_BottleSpawner(ThingSpawner):
+    child_type = 'Bottle'
 
 
 
index 076fd92ae684d4880a14c656e85a1191afd7fd5a..cb3080d0caa3d315f01f76c80c4d457492c81d11 100755 (executable)
@@ -11,14 +11,15 @@ from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THIN
                                 cmd_GOD_THING_PROTECTION, cmd_THING_PROTECTION,
                                 cmd_SET_MAP_CONTROL_PASSWORD, cmd_SPAWN_POINT,
                                 cmd_THING_MUSICPLAYER_SETTINGS,
-                                cmd_THING_MUSICPLAYER_PLAYLIST_ITEM)
+                                cmd_THING_MUSICPLAYER_PLAYLIST_ITEM,
+                                cmd_THING_BOTTLE_EMPTY)
 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
                              Task_DROP, Task_FLATTEN_SURROUNDINGS, Task_DOOR,
                              Task_INTOXICATE, Task_COMMAND)
 from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
                               Thing_SpawnPoint, Thing_SpawnPointSpawner,
-                              Thing_Door, Thing_DoorSpawner, Thing_Consumable,
-                              Thing_ConsumableSpawner, Thing_MusicPlayer)
+                              Thing_Door, Thing_DoorSpawner, Thing_Bottle,
+                              Thing_BottleSpawner, Thing_MusicPlayer)
 
 from plomrogue.config import config
 game = Game(config['savefile'])
@@ -53,6 +54,7 @@ game.register_command(cmd_BECOME_ADMIN)
 game.register_command(cmd_SPAWN_POINT)
 game.register_command(cmd_THING_MUSICPLAYER_SETTINGS)
 game.register_command(cmd_THING_MUSICPLAYER_PLAYLIST_ITEM)
+game.register_command(cmd_THING_BOTTLE_EMPTY)
 game.register_task(Task_WAIT)
 game.register_task(Task_MOVE)
 game.register_task(Task_WRITE)
@@ -69,8 +71,8 @@ game.register_thing_type(Thing_SpawnPoint)
 game.register_thing_type(Thing_SpawnPointSpawner)
 game.register_thing_type(Thing_Door)
 game.register_thing_type(Thing_DoorSpawner)
-game.register_thing_type(Thing_Consumable)
-game.register_thing_type(Thing_ConsumableSpawner)
+game.register_thing_type(Thing_Bottle)
+game.register_thing_type(Thing_BottleSpawner)
 game.register_thing_type(Thing_MusicPlayer)
 game.read_savefile()
 game.io.start_loop()