def testMartingaleWin(self): bet = Bet(1.0, Outcome("BLACK", 1)) initialStake = self.martingale.stake - bet.amount self.martingale.placeBets() self.martingale.win(bet) winAmount = bet.winAmount() + initialStake self.assertEqual(0, self.martingale.lossCount) self.assertEqual(1, self.martingale.betMultiple) self.assertEqual(winAmount, self.martingale.stake)
class BetTestCase(unittest.TestCase): def setUp(self): self.outcome_5 = Outcome("00-0-1-2-3", RoulettePayout.FiveBet) self.outcome_0 = Outcome("Number 0", RoulettePayout.StraightBet) self.bet_5 = Bet(1000, self.outcome_5) self.bet_0 = Bet(1000, self.outcome_0) def test_winAmount(self): self.assertEqual(self.bet_5.winAmount(), 1000 + 1000 * 6) self.assertEqual(self.bet_0.winAmount(), 1000 + 1000 * 35) def test_getAmount(self): self.assertEqual(self.bet_5, "1000 on 00-0-1-2-3 (6:1)")
def testBetsIterator(self): betFour = Bet(3, Outcome("test4", 2)) betFive = Bet(2, Outcome("test5", 3)) self.table.placeBet(self.betOne) self.table.placeBet(self.betTwo) self.table.placeBet(betFour) self.table.placeBet(betFive) betStrings = [] for bet in self.table.bets: betStrings.append(str(bet)) self.assertTrue("1 on test1" in betStrings, MISSING_BET_STRINGS_VALUE) self.assertTrue("2 on test2" in betStrings, MISSING_BET_STRINGS_VALUE) self.assertTrue("3 on test4" in betStrings, MISSING_BET_STRINGS_VALUE) self.assertTrue("2 on test5" in betStrings, MISSING_BET_STRINGS_VALUE)
def placeBets(self): """Updates the Table with the various bets.""" # create bet bet = Bet(self.BASE_AMOUNT, self.getOutcome(self.BASE_BET)) # update table with bet super(Passenger57, self).placeBets(bet)
def testMartingaleLoss(self): bet = Bet(1.0, Outcome("BLACK", 1)) self.martingale.placeBets() self.martingale.lose(bet) self.assertEqual(1, self.martingale.lossCount) self.assertEqual(2, self.martingale.betMultiple)
def placeBets(self): "Ideally the black should not be hardcoded but taken from some variable" super().placeBets() betAmount = self.initialBet * self.betMultiple self.stake -= betAmount blackOutcome = self.table.wheel.getOutcome("Black") blackBet = Bet(betAmount, blackOutcome) self.table.placeBet(blackBet)
def test_win_loseAmount(): rng = NonRandom() wheel = Wheel(rng) binbuilder = BinBuilder(wheel) binbuilder.straightBets() outcome = wheel.getOutcome("1") amount = 500 bet = Bet(amount, outcome) for i in range(0, 38): wheel.rng.setSeed(i) returned_bin = wheel.next() returned_outcomes = returned_bin.outcomes if outcome in returned_outcomes: assert bet.winAmount() == 500 + 500 * outcome.odds else: assert bet.loseAmount() == 500
def setUp(self): # create player self.table = Table() self.player = SevenReds(self.table) self.player.setStake(1000) # create bets to test them self.bet1 = Bet(1, self._getOutcome("Black")) self.bet2 = Bet(2, self._getOutcome("Black")) self.bet3 = Bet(4, self._getOutcome("Black")) # create NonRandom instance with seed non_random = NonRandom() non_random.setSeed(1) # create game self.wheel = Wheel(non_random) self.game = Game(self.wheel, self.table)
class TestBet(TestCase): def setUp(self): self.betOne = Bet(1, Outcome("test1", 1)) self.betTwo = Bet(1, Outcome("test2", 3)) self.betThree = Bet(1, Outcome("test3", 4)) self.betFour = Bet(5, Outcome("test4", 4)) def testWinAmount(self): self.assertEqual(2, self.betOne.winAmount()) self.assertEqual(4, self.betTwo.winAmount()) self.assertEqual(5, self.betThree.winAmount()) self.assertEqual(25, self.betFour.winAmount()) def testLoseAmount(self): self.assertEqual(1, self.betOne.loseAmount()) self.assertEqual(1, self.betTwo.loseAmount()) self.assertEqual(1, self.betThree.loseAmount()) self.assertEqual(5, self.betFour.loseAmount()) def testToString(self): self.assertEqual("5 on test4", self.betFour.__str__(), "String representation not as expected")
def placeBets(self): """Create bet and update table with it.""" # create bet bet = Bet(self.BASE_AMOUNT * self.bet_multiple, self.getOutcome(self.BASE_BET)) # update table with bet success = super(Martingale, self).placeBets(bet) # if bet coudn't be placed because no more money, leave and reset if not success: self.setRoundsToGo(0) self.loss_count = 0 self.bet_multiple = 1 return success
def testCheckCanBet(self): bet = Bet(4.0, Outcome("BLACK", 1)) self.assertTrue(self.martingale.checkCanBetPlay(bet))
def testCheckCantBetMoreThanTableLimit(self): bet = Bet(20.0, Outcome("BLACK", 1)) self.assertFalse(self.martingale.checkCanBetPlay(bet))
def testCheckCantBetPlayMoreThanStake(self): bet = Bet(1.0, Outcome("BLACK", 1)) self.martingale.setStake(0) self.assertFalse(self.martingale.checkCanBetPlay(bet))
def setUp(self): self.table = Table() self.betOne = Bet(1, Outcome("test1", 4)) self.betTwo = Bet(2, Outcome("test2", 3)) self.betThree = Bet(12, Outcome("test3", 4))
def testMartingaleCanPlaceBetsOnTable(self): bet = Bet(1.0, Outcome("BLACK", 1)) self.martingale.placeBets() self.assertIn(bet, self.table.bets)
def placeBets(self): super().placeBets() betToPlace = Bet(self.BET_AMOUNT, self.black) self.table.placeBet(betToPlace)
def setUp(self): self.betOne = Bet(1, Outcome("test1", 1)) self.betTwo = Bet(1, Outcome("test2", 3)) self.betThree = Bet(1, Outcome("test3", 4)) self.betFour = Bet(5, Outcome("test4", 4))
def placeBets(self): bet = Bet(2, self.black) self.table.placeBet(bet) self.stake -= bet.amount
def setUp(self): self.outcome_5 = Outcome("00-0-1-2-3", RoulettePayout.FiveBet) self.outcome_0 = Outcome("Number 0", RoulettePayout.StraightBet) self.bet_5 = Bet(1000, self.outcome_5) self.bet_0 = Bet(1000, self.outcome_0)