Upon Reflection 0 ▲ ronjeffries.com 68 days ago · Tech · hide · Fediverse post Hello, loves! I think PassageCollection should have the protection against duplication built in. We have a lambda, how nice. As things stand, the user of the PassageCollection is responsible for ensuring that there’s only one passage per room. Since that’s the default behavior we want, let’s build it into the object. Let’s have add_passage return True if the passage was added, and False if it was not. Creating a passage to add is costly, so let’s see if we can pass in a lambda that is only called if needed. Let’s enhance our test. def test_create_passage(self): layout = DungeonLayout(10, 10) room_1 = Room([Cell(0,0), Cell(0,1), Cell(0,2)]) room_2 = Room([Cell(1,0), Cell(1,1), Cell(1,2)]) layout.add_room(room_1) layout.add_room(room_2) passages = PassageCollection() cells = lambda: (Cell(0,0), Cell(1,0)) done = passages.create_passage(room_1, room_2, cells) assert done == True assert len(passages.cell_connections) == 2 assert len(passages.room_connections) == 2 cells = lambda:… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town