From: Christian Heller Date: Tue, 15 Dec 2020 00:04:04 +0000 (+0100) Subject: Add psychedelics, move random colouring from drunkenness to tripping. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/gitweb.js?a=commitdiff_plain;h=9f83e41901f23e282737e7344c84e8a692d05ef0;p=plomrogue2 Add psychedelics, move random colouring from drunkenness to tripping. --- diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index ca6d4ab..d42aa4d 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -184,7 +184,7 @@ class Task_INTOXICATE(Task): def check(self): if self.thing.carrying is None: raise PlayError('carrying nothing to consume') - if self.thing.carrying.type_ not in {'Bottle', 'Cookie'}: + if self.thing.carrying.type_ not in {'Bottle', 'Cookie', 'Psychedelic'}: raise PlayError('cannot consume this kind of thing') if self.thing.carrying.type_ == 'Bottle' and\ not self.thing.carrying.full: @@ -194,11 +194,16 @@ class Task_INTOXICATE(Task): if self.thing.carrying.type_ == 'Bottle': self.thing.carrying.full = False self.thing.carrying.empty() - self.thing.send_msg('RANDOM_COLORS') self.thing.send_msg('CHAT "You are drunk now."') self.thing.drunk = 10000 self.thing.invalidate('fov') self.thing.game.record_change(self.thing.position, 'other') + elif self.thing.carrying.type_ == 'Psychedelic': + self.thing.tripping = 10000 + self.thing.send_msg('CHAT "You start tripping."') + self.thing.send_msg('RANDOM_COLORS') + eaten = self.thing.uncarry() + self.thing.game.remove_thing(eaten) elif self.thing.carrying.type_ == 'Cookie': self.thing.send_msg('CHAT ' + quote('You eat a cookie and gain the ability to draw the following character: "%s"' % self.thing.carrying.thing_char)) self.thing.add_cookie_char(self.thing.carrying.thing_char) diff --git a/plomrogue/things.py b/plomrogue/things.py index 0dced0d..072f251 100644 --- a/plomrogue/things.py +++ b/plomrogue/things.py @@ -170,6 +170,18 @@ class Thing_Door(Thing): +class Thing_Psychedelic(Thing): + symbol_hint = 'P' + portable = True + + + +class Thing_PsychedelicSpawner(ThingSpawner): + symbol_hint = 'P' + child_type = 'Psychedelic' + + + class Thing_Bottle(Thing): symbol_hint = 'B' portable = True @@ -411,6 +423,7 @@ class Thing_CookieSpawner(Thing): class ThingAnimate(Thing): blocks_movement = True drunk = 0 + tripping = 0 def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -442,16 +455,6 @@ class ThingAnimate(Thing): return task def proceed(self): - self.drunk -= 1 - if self.drunk == 0: - for c_id in self.game.sessions: - if self.game.sessions[c_id]['thing_id'] == self.id_: - # TODO: refactor with self.send_msg - self.game.io.send('DEFAULT_COLORS', c_id) - self.game.io.send('CHAT "You sober up."', c_id) - self.invalidate('fov') - break - self.game.changed = True if self.task is None: self.task = self.get_next_task() return @@ -563,6 +566,22 @@ class Thing_Player(ThingAnimate): super().__init__(*args, **kwargs) self.carrying = None + def proceed(self): + super().proceed() + self.drunk -= 1 + if self.drunk == 0: + self.send_msg('CHAT "You sober up."') + self.invalidate('fov') + self.game.changed = True + self.tripping -= 1 + if self.tripping == 0: + self.send_msg('DEFAULT_COLORS') + self.send_msg('CHAT "You sober up."') + self.game.changed = True + elif self.tripping > 0 and self.tripping % 250 == 0: + self.send_msg('RANDOM_COLORS') + self.game.changed = True + def send_msg(self, msg): for c_id in self.game.sessions: if self.game.sessions[c_id]['thing_id'] == self.id_: diff --git a/rogue_chat.py b/rogue_chat.py index 680caa9..b69356a 100755 --- a/rogue_chat.py +++ b/rogue_chat.py @@ -24,7 +24,8 @@ from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner, Thing_Door, Thing_DoorSpawner, Thing_Bottle, Thing_BottleSpawner, Thing_BottleDeposit, Thing_MusicPlayer, Thing_Hat, Thing_HatRemixer, - Thing_Cookie, Thing_CookieSpawner) + Thing_Cookie, Thing_CookieSpawner, Thing_Psychedelic, + Thing_PsychedelicSpawner) from plomrogue.config import config game = Game(config['savefile']) @@ -94,6 +95,8 @@ game.register_thing_type(Thing_Hat) game.register_thing_type(Thing_HatRemixer) game.register_thing_type(Thing_Cookie) game.register_thing_type(Thing_CookieSpawner) +game.register_thing_type(Thing_Psychedelic) +game.register_thing_type(Thing_PsychedelicSpawner) game.read_savefile() game.io.start_loop() for port in config['servers']: