Esempio n. 1
0
def test_add_card_should_add_card_for_player_with_one_card(person, turtle):
    player = Player(person, turtle, [Card(0, 'RED', 'PLUS')])
    card = Card(1, 'RED', 'MINUS')

    player.add_card(card)

    assert player.has_card(card)
Esempio n. 2
0
def test_player_should_have_no_cards_after_removing_only_card(person, turtle):
    card = Card(0, 'RED', 'PLUS')
    player = Player(person, turtle, [card])

    player.remove_card(card)

    assert not player.cards
Esempio n. 3
0
def test_has_card_should_return_false_when_user_has_no_cards(person, turtle):
    cards = []
    player = Player(person, turtle, cards)

    actual = player.has_card(Card(0, 'RED', 'PLUS'))

    assert not actual
Esempio n. 4
0
def test_new_card_should_be_the_first_of_player_cards(person, turtle):
    player = Player(person, turtle, [Card(0, 'RED', 'PLUS')])
    card = Card(1, 'RED', 'MINUS')

    player.add_card(card)

    assert player.cards[0] == card
Esempio n. 5
0
def test_has_card_returns_true_when_has_card_in_two_cards(person, turtle):
    cards = [Card(0, 'RED', 'PLUS'), Card(1, 'RED', 'MINUS')]
    player = Player(person, turtle, cards)

    actual = player.has_card(cards[0])

    assert actual
Esempio n. 6
0
def test_add_card_should_add_card_for_player_with_no_cards(person, turtle):
    card = Card(0, 'RED', 'PLUS')
    player = Player(person, turtle, [])

    player.add_card(card)

    assert player.has_card(card)
Esempio n. 7
0
def test_has_card_should_return_true_when_user_has_given_card(person, turtle):
    card = Card(0, 'RED', 'PLUS')
    player = Player(person, turtle, [card])

    actual = player.has_card(card)

    assert actual
Esempio n. 8
0
def test_new_card_should_add_card_for_player_with_two_cards(person, turtle):
    cards = [Card(0, 'RED', 'PLUS'), Card(1, 'GREEN', 'MINUS')]
    player = Player(person, turtle, cards)
    card = Card(2, 'RAINBOW', 'ARROW')

    player.add_card(card)

    assert player.cards[0] == card
Esempio n. 9
0
def test_player_shouldnt_have_card_after_its_removal(person, turtle):
    card = Card(0, 'RED', 'PLUS')
    cards = [card, Card(1, 'RED', 'MINUS')]
    player = Player(person, turtle, cards)

    player.remove_card(card)

    assert not player.has_card(card)
Esempio n. 10
0
def test_remove_card_should_raise_when_player_has_other_card(person, turtle):
    player = Player(person, turtle, [Card(1, 'RED', 'MINUS')])

    with pytest.raises(ValueError):
        player.remove_card(Card(0, 'RED', 'PLUS'))
Esempio n. 11
0
 def _ensure_player_can_move(self, player: Player):
     while not self._can_player_move(player):
         player.cards = self.stacks.get_new_cards(HAND_SIZE)
Esempio n. 12
0
 def _init_player(self, person: Person, turtle: Turtle):
     return Player(person, turtle, self.stacks.get_new_cards(HAND_SIZE))
Esempio n. 13
0
 def _update_player_cards_and_stacks(self, player: Player, action: Action):
     self.stacks.put(action.card)
     player.remove_card(action.card)
     new_card = self.stacks.get_new()
     player.add_card(new_card)