def test_end_turn_goes_to_next_player(fake_roll_dice): fake_roll_dice.return_value = (1, 2) # not a 7 players = [SimplePlayer(Color.RED), SimplePlayer(Color.BLUE)] game = Game(players) actions = [] while not any( a.action_type == ActionType.ROLL for a in game.state.playable_actions ): actions.append(game.play_tick()) p0_color = game.state.colors[0] p1_color = game.state.colors[1] assert ( game.state.current_prompt == ActionPrompt.PLAY_TURN and game.state.current_color() == p0_color ) assert game.state.playable_actions == [Action(p0_color, ActionType.ROLL, None)] game.execute(Action(p0_color, ActionType.ROLL, None)) assert game.state.current_prompt == ActionPrompt.PLAY_TURN assert game.state.current_color() == p0_color assert player_has_rolled(game.state, p0_color) assert Action(p0_color, ActionType.END_TURN, None) in game.state.playable_actions game.execute(Action(p0_color, ActionType.END_TURN, None)) assert game.state.current_prompt == ActionPrompt.PLAY_TURN assert game.state.current_color() == p1_color assert not player_has_rolled(game.state, p0_color) assert not player_has_rolled(game.state, p1_color) assert game.state.playable_actions == [Action(p1_color, ActionType.ROLL, None)]
def test_play_monopoly_no_monopoly_card(): players = [SimplePlayer(Color.RED), SimplePlayer(Color.BLUE)] game = Game(players) action_to_execute = Action(players[0].color, ActionType.PLAY_MONOPOLY, ORE) with pytest.raises(ValueError): # no monopoly game.execute(action_to_execute)
def test_play_year_of_plenty_no_year_of_plenty_card(): players = [SimplePlayer(Color.RED), SimplePlayer(Color.BLUE)] game = Game(players) action_to_execute = Action( players[0].color, ActionType.PLAY_YEAR_OF_PLENTY, [ORE, WHEAT] ) with pytest.raises(ValueError): # no year of plenty card game.execute(action_to_execute)
def test_play_year_of_plenty_not_enough_resources(): players = [SimplePlayer(Color.RED), SimplePlayer(Color.BLUE)] player_to_act = players[0] game = Game(players) game.state.resource_freqdeck = [0, 0, 0, 0, 0] player_deck_replenish(game.state, player_to_act.color, YEAR_OF_PLENTY) action_to_execute = Action( player_to_act.color, ActionType.PLAY_YEAR_OF_PLENTY, [ORE, WHEAT], ) with pytest.raises(ValueError): # not enough cards in bank game.execute(action_to_execute)
def test_execute_action_on_copies_doesnt_conflict(): players = [ SimplePlayer(Color.RED), SimplePlayer(Color.BLUE), SimplePlayer(Color.WHITE), SimplePlayer(Color.ORANGE), ] game = Game(players) p0_color = game.state.colors[0] game.execute(Action(p0_color, ActionType.BUILD_SETTLEMENT, 0)) action = Action(p0_color, ActionType.BUILD_ROAD, (0, 1)) game_copy = game.copy() game_copy.execute(action) game_copy = game.copy() game_copy.execute(action) game.execute(action)