def test_5_baron_suicide():
    """
    player0 has Baron-Baron and everyone else has higher cards, so they die.
    """
    game_round = start_round_from_player_cards(
        [cards.Baron(), cards.Baron()],
        [cards.Countess(), cards.Handmaid(),
         cards.Guard()],
        [cards.Handmaid(), cards.Princess(),
         cards.Guard()],
        first_player=0,
    )
    player0, player1, player2 = game_round.players

    play_random_move(player0)
    assert not game_round.ended
    assert not player0.alive
    assert player1.alive
    assert player2.alive
    def round_runner(g):
        game_round = start_round_from_player_cards(
            [cards.Guard(), cards.Baron()],
            [cards.King(), cards.Princess()],
            first_player=0,
        )
        object.__setattr__(g.state, "round", game_round)  # work around frozen dataclass
        player0, player1 = game_round.players

        play_with_choices(player0, CardType.GUARD, player1, cards.Princess)
        play_random_move(player1)

        end = game_round.state
        assert end.type == RoundState.Type.ROUND_END
        assert end.winner is player0
示例#3
0
def test_baron_equalOpponent_noneEliminated(started_round: Round, card):
    player = started_round.current_player
    opponent = started_round.next_player(player)
    give_card(player, card, replace=True)
    give_card(opponent, card, replace=True)

    move = play_card(player, cards.Baron())
    target_step = next(move)
    target_step.choice = opponent
    comparison, *_ = send_gracious(move, target_step)
    move.close()
    assert len(_) == 0
    assert isinstance(comparison, mv.CardComparison)

    assert player.alive
    assert opponent.alive
def test_3_king_win():
    """
    player1 draws the Princess but is forced to relinquish it because they have a King.
    """
    game_round = start_round_from_player_cards(
        [cards.Guard(), cards.Baron()],
        [cards.King(), cards.Princess()],
        first_player=0,
    )
    player0, player1 = game_round.players

    play_with_choices(player0, CardType.GUARD, player1, cards.Princess)
    play_random_move(player1)

    end = game_round.state
    assert end.type == RoundState.Type.ROUND_END
    assert end.winner is player0
示例#5
0
def test_advanceTurn_emptyDeck_roundEndsWithLargestCardWinner(
        started_round: Round, set_aside):
    started_round.deck = Deck([], set_aside=set_aside)
    increasing_cards = [
        cards.Guard(),
        cards.Priest(),
        cards.Baron(),
        cards.Princess()
    ]
    for player, card in zip(started_round.players, increasing_cards):
        give_card(player, card, replace=True)
    # noinspection PyUnboundLocalVariable
    winner = player

    state: loveletter.round.RoundEnd = force_next_turn(started_round)
    assert state.type == RoundState.Type.ROUND_END
    assert state.reason == loveletter.round.RoundEnd.Reason.EMPTY_DECK
    assert state.winners == frozenset({winner})
    assert state.winner is winner
示例#6
0
def test_baron_strongerOpponent_selfEliminated(started_round: Round, card1,
                                               card2):
    player = started_round.current_player
    opponent = started_round.next_player(player)
    give_card(player, card1, replace=True)
    give_card(opponent, card2, replace=True)

    move = play_card(player, cards.Baron())
    target_step = next(move)
    target_step.choice = opponent
    comparison, elimination, *_ = send_gracious(move, target_step)
    move.close()
    assert len(_) == 0
    assert isinstance(comparison, mv.CardComparison)
    assert isinstance(elimination, mv.PlayerEliminated)
    assert comparison.opponent is opponent
    assert elimination.eliminated is player

    assert not player.alive
    assert opponent.alive
def test_4_princess_suicide():
    """
    player1 holds a Princess but has to eliminate themselves because they draw a Prince
    and the opponent is immune.
    """
    game_round = start_round_from_player_cards(
        [cards.Handmaid(), cards.Baron(),
         cards.Guard()],
        [cards.Princess(), cards.Prince(),
         cards.Countess()],
        first_player=0,
    )
    player0, player1 = game_round.players

    play_with_choices(player0, CardType.HANDMAID)
    play_random_move(player1)

    assert game_round.ended
    assert game_round.state.winner is player0
    assert CardType(
        game_round.deck.take()) == CardType.GUARD  # assert no card dealt