def start_round_from_player_cards(*player_cards: Sequence[cards.Card], first_player: int, set_aside=None): """ Create a round that will deal to each player the specified sequence of cards. The deck is built in a way so that player i starts with player_cards[i][0] and is dealt the cards in player_cards[i][1:] in order at each successive turn. This assumes that no player is eliminated before the last card in player_cards[i] is dealt to them. :param player_cards: A varargs sequence of card sequences that each player will receive during the round. The first list corresponds to player 0, then player 1, and so on. :param first_player: ID (index) of the first player to play in the round. This is (also) needed to build the deck so that player_cards[i] always corresponds to player i (*not* the i-th player to play). :param set_aside: Which card to set aside in the deck. Default is a new instance of :class:`cards.Princess`. :return: A round with the number of players and deck deduced from ``player_cards``. """ player_cards = player_cards[first_player:] + player_cards[:first_player] stack = list(mitt.roundrobin(*player_cards))[::-1] deck = Deck(stack, set_aside=set_aside or cards.Princess()) round = Round(len(player_cards), deck=deck) round.start(first_player=round.players[first_player]) return round
def make_round_mock(): round_ = Round(2) round_.start() player = round_.current_player round_mock = MagicMock(wraps=round_) round_mock.current_player = round_mock.state.current_player = player type(round_mock).living_players = PropertyMock( side_effect=lambda: round_.living_players) round_mock.players = round_.players for p in round_mock.players: p.round = round_mock return round_mock
def new_round(num_players) -> Round: return Round(num_players)