class PokerGame(object): def __init__(self, players): self.players = [Player(player) for player in players] self.pot = 0 self.state = None self.cards = [] self.deck = Deck() self._stages = [self._pre_flop, self._flop, self._turn, self._river] def next_round(self): return PokerRound(self.players, self.pot) def _pre_flop(self): self.state = 'Pre-flop' for player in self.players: player.add_cards(self.deck.draw_cards(2)) return self.next_round() def _flop(self): self.state = 'Flop' self.cards.extend(self.deck.draw_cards(3)) return self.next_round() def _turn(self): self.state = 'Turn' self.cards.extend(self.deck.draw_cards(1)) return self.next_round() def _river(self): self.state = 'River' self.cards.extend(self.deck.draw_cards(1)) return self.next_round() def next(self): while self._stages: yield self._stages.pop(0) raise StopIteration
def __init__(self, players): self.players = [Player(player) for player in players] self.pot = 0 self.state = None self.cards = [] self.deck = Deck() self._stages = [self._pre_flop, self._flop, self._turn, self._river]