def test_move_full_stack_to_minus_trap_to_empty(self): self.g.camel_track[8] = ["c_0", "c_2", "c_1", "c_4"] self.g.camel_track[11] = ["c_3"] self.g.trap_track[10] = [-1, 2] expected_player_money = copy.deepcopy(self.g.player_money_values) def mock_random_camel(_): return 0 def mock_roll(_): return 2 with unittest.mock.patch('random.choice', mock_random_camel): with unittest.mock.patch('camelup.roll_dice', mock_roll): camelup.move_camel(self.g, 3) expected_track = [[] for _ in range(self.g.BOARD_SIZE * 2)] expected_track[8] = [] expected_track[9] = ["c_0", "c_2", "c_1", "c_4"] expected_track[11] = ["c_3"] for ii in range(self.g.BOARD_SIZE): self.assertEqual(self.g.camel_track[ii], expected_track[ii]) # Check that payout occurred expected_player_money[2] += 1 expected_player_money[3] += 1 self.assertEqual(self.g.player_money_values, expected_player_money)
def test_end_of_round_scoring_with_bets(self): # Remove camels from start positions self.g.camel_track[0] = [] self.g.camel_track[1] = [] self.g.camel_track[2] = [] self.g.camel_yet_to_move = [True, False, False, False, False] self.g.camel_track[0] = ["c_0"] self.g.camel_track[8] = ["c_1", "c_2"] self.g.camel_track[10] = ["c_4"] self.g.camel_track[12] = ["c_3"] self.g.round_bets = [["c_3", 0], ["c_3", 1], ["c_2", 3], ["c_3", 1], ["c_4", 2], ["c_0", 3]] expected_coins = copy.deepcopy(self.g.player_money_values) camelup.move_camel(g=self.g, player=0) expected_coins[0] += 1 # Coin for rolling expected_coins[0] += self.g.FIRST_PLACE_ROUND_PAYOUT[ 0] # Payout for first to choose first expected_coins[1] += self.g.FIRST_PLACE_ROUND_PAYOUT[ 1] # Payout for second to choose first expected_coins[ 3] += self.g.THIRD_OR_WORSE_PLACE_ROUND_PAYOUT # Payout for third or worse bet expected_coins[1] += self.g.FIRST_PLACE_ROUND_PAYOUT[ 2] # Payout for third to choose first expected_coins[2] += self.g.SECOND_PLACE_ROUND_PAYOUT[ 0] # Payout for first to choose second expected_coins[ 3] += self.g.THIRD_OR_WORSE_PLACE_ROUND_PAYOUT # Payout for third or worse bet self.assertEqual(expected_coins, self.g.player_money_values)
def test_end_of_round_scoring(self): expected_coins = copy.deepcopy(self.g.player_money_values) self.g.camel_yet_to_move = [True, False, False, False, False] self.g.camel_track[15] = ["c_0"] self.g.camel_track[8] = ["c_1", "c_2"] self.g.camel_track[10] = ["c_4"] self.g.camel_track[12] = ["c_3"] self.g.game_winner_bets = [["c_0", 0], ["c_0", 1], ["c_2", 3], ["c_3", 2], ["c_4", 2], ["c_0", 2], ["c_0", 3]] self.g.game_loser_bets = [["c_1", 1], ["c_1", 2], ["c_3", 0], ["c_4", 3], ["c_0", 3], ["c_1", 3], ["c_1", 0]] camelup.move_camel(g=self.g, player=0) expected_coins[0] += 1 # Coin for rolling expected_coins[0] += self.g.get_game_bets_payout( 0) # Payout for first to choose winner expected_coins[1] += self.g.get_game_bets_payout( 1) # Payout for second to choose winner expected_coins[ 3] += self.g.BAD_GAME_END_BET # Payout for bad bet on winner expected_coins[ 2] += self.g.BAD_GAME_END_BET # Payout for bad bet on winner expected_coins[ 2] += self.g.BAD_GAME_END_BET # Payout for bad bet on winner expected_coins[2] += self.g.get_game_bets_payout( 2) # Payout for third to choose winner expected_coins[3] += self.g.get_game_bets_payout( 3) # Payout for fourth to choose winner expected_coins[1] += self.g.get_game_bets_payout( 0) # Payout for first to choose loser expected_coins[2] += self.g.get_game_bets_payout( 1) # Payout for second to choose loser expected_coins[ 0] += self.g.BAD_GAME_END_BET # Payout for bad bet on loser expected_coins[ 3] += self.g.BAD_GAME_END_BET # Payout for bad bet on loser expected_coins[ 3] += self.g.BAD_GAME_END_BET # Payout for bad bet on loser expected_coins[3] += self.g.get_game_bets_payout( 2) # Payout for third to choose loser expected_coins[0] += self.g.get_game_bets_payout( 3) # Payout for fourth to choose loser self.assertEqual(expected_coins, self.g.player_money_values)
def test_end_of_round_scoring_only_rolls(self): expected_money = copy.deepcopy(self.g.player_money_values) camelup.move_camel(g=self.g, player=0) camelup.move_camel(g=self.g, player=1) camelup.move_camel(g=self.g, player=2) camelup.move_camel(g=self.g, player=3) camelup.move_camel(g=self.g, player=0) expected_money[0] += 2 expected_money[1] += 1 expected_money[2] += 1 expected_money[3] += 1 self.assertEqual(expected_money, self.g.player_money_values)
def test_move_stacked_camel_to_stack(self): self.g.camel_track[10] = ["c_0", "c_1"] self.g.camel_track[12] = ["c_2", "c_3", "c_4"] def mock_random_camel(_): return 0 def mock_roll(_): return 2 with unittest.mock.patch('random.choice', mock_random_camel): with unittest.mock.patch('camelup.roll_dice', mock_roll): camelup.move_camel(self.g, 0) expected_track = [[] for _ in range(self.g.BOARD_SIZE * 2)] expected_track[12] = ["c_2", "c_3", "c_4", "c_0", "c_1"] for ii in range(self.g.BOARD_SIZE): self.assertEqual(self.g.camel_track[ii], expected_track[ii])