1 day ago · Tech · 0 comments

Added in Post There is a bit of thrashing below, where I think I see a simpler approach and later discover that I’m mistaken. Thrashing happens sometimes. I’ll add more comments below so you’ll have a better sense of what is happening. Hello, loves! The new conditional-entry logic is clearly a hack. Let’s provide a little improvement. Some thrashing. Method object. Satisfactory but not amazing. The hack we’d like to fix is embedded in just one method: class Dungeon: def place_player_at(self, cell): old_cell = self.player_cell self.player_cell = cell move_allowed = all(( item.interact_with_player(self) for item in list(self.contents_at(cell)))) if not move_allowed: self.player_cell = old_cell What a crock! Save where the player is, move the player, run the interactions, and if any object, move the player back where she was. Why?, you ask. Well, I’ll tell you why. The interact_with_player is sent to dungeon contents, which can optionally give themselves to the player with code like…

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