當前位置: 首頁>>代碼示例>>Python>>正文


Python controller.GameController類代碼示例

本文整理匯總了Python中durak.controller.GameController的典型用法代碼示例。如果您正苦於以下問題:Python GameController類的具體用法?Python GameController怎麽用?Python GameController使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了GameController類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_is_player1_to_move

    def test_is_player1_to_move(self):
        controller = GameController()
        controller._to_move = controller._player1
        self.assertTrue(controller.is_player1_to_move())

        controller._to_move = controller._player2
        self.assertFalse(controller.is_player1_to_move())
開發者ID:drtyrsa,項目名稱:durak,代碼行數:7,代碼來源:tests.py

示例2: test_to_move_property

    def test_to_move_property(self):
        controller = GameController()
        controller._to_move = controller._player1
        self.assertEqual(controller.to_move, controller.PLAYER1)

        controller._to_move = controller._player2
        self.assertEqual(controller.to_move, controller.PLAYER2)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:7,代碼來源:tests.py

示例3: test_winner_property

 def test_winner_property(self):
     controller = GameController()
     given_list = [controller._player1, controller._player2, None]
     expected_list = [controller.PLAYER1, controller.PLAYER2, None]
     for given, expected in zip(given_list, expected_list):
         controller._winner = given
         self.assertEqual(controller.winner, expected)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:7,代碼來源:tests.py

示例4: test_to_respond

    def test_to_respond(self):
        controller = GameController()
        controller._to_move = controller._player1
        self.assertEqual(controller._to_respond, controller._player2)

        controller._to_move = controller._player2
        self.assertEqual(controller._to_respond, controller._player1)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:7,代碼來源:tests.py

示例5: test_register_move_goes_to_responding_if_card_is_none

    def test_register_move_goes_to_responding_if_card_is_none(self):
        controller = GameController()
        controller._state = controller.States.MOVING
        controller._on_table = [DurakCard('AC'), DurakCard('AH')]

        controller.register_move(None)

        self.assertEqual(controller._state, controller.States.DEALING)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:8,代碼來源:tests.py

示例6: test_if_winner_is_ignored_first_move_is_selected_by_trump

    def test_if_winner_is_ignored_first_move_is_selected_by_trump(self):
        controller = GameController()
        controller._winner = controller._player1

        with patch.object(controller,
                          '_get_first_to_move_by_trump') as _get_first_mock:
            controller.start_new_game()
            self.assertEqual(controller._to_move, _get_first_mock.return_value)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:8,代碼來源:tests.py

示例7: test_if_winner_is_none_first_move_is_selected_by_trump

    def test_if_winner_is_none_first_move_is_selected_by_trump(self):
        controller = GameController()
        self.assertTrue(controller._winner is None)

        with patch.object(controller,
                          '_get_first_to_move_by_trump') as _get_first_mock:
            controller.start_new_game()
            self.assertEqual(controller._to_move, _get_first_mock.return_value)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:8,代碼來源:tests.py

示例8: test_get_enemy_of

 def test_get_enemy_of(self):
     controller = GameController()
     self.assertEqual(
         controller._get_enemy_of(controller._player1), controller._player2
     )
     self.assertEqual(
         controller._get_enemy_of(controller._player2), controller._player1
     )
開發者ID:drtyrsa,項目名稱:durak,代碼行數:8,代碼來源:tests.py

示例9: test_register_give_more_with_no_cards_goes_to_dealing

    def test_register_give_more_with_no_cards_goes_to_dealing(self):
        controller = GameController()
        controller._state = controller.States.GIVING_MORE
        controller._no_response = True

        controller.register_give_more([])

        self.assertEqual(controller.state, controller.States.DEALING)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:8,代碼來源:tests.py

示例10: test_start_new_game_return_value_and_state

 def test_start_new_game_return_value_and_state(self):
     controller = GameController()
     result = controller.start_new_game()
     self.assertDictEqual(result, {
         'player1_cards': set(controller._player1.cards),
         'player2_cards': set(controller._player2.cards),
         'trump': controller._trump,
     })
     self.assertEqual(controller.state, controller.States.MOVING)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:9,代碼來源:tests.py

示例11: test_if_winner_and_not_ignored_it_selects_first_move

    def test_if_winner_and_not_ignored_it_selects_first_move(self):
        controller = GameController()
        controller._winner = controller._player1

        with patch.object(controller,
                          '_get_first_to_move_by_trump') as _get_first_mock:
            controller.start_new_game(ignore_winner=False)
            self.assertEqual(controller._to_move, controller._player1)
            self.assertFalse(_get_first_mock.called)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:9,代碼來源:tests.py

示例12: test_start_new_game_players_and_deck_cards

    def test_start_new_game_players_and_deck_cards(self):
        controller = GameController()
        controller.start_new_game()
        self.assertEqual(controller._trump, controller._deck[-1])

        all_cards = []
        all_cards.extend(controller._deck)
        all_cards.extend(controller._player1.cards)
        all_cards.extend(controller._player2.cards)
        self.assertItemsEqual(all_cards, DurakCard.all())
開發者ID:drtyrsa,項目名稱:durak,代碼行數:10,代碼來源:tests.py

示例13: test_successful_register_give_more

    def test_successful_register_give_more(self):
        controller = GameController()
        controller._state = controller.States.GIVING_MORE
        controller._no_response = True
        controller._to_move = controller._player1
        controller._deck = [DurakCard('JH')]
        controller._trump = DurakCard('6H')
        controller._player1.cards = CardSet(
            cards=(DurakCard('AC'), DurakCard('6S'), DurakCard('6H')),
            trump=controller._trump
        )
        controller._player2.cards = CardSet(
            cards=(DurakCard('7C'), DurakCard('7H'), DurakCard('7D')),
            trump=controller._trump
        )
        controller._on_table = Table([DurakCard('6D')])

        controller.register_give_more([DurakCard('6S'), DurakCard('6H')])

        self.assertItemsEqual(controller._player1.cards, [DurakCard('AC')])
        self.assertSequenceEqual(controller._on_table, [DurakCard('6D')])
        self.assertItemsEqual(
            controller._on_table.given_more, [DurakCard('6S'), DurakCard('6H')]
        )
        self.assertEqual(controller._state, controller.States.DEALING)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:25,代碼來源:tests.py

示例14: test_state

 def test_state(self):
     controller = GameController()
     states = {
         controller.States.MOVING,
         controller.States.RESPONDING,
         controller.States.GIVING_MORE,
         controller.States.DEALING
     }
     for state in states:
         controller._state = state
         self.assertEqual(controller.state, state)
開發者ID:drtyrsa,項目名稱:durak,代碼行數:11,代碼來源:tests.py

示例15: test_deal_cards_and_return_value

    def test_deal_cards_and_return_value(self):
        controller = GameController()
        controller._trump = DurakCard('6H')
        controller._state = controller.States.DEALING
        controller._no_response = False
        controller._discarded = []
        controller._to_move = controller._player1
        controller._player1.cards = {DurakCard('6S'), DurakCard('6H')}
        controller._player2.cards = {DurakCard('7S'), DurakCard('7H')}
        controller._deck = [
            DurakCard('AS'),
            DurakCard('AH'),
            DurakCard('KS'),
            DurakCard('KH'),
            DurakCard('QS'),
            DurakCard('QH'),
            DurakCard('JS'),
            DurakCard('JH'),
            DurakCard('TS'),
            DurakCard('TH'),
        ]
        controller._on_table = Table()
        controller._logger_enabled = False

        return_value = controller.deal()

        self.assertItemsEqual(
            controller._player1.cards, [
                DurakCard('6S'),
                DurakCard('6H'),
                DurakCard('AS'),
                DurakCard('AH'),
                DurakCard('KS'),
                DurakCard('KH'),
            ]
        )
        self.assertItemsEqual(
            controller._player2.cards, [
                DurakCard('7S'),
                DurakCard('7H'),
                DurakCard('QS'),
                DurakCard('QH'),
                DurakCard('JS'),
                DurakCard('JH'),
            ]
        )
        self.assertSequenceEqual(
            controller._deck, [DurakCard('TS'), DurakCard('TH')]
        )
        self.assertDictEqual(return_value, {
            'player1_cards': controller._player1.cards - {DurakCard('6S'), DurakCard('6H')},
            'player2_cards': controller._player2.cards - {DurakCard('7S'), DurakCard('7H')},
        })
開發者ID:drtyrsa,項目名稱:durak,代碼行數:53,代碼來源:tests.py


注:本文中的durak.controller.GameController類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。