Пример #1
0
    def test_start_game_preround(self):
        """
        When the game is started,
        it should go into the first pre-round,
        passing left.
        """
        game = HeartsGame(deal_func=lambda: example_hands)
        observer = Mock()
        game.add_observer(observer)

        game.start()

        self.assertEqual("passing", game.get_state())
        self.assertEqual("left", game.get_pass_direction())
        self.assertEqual(example_hands[0], game.get_hand(0))
Пример #2
0
    def test_finish_passing(self):
        """
        Tests that the state transitions properly
        into playing when passing is finished.
        """
        game = HeartsGame(deal_func=lambda: example_hands)
        observer = Mock()
        game.add_observer(observer)

        game.start()

        for i in range(4):
            game.pass_cards(i, example_hands[i][:3])

        self.assertEqual("playing", game.get_state())
        self.assertEqual(1, game.get_current_player())
        new_hand = example_hands[0][:3] + example_hands[1][3:]
        self.assertEqual(set(new_hand), set(game.get_hand(1)))
Пример #3
0
 def test_init_get_state(self):
     game = HeartsGame()
     self.assertEqual("init", game.get_state())