Example #1
0
 def test_player_should_give_card_to_trick_when_playing(self):
     player = Player()
     card = Card("C", "S")
     trick = Trick()
     player.add_card_to_hand(card)
     player.play(trick, 0)
     assert len(trick) == 1
Example #2
0
 def test_player_hand_should_be_smaller_after_playing(self):
     player = Player()
     card = Card("C", "S")
     trick = Trick()
     player.add_card_to_hand(card)
     l = len(player.hand)
     player.play_card(card, trick)
     assert len(player.hand) == l - 1
Example #3
0
 def test_player_should_set_owner_on_his_cards(self):
     player = Player()
     cards = [Card("C", "S"), Card("D", "S"), Card("H", "S"),
              Card("S", "S"), Card("C", "E"), Card("D", "T"),
              Card("H", "J"), Card("S", "Q")]
     for card in cards:
         player.add_card_to_hand(card)
     for card in player.hand:
         assert card.owner is player
Example #4
0
 def test_get_demanded_suit_card_in_hand_should_return_demanded_suit_cards_only(self):
     player = Player()
     cards = [Card("C", "S"), Card("D", "S"), Card("H", "S"), Card("S", "S"), Card("C", "E"), Card("D", "T"),
              Card("H", "J"), Card("S", "Q")]
     for card in cards:
         player.add_card_to_hand(card)
     for suit in range(4):
         for card in player.get_demanded_suit_cards_in_hand(suit):
             assert card.suit == suit
Example #5
0
 def test_player_should_have_only_ranked_cards_after_setting_trump(self):
     player = Player()
     cards = [Card("C", "S"), Card("D", "S"), Card("H", "S"),
              Card("S", "S"), Card("C", "E"), Card("D", "T"),
              Card("H", "J"), Card("S", "Q")]
     for card in cards:
         player.add_card_to_hand(card)
     player.set_trump_suit("C")
     for new_card in player.hand:
         assert isinstance(new_card, RankedCard)
Example #6
0
 def test_add_card_to_hand_AND_move_all_card(self):
     p = Player()
     empty_cc = CardCollection()
     dest_cc = CardCollection()
     p.add_card_to_hand(3)
     p.add_card_to_hand(4)
     p.add_card_to_hand(10)
     self.assertEqual(empty_cc, dest_cc)
     p.move_all_cards(dest_cc)
     self.assertEqual(empty_cc, p.hand)
     expected_dest = CardCollection()
     expected_dest[3] = 1
     expected_dest[4] = 1
     expected_dest[10] = 1
     self.assertEqual(dest_cc, expected_dest)
Example #7
0
 def test_get_hand_len(self):
     p = Player()
     p.add_card_to_hand(3)
     self.assertEqual(p.get_hand_len(), 1)
     p.add_card_to_hand(4)
     self.assertEqual(p.get_hand_len(), 2)
     p.add_card_to_hand(4)
     self.assertEqual(p.get_hand_len(), 3)
Example #8
0
 def test_get_hand_value(self):
     p = Player()
     p.add_card_to_hand(3)
     self.assertEqual(p.get_hand_value(), 3)
     p.add_card_to_hand(4)
     self.assertEqual(p.get_hand_value(), 7)
     p.add_card_to_hand(2)
     self.assertEqual(p.get_hand_value(), 9)
Example #9
0
 def test_player_should_return_card_in_hand_when_chooses_card(self):
     player = Player()
     card = Card("C", "S")
     player.add_card_to_hand(card)
     chosen_card = player.choose_card(Trick(), 0)
     assert chosen_card in player.hand