2 days ago · Tech · 0 comments

I have a bit of time at the keyboard. Let’s improve the dungeon contents code a bit. Let’s allow for more than one content item. We can do that with a test, I think. def test_contents_is_collection(self): layout = DungeonLayout(10, 10) room_cell = layout.at(5, 5) room = Room([room_cell]) layout.add_room(room) dungeon = Dungeon(layout) dungeon.place_content_at(room_cell,"treasure") dungeon.place_content_at(room_cell,"more treasure") contents = dungeon.contents_at(room_cell.xy) assert len(contents) == 2 I don’t like that I need this much setup for the test. We’ll think of something to do about that. First make it work. I think this will break DungeonView, and that reminds me that our original test doesn’t test very much: def test_place_content(self): layout = DungeonLayout(10, 10) room_cell = layout.at(5, 5) room = Room([room_cell]) layout.add_room(room) dungeon = Dungeon(layout) dungeon.place_content_at(room_cell,"treasure") I think we’ll probably just let that one get removed, the…

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