From: Christian Heller Date: Mon, 14 Dec 2020 20:25:55 +0000 (+0100) Subject: Differentiate thing blocking into blocks_{sound,light,movement}. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Byoutube_prefix%7D%7D%7B%7Bresult.id%7D%7D?a=commitdiff_plain;h=08ec4530a77f65da7bee3fd60a1c8ca6d06b8760;p=plomrogue2 Differentiate thing blocking into blocks_{sound,light,movement}. --- diff --git a/plomrogue/game.py b/plomrogue/game.py index ba7c285..35a6108 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -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_, diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index 8af4bb9..1dec10d 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -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() diff --git a/plomrogue/things.py b/plomrogue/things.py index 0d17d3c..021412a 100644 --- a/plomrogue/things.py +++ b/plomrogue/things.py @@ -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)