Oct-05-2019, 07:28 PM
I'm glad you got that working-ish.
There's a problem with responsibilities here. When the fold button is pressed, the row with the player's cards and the button needs to be removed from the presentation. So, the GUI needs to know what to present. However, the player does not need to know what's presented; the player only needs to know that it folded.
This is the Single Responsibility Principle. As Uncle Bob puts it: "A class should have one and only one reason to change." The GUI should change when a change needs to be made to the GUI but the Player should remain unchanged in that case.
If we separate the front-end presentation and the back-end data flow, we can likely clear up the problem.
There's a problem with responsibilities here. When the fold button is pressed, the row with the player's cards and the button needs to be removed from the presentation. So, the GUI needs to know what to present. However, the player does not need to know what's presented; the player only needs to know that it folded.
This is the Single Responsibility Principle. As Uncle Bob puts it: "A class should have one and only one reason to change." The GUI should change when a change needs to be made to the GUI but the Player should remain unchanged in that case.
If we separate the front-end presentation and the back-end data flow, we can likely clear up the problem.
class Player: self.folded = False def fold(self): self.folded = True class Presentation: def player_folds(self, index, player): # index is for removing the correct row of data player.fold() ...hide or forget the presented data...When a new hand is dealt, the Presentation will need new information from the players. I recommend the players contain and manage their information and have a method for providing that to a caller.