예제 #1
0
 def test_clearbrokeplayers(self):
     s = factory.session_factory(seats=6, game='FIVE CARD DRAW', level=1)
     p = s.table.seats[0]
     p.stack = 0
     expected = []
     s.clear_broke_players()
     result = s.table.get_broke_players()
     self.assertEqual(expected, result)
예제 #2
0
    def setUp_studGame(self, lvl=1, players=6, street=1):
        """ Setup a 5 card stud game for testing. """
        g = factory.session_factory(seats=players, game="FIVE CARD STUD", level=lvl)
        self.r = g.new_round()

        for _ in range(street - 1):  # Adjust which street to test.
            self.r.next_street()

        tools.deal_5stud_test_hands(self.r.table)
        self.r.post_antes()
        self.r.table.set_bringin()
        self.br = betting.BettingRound(self.r)
예제 #3
0
    def setUp_shorty(self, shortstack, lvl=1, players=6, street=1):
        """ Sets up a table of short stack players """
        g = factory.session_factory(seats=players, game="FIVE CARD DRAW", level=lvl)
        # Sets seat 1(we'll use as the SB) as the short stack amount for easy testing.
        g.table.seats[1].stack = shortstack
        g.table.move_button()
        g.table.set_blinds()
        self.assertEqual(g.table.TOKENS['D'], 0)  # verify the button is 0
        self.r = g.new_round()

        for _ in range(street - 1):  # Adjust which street to test.
            self.r.next_street()
        self.r.post_blinds()
        self.r.deal_cards(2)
        self.br = betting.BettingRound(self.r)
예제 #4
0
    def setUp(self, lvl=1, players=6, street=1):
        """ Setup a session and round, with a table filled with 6 players.
            Default level is $2/$4.
        """
        g = factory.session_factory(seats=players, game="FIVE CARD DRAW", level=lvl)

        g.table.move_button()
        g.table.set_blinds()
        self.assertEqual(g.table.TOKENS['D'], 0)  # verify the button is 0
        self.r = g.new_round()

        for _ in range(street - 1):  # Adjust which street to test.
            self.r.next_street()

        self.r.post_blinds()
        self.r.deal_cards(5)
        self.br = betting.BettingRound(self.r)
예제 #5
0
def play_poker():
    """ Start a session of poker """
    if HERO is None:
        print('You need to load or create a player first!')
        pause()
        return

    rebuy = get_buyin(GAME, HERO)

    g = factory.session_factory(
        seats=GAME.seats,
        game=GAME.game,
        tablename=GAME.tablename,
        level=GAME.level,
        hero=HERO,
        names='random',
        herobuyin=rebuy,
        varystacks=True
    )

    playing = True

    while playing:
        os.system('clear')
        g.play()
        # Check if hero went broke
        if g.find_hero().stack == 0:
            rebuy = get_buyin(GAME, HERO)

        g.table_maintainance()

        choice = input('keep playing? > ')
        if choice.lower() == 'n':
            playing = False
            g.find_hero().standup()
            player.save_player(HERO)
예제 #6
0
 def setUp_stud(self, lvl=1, players=6):
     self.g = factory.session_factory(seats=players, game="FIVE CARD STUD", level=lvl)
     self.r = poker.Round(self.g)
예제 #7
0
 def setUp(self, lvl=1, players=6):
     # Make a 6 player table
     self.g = factory.session_factory(seats=players, game="FIVE CARD DRAW", level=lvl)
     self.r = poker.Round(self.g)
예제 #8
0
 def test_sessionfactory_hero_herohasbankminusstack(self):
     s = factory.session_factory(seats=2, game="FIVE CARD STUD",
                                 hero=self.h, herobuyin=factory.DEF_STACK)
     expected = factory.CPU_BANK_BITS - factory.DEF_STACK
     result = s.table.seats[0].player.bank
     self.assertEqual(expected, result)
예제 #9
0
 def test_sessionfactory_hero_defaultseat_seat0hashero(self):
     s = factory.session_factory(seats=2, game="FIVE CARD STUD",
                                 hero=self.h, herobuyin=factory.DEF_STACK)
     expected = self.h.name
     result = str(s.table.seats[0].player)
     self.assertEqual(expected, result)
예제 #10
0
 def test_sessionfactory_hero_defaultseat_seat0(self):
     s = factory.session_factory(seats=2, game="FIVE CARD STUD",
                                 hero=self.h, herobuyin=factory.DEF_STACK)
     expected = 0
     result = s.table.get_index(self.h)
     self.assertEqual(expected, result)
예제 #11
0
 def test_sessionfactory_2seat_Poolhas2less(self):
     s = factory.session_factory(seats=2, game="FIVE CARD STUD")
     expected = 2
     result = factory.DEFAULT_POOL - len(s.playerpool)
     self.assertEqual(expected, result)