1 day ago · Tech · 0 comments

Should we start to address the Horrendous Mess™, or do something else? Something else: work toward removing room knowledge from Cell. The only thing left in Cell that is of any concern is its room instance variable. All the rest is __repr__ and coordinate stuff. So that could be worth going after. We want the cell not to know about its containers, because, well, mostly because we have come to think it’s ugly, and its mother dresses it funny. The real information about rooms is already in DungeonLayout: class DungeonLayout: deltas = [(-1, 0), (1, 0), (0, -1), (0, 1)] def __init__(self, max_x=10, max_y=10): self.cells = dict() for x in range(max_x): for y in range(max_y): self.cells[(x,y)] = Cell(x, y) self.rooms = [] In Cell, we have these references to the Cell.room variable: class Cell: @property def room(self): return self._room @room.setter def room(self, room): self._room = room @property def is_available(self) -> bool: return self.room is None @property def is_in_a_room(self):…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.