home · contact · privacy
Add psychedelics, move random colouring from drunkenness to tripping.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 15 Dec 2020 00:04:04 +0000 (01:04 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 15 Dec 2020 00:04:04 +0000 (01:04 +0100)
plomrogue/tasks.py
plomrogue/things.py
rogue_chat.py

index ca6d4ab99d0922501e767605334c01160415d1ad..d42aa4deb232de0a17dcaebaa838dc20e10a01c9 100644 (file)
@@ -184,7 +184,7 @@ class Task_INTOXICATE(Task):
     def check(self):
         if self.thing.carrying is None:
             raise PlayError('carrying nothing to consume')
     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:
             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()
         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')
             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)
         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)
index 0dced0da0a612b1c10248c3ba8f9eef52e057a72..072f2513ce9a11a56e86c92828cbfde3cb1f594b 100644 (file)
@@ -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
 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
 class ThingAnimate(Thing):
     blocks_movement = True
     drunk = 0
+    tripping = 0
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
@@ -442,16 +455,6 @@ class ThingAnimate(Thing):
             return task
 
     def proceed(self):
             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
         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
 
         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_:
     def send_msg(self, msg):
         for c_id in self.game.sessions:
             if self.game.sessions[c_id]['thing_id'] == self.id_:
index 680caa9a3c48e035151c2b5c43ced032976adce6..b69356a15fb184d0d17a40b6c58094194e691f54 100755 (executable)
@@ -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_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'])
 
 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_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']:
 game.read_savefile()
 game.io.start_loop()
 for port in config['servers']: