13 hours ago · Tech · 0 comments

Cleaning up Cell fixed a big design issue. Now we are left with a smaller one. We’ll see what we can do about that. While you weren’t watching, I did a bit of work, changing this: class DungeonLayout: def is_available(self, cell) -> bool: return self.xy_is_available(cell.xy) def is_in_a_room(self, cell) -> bool: return self.xy_is_in_a_room(cell.xy) def xy_is_available(self, xy): return not self.xy_is_in_a_room(xy) def xy_is_in_a_room(self, xy): cell = self.at(*xy) return any([cell in room for room in self.rooms]) def get_room(self, cell): for room in self.rooms: if cell in room: return room return None To this: class DungeonLayout: def is_available(self, cell) -> bool: return not self.is_in_a_room(cell) def is_in_a_room(self, cell) -> bool: return self.get_room(cell) is not None def get_room(self, cell) -> Room|None: for room in self.rooms: if cell in room: return room return None I decided that having both the xy form and the Cell form wasn’t helping. Instead, one always had to…

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