def test_play_break_hearts(self): """ Tests that once hearts is broken, it is possible to lead with a heart. """ hands = [ ["d4", "dj", "s9", 'h5', 'c2', 'h1', 'd2', 'h8', 'd3', 's2', 'd9', 'd8', 'dq'], ["s7", "c5", "c4", 'c10', 'h6', 'c3', 'h10', 'hk', 'd7', 'dk', 'h4', 'sj', 'hq'], ["hj", "s5", "d5", 's6', 's10', 'd1', 'sk', 's4', 'h7', 'd10', 'c9', 'cq', 'cj'], ["d6", "h2", "sq", 'c8', 'h9', 'ck', 'h3', 'c6', 's1', 'c1', 's3', 'c7', 's8'] ] round = HeartsRound(hands) # get the first trick out of the way round.play_card("c2") round.play_card("c10") round.play_card("c9") round.play_card("c8") # player 1 to start now self.assertEqual(1, round.get_current_player()) round.play_card("c3") round.play_card("cj") round.play_card("c7") round.play_card("h5") # player 0 has no clubs # player 2 wins due to cj self.assertEqual(2, round.get_current_player()) # check that hearts is broken self.assertTrue(round.is_hearts_broken()) # player 2 can lead with a heart now round.play_card("h7") self.assertEqual([{"player": 2, "card": "h7"}], round.get_trick())
def test_init_play_is_hearts_broken(self): """ When play initially starts, hearts should not be broken. """ round = HeartsRound(example_hands) self.assertFalse(round.is_hearts_broken())