Example #1
0
def test_countess_playPrinceOrKing_raises(current_player, other_card_type):
    give_card(current_player, cards.Countess(), replace=True)
    give_card(current_player, card := card_from_card_type(other_card_type))

    with assert_state_is_preserved(current_player.round) as mocked_round:
        with pytest.raises(valid8.ValidationError):
            autofill_move(mocked_round.current_player.play_card(card))
Example #2
0
def test_countess_choosePrinceOrKing_raises(current_player, other_card_type):
    give_card(current_player, cards.Countess(), replace=True)
    give_card(current_player, other_card :=
              card_from_card_type(other_card_type))

    event = loveletter.round.ChooseCardToPlay(current_player)
    with pytest.raises(valid8.ValidationError):
        event.choice = other_card
Example #3
0
def test_countess_playNotPrinceOrKing_noOp(current_player: RoundPlayer,
                                           card_type):
    target = current_player.round.next_player(current_player)
    with assert_state_is_preserved(current_player.round,
                                   allow_mutation={current_player,
                                                   target}) as mocked_round:
        player, target = mocked_round.current_player, mocked_round.players[
            target.id]
        give_card(player, cards.Countess(), replace=True)
        move = play_card(player,
                         card := card_from_card_type(card_type),
                         autofill=False)
        step = None
        for _ in card.steps:
            step = move.send(step)
            if isinstance(step, mv.PlayerChoice):
                step.choice = target
            else:
                step = autofill_step(step)
        send_gracious(move, step)
Example #4
0
def test_prince_againstNonPrincess_dealsCard(started_round: Round,
                                             target: RoundPlayer, card_type):
    player = started_round.current_player
    give_card(target, card_from_card_type(card_type), replace=True)
    target_card = target.hand.card

    deck_before = list(started_round.deck)
    move = play_card(player, cards.Prince())
    target_step = next(move)
    target_step.choice = target
    results = send_gracious(move, target_step)
    assert tuple(map(type, results)) == (
        mv.CardDiscarded,
        mv.CardDealt,
    )
    assert results[0].target is target
    assert target.alive
    assert target.hand.card is deck_before[-1]
    assert target.discarded_cards[
        -1 if target is not player else -2] is target_card
    # Checking second-to-last as last is the Prince card:
    assert list(started_round.discard_pile)[-2] is target_card
    assert list(started_round.deck) == deck_before[:-1]
Example #5
0
 def case_other_multistep_card_nocancel(self, card_type: CardType):
     return card_from_card_type(card_type)
Example #6
0
 def case_target_card_nocancel(self, card_type):
     return card_from_card_type(card_type)
Example #7
0
 def case_discard_card(self, card_type: CardType):
     return card_from_card_type(card_type)