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'
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]))
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)
-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'
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'])
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)
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()