home · contact · privacy
Differentiate thing blocking into blocks_{sound,light,movement}.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 14 Dec 2020 20:25:55 +0000 (21:25 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 14 Dec 2020 20:25:55 +0000 (21:25 +0100)
plomrogue/game.py
plomrogue/tasks.py
plomrogue/things.py

index ba7c285c83a1c49d32ae0ca96aafaf869f2ca59c..35a610881bed5fea0ce7081d2b6f92bdc2774150 100755 (executable)
@@ -215,7 +215,7 @@ class Game(GameBase):
             t.uncarry()
         self.things.remove(t)
         self.record_change(t.position, 'other')
-        if t.blocking:
+        if t.blocks_light:
             self.record_change(t.position, 'fov')
 
     def add_thing(self, type_, position, id_=0):
@@ -228,7 +228,7 @@ class Game(GameBase):
         else:
             self.things += [t]
         self.record_change(t.position, 'other')
-        if t.blocking:
+        if t.blocks_light:
             self.record_change(t.position, 'fov')
         return t
 
@@ -510,7 +510,7 @@ class Game(GameBase):
                     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:
+                if t.type_ == 'Door' and t.blocks_movement:
                     write(f, 'THING_DOOR_CLOSED %s' % t.id_)
                 elif t.type_ == 'Hat':
                     write(f, 'THING_HAT_DESIGN %s %s' % (t.id_,
index 8af4bb957f683227decdcd2f2066a79a766004e5..1dec10d7e8b1a639474ba8e07d6e371cf1963185 100644 (file)
@@ -36,18 +36,18 @@ class Task_MOVE(Task):
         test_yxyx = self._get_move_target()
         move_blockers = self.thing.game.get_movement_blockers()
         if test_yxyx in [t.position for t in self.thing.game.things
-                         if t.blocking]:
+                         if t.blocks_movement]:
             raise PlayError('blocked by other thing')
         elif self.thing.game.maps[test_yxyx[0]][test_yxyx[1]] in move_blockers:
             raise PlayError('blocked by impassable tile')
 
     def do(self):
         self.thing.game.record_change(self.thing.position, 'other')
-        if self.thing.blocking:
+        if self.thing.blocks_light:
             self.thing.game.record_change(self.thing.position, 'fov')
         self.thing.position = self._get_move_target()
         self.thing.game.record_change(self.thing.position, 'other')
-        if self.thing.blocking:
+        if self.thing.blocks_light:
             self.thing.game.record_change(self.thing.position, 'fov')
         if self.thing.carrying:
             self.thing.carrying.position = self.thing.position
@@ -169,7 +169,7 @@ class Task_DOOR(Task):
                              get_neighbors_yxyx(self.thing.position).values())
         for t in [t for t in self.thing.game.things if
                   t.type_ == 'Door' and t.position in action_radius]:
-            if t.blocking:
+            if t.blocks_movement:
                 t.open()
             else:
                 t.close()
index 0d17d3c029469713ed25305d20433467a847b6d2..021412a1e61bc8f8467c751d40a394bb2245aac6 100644 (file)
@@ -20,7 +20,9 @@ class ThingBase:
 
 
 class Thing(ThingBase):
-    blocking = False
+    blocks_movement = False
+    blocks_sound = False
+    blocks_light = False
     portable = False
     protection = '.'
     commandable = False
@@ -68,9 +70,7 @@ class Thing(ThingBase):
             return lowered_msg
 
         largest_audible_distance = 20
-        # player's don't block sound
-        obstacles = [t.position for t in self.game.things
-                     if t.blocking and t.type_ != 'Player']
+        obstacles = [t.position for t in self.game.things if t.blocks_sound]
         sound_blockers = self.game.get_sound_blockers()
         dijkstra_map = DijkstraMap(sound_blockers, obstacles, self.game.maps,
                                    self.position, largest_audible_distance,
@@ -146,16 +146,20 @@ class Thing_DoorSpawner(ThingSpawner):
 
 class Thing_Door(Thing):
     symbol_hint = 'D'
-    blocking = False
+    blocks_movement = False
     portable = True
     installable = True
 
     def open(self):
-        self.blocking = False
+        self.blocks_movement = False
+        self.blocks_light = False
+        self.blocks_sound = False
         del self.thing_char
 
     def close(self):
-        self.blocking = True
+        self.blocks_movement = True
+        self.blocks_light = True
+        self.blocks_sound = True
         self.thing_char = '#'
 
     def install(self):
@@ -185,7 +189,7 @@ class Thing_Bottle(Thing):
         fov_map_class = self.game.map_geometry.fov_map_class
         fov_radius = 12
         light_blockers = self.game.get_light_blockers()
-        obstacles = [t.position for t in self.game.things if t.blocking]
+        obstacles = [t.position for t in self.game.things if t.blocks_light]
         fov = fov_map_class(light_blockers, obstacles, self.game.maps,
                             self.position, fov_radius, self.game.get_map)
         fov.init_terrain()
@@ -405,7 +409,8 @@ class Thing_CookieSpawner(Thing):
 
 
 class ThingAnimate(Thing):
-    blocking = True
+    blocks_movement = True
+    blocks_light = True
     drunk = 0
 
     def __init__(self, *args, **kwargs):
@@ -466,7 +471,7 @@ class ThingAnimate(Thing):
         fov_map_class = self.game.map_geometry.fov_map_class
         fov_radius = 3 if self.drunk > 0 else 12
         light_blockers = self.game.get_light_blockers()
-        obstacles = [t.position for t in self.game.things if t.blocking]
+        obstacles = [t.position for t in self.game.things if t.blocks_light]
         self._fov = fov_map_class(light_blockers, obstacles, self.game.maps,
                                   self.position, fov_radius, self.game.get_map)