예제 #1
0
 def test_winner_should_return_correct_index_without_offset(self):
     trick = Trick(cards=[Card("C", "E"), Card("C", "T"), Card("C", "J"), Card("C", "Q")]).to_ranked("C")
     assert trick.winner == Card("C", "J")
     trick = Trick(cards=[Card("C", "E"), Card("D", "T"), Card("H", "J"), Card("S", "Q")]).to_ranked("C")
     assert trick.winner == Card("C", "E")
     trick = Trick(cards=[Card("D", "E"), Card("D", "T"), Card("H", "J"), Card("S", "Q")]).to_ranked("C")
     assert trick.winner == Card("D", "T")
     trick = Trick(cards=[Card("D", "E"), Card("C", "T"), Card("C", "J"), Card("H", "Q")]).to_ranked("C")
     assert trick.winner == Card("C", "J")
     trick = Trick(cards=[Card("D", "E"), Card("H", "T"), Card("S", "J"), Card("H", "Q")]).to_ranked("C")
     assert trick.winner == Card("D", "E")
예제 #2
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
예제 #3
0
 def test_referee_should_compute_team_score(self):
     team = Team(0, Player(), Player())
     cards = [Card("C", "E"), Card("C", "N"), Card("C", "J")]
     trick = Trick(cards).to_ranked("C")
     team.get_cards(trick)
     assert self.referee.count_team_points(team) == 34
     team.started = True
     assert self.referee.count_team_points(team) == 0
예제 #4
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
예제 #5
0
 def play_one_turn(self):
     trick = Trick()
     for i in range(4):
         player = self.who_plays_now(i)
         player.play(trick, self.trump_suit)
     return trick
예제 #6
0
 def test_team_should_have_four_cards_after_winning_a_trick(self):
     self.team.get_cards(Trick([Card("D", "S"), Card("D", "E"), Card("D", "N"), Card("D", "T")]))
     assert len(self.team.won_cards) == 4
     self.team.get_cards(Trick([Card("C", "S"), Card("C", "E"), Card("C", "N"), Card("C", "T")]))
     assert len(self.team.won_cards) == 8
예제 #7
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