21 hours ago · Tech · 0 comments

Having chosen Strategy over Mixin, we’ll get down to doing it for real. I’d like to have some way to test what we do here. As things stand, I don’t see a useful approach. Maybe one will come to mind. I think the thing will be to build a new content class, fully configurable, to replace all the old ones. I’ll do that in a test file even if we don’t have any decent tests, and maybe we can test the maim operations. We’ll see what happens. To begin with: I’ve made four or five attempts at this and none of them feel right. I’ll spare you the pastes that didn’t work I’ll begin again, with a ContentItem that, when we’re done, will have all the methods needed, draw, placed. interact_with_player. Then I’ll make it work. class TestContent: def test_initial_placed(self): dungeon = None content = ContentItem() result = content.placed(dungeon) assert result == 'ignored' class ContentItem: def __init__(self): self.placement_strategy = IgnorePlacedStrategy() def placed(self, dungeon): return…

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