示例#1
0
         # play the line
         if stake > line_bet and g.is_button_off:
             if b.play_pass_line(line_bet):
                 stake -= line_bet
                 if debug:
                     print "pass line bet %s" % line_bet
         if stake > line_odds and g.is_button_on() and b.pass_line_odds == 0:
             if b.play_pass_line_odds(line_odds):
                 stake -= line_odds
                 if debug:
                     print "pass line odds %s" % line_odds
         have_place = b.have_place_bets()
         if stake > 27 and g.is_button_on() and not have_place:
             for i in [4, 5, 6, 8, 9, 10]:
                 if i != 6 and i != 8 and i != g.current_point:
                     b.place_the_number(i, 5)
                     stake -= 5
                 if i != g.current_point and (i == 6 or i == 8):
                     b.place_the_number(i, 6)
                     stake -= 6
             if debug:
                 print "placing across, stake = %s" % stake 
 
         g.roll_dice(verbose=debug)
         if debug:
             print b.show_bets()
         win = b.check_winnings(verbose=debug)
         if win:
             stake += win
         if debug:
             print "Roll %s stake = %s" % (i, stake)
示例#2
0
     if six_eight.play_pass_line_odds(line_odds):
         stake2 -= line_odds
         if debug:
             print "6_8: pass line odds %s" % line_odds
 # play pass line odds
 if stake3 > line_odds and game.is_button_on() and come.pass_line_odds == 0:
     if come.play_pass_line_odds(line_odds):
         stake3 -= line_odds
         if debug:
             print "Come: pass line odds %s" % line_odds
 # do the extra betting
 have_place1 = across.have_place_bets()
 if stake1 > 27 and game.is_button_on() and not have_place1:
     for i in [4, 5, 6, 8, 9, 10]:
         if i != 6 and i != 8 and i != game.current_point:
             across.place_the_number(i, 5)
             stake1 -= 5
         if i != game.current_point and (i == 6 or i == 8):
             across.place_the_number(i, 6)
             stake1 -= 6
     if debug:
         print "Across: placing across, stake = %s" % stake1 
 have_place2 = six_eight.have_place_bets()
 if stake2 > 12 and game.is_button_on() and not have_place2:
     for i in [6, 8]:
         if i != game.current_point:
             six_eight.place_the_number(i, 6)
             stake2 -= 6
     if debug:
         print "6_8: placing 6 and 8, stake = %s" % stake2 
 if stake3 > line_bet and num_come_bets < 3:
示例#3
0
class TestBetting(unittest.TestCase):


    def setUp(self):
        self.betting = Betting(CrapsGame())


    def testSimple(self):
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(d1_val=4, d2_val=3)
        self.assertTrue(self.betting.game.is_seven(), "msg")
        self.assertEqual(10, self.betting.check_winnings(), "msg")
        self.assertFalse(self.betting.play_come_bet(5), "msg")
        self.assertEqual(10, self.betting.check_winnings(), "msg")
        
    def testPassLine(self):
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(d1_val=4, d2_val=3)
        self.assertEqual(10, self.betting.check_winnings(), "got %s not 10" % self.betting.check_winnings())
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(d1_val=4, d2_val=2)
        self.betting.play_pass_line_odds(10)
        self.betting.game.roll_dice(d1_val=4, d2_val=2)
        self.assertEqual(5 + 5 + 10 + 12, self.betting.check_winnings(), "32 != %s" % self.betting.check_winnings())
        
        
    def testCraps(self):
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(d1_val=1, d2_val=2)
        self.assertTrue(self.betting.game.is_craps(), "msg")
        self.assertEqual(0, self.betting.check_winnings(), "msg")
        self.assertEqual(0, self.betting.pass_line_bet, "msg")
        
    def testPlaceBets(self):
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(d1_val=1, d2_val=5)
        self.betting.place_the_number(8, 6)
        self.betting.game.roll_dice(d1_val=5, d2_val=3)
        self.assertEqual(7, self.betting.check_winnings(), "msg")
        
    def testComeBets(self):
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(verbose=True, d1_val=1, d2_val=5)
        self.betting.play_pass_line_odds(10)
        self.betting.play_come_bet(5)
        self.betting.game.roll_dice(verbose=True, d1_val=2, d2_val=5)
        self.assertEqual(10, self.betting.check_winnings(), "msg")
        self.assertFalse(self.betting.play_come_bet(5), "msg")
        self.assertEqual(0, self.betting.num_come_bets(), "expecting 0 got %s" % self.betting.num_come_bets())
        self.betting.game.roll_dice(verbose=True, d1_val=1, d2_val=5)
        self.assertEqual(0, self.betting.check_winnings(), "msg")
        self.assertTrue(self.betting.play_come_bet(5), "msg")
        self.betting.game.roll_dice(verbose=True, d1_val=1, d2_val=3)
        self.assertEqual(0, self.betting.check_winnings(), "msg")  
        self.assertEqual(1, self.betting.num_come_bets(), "expected 1 got %s" % self.betting.num_come_bets())      
        self.assertTrue(self.betting.play_come_bet_odds(4, 10), "msg")
        self.betting.game.roll_dice(verbose=True, d1_val=2, d2_val=2)
        self.assertEqual(40, self.betting.check_winnings(verbose=True), "expected 40 got %s" % self.betting.check_winnings())        
      
    def testPlaceAndPass(self):
        self.betting.play_pass_line(5)
        self.betting.game.roll_dice(verbose=True, d1_val=1, d2_val=5)
        self.betting.check_winnings(verbose=True)
        self.betting.play_pass_line_odds(10)
        self.betting.place_the_number(4, 5)
        self.betting.place_the_number(5, 5)
        self.betting.place_the_number(8, 6)
        self.betting.place_the_number(9, 5)
        self.betting.place_the_number(10, 5)
        self.betting.game.roll_dice(verbose=True, d1_val=1, d2_val=4)
        self.betting.check_winnings(verbose=True)
        self.betting.game.roll_dice(verbose=True, d1_val=2, d2_val=4)
        self.assertEqual(32, self.betting.check_winnings(verbose=True), "got %s" % self.betting.check_winnings())