当前位置: 首页>>代码示例>>Python>>正文


Python GameController._discarded方法代码示例

本文整理汇总了Python中durak.controller.GameController._discarded方法的典型用法代码示例。如果您正苦于以下问题:Python GameController._discarded方法的具体用法?Python GameController._discarded怎么用?Python GameController._discarded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在durak.controller.GameController的用法示例。


在下文中一共展示了GameController._discarded方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deal_with_no_response

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
    def test_deal_with_no_response(self):
        controller = GameController()
        controller._trump = DurakCard('6H')
        controller._state = controller.States.DEALING
        controller._no_response = True
        controller._discarded = []
        controller._to_move = controller._player1
        controller._player1.cards = {DurakCard('JH')}
        controller._player2.cards = set()
        controller._deck = []
        controller._on_table = Table([DurakCard('6S'), DurakCard('6H')])
        controller._on_table.given_more = {DurakCard('7S'), DurakCard('7H')}
        controller._logger_enabled = False

        controller.deal()

        self.assertItemsEqual(
            controller._player2.cards,
            {
                DurakCard('6S'),
                DurakCard('6H'),
                DurakCard('7S'),
                DurakCard('7H')
            }
        )
        self.assertFalse(controller._no_response)
        self.assertEqual(controller._to_move, controller._player1)
        self.assertEqual(controller._state, controller.States.MOVING)
开发者ID:drtyrsa,项目名称:durak,代码行数:30,代码来源:tests.py

示例2: test_game_data_for_public

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
 def test_game_data_for_public(self):
     controller = GameController()
     controller._trump = DurakCard('6H')
     controller._deck = [DurakCard('7S'), DurakCard('8D')]
     controller._on_table = [DurakCard('9C'), DurakCard('TH')]
     controller._discarded = [DurakCard('JD'), DurakCard('QS')]
     controller._player1.cards = CardSet(
         cards=(DurakCard('AC'), DurakCard('8S'), DurakCard('KS')),
         trump=controller._trump
     )
     controller._player2.cards = CardSet(
         cards=(DurakCard('KD'),), trump=controller._trump
     )
     controller._to_move = controller._player1
     self.assertDictEqual(
         controller.get_game_data_for(controller.PLAYER1),
         controller._get_game_data_for(controller._player1)
     )
     self.assertDictEqual(
         controller.get_game_data_for(controller.PLAYER2),
         controller._get_game_data_for(controller._player2)
     )
     self.assertDictEqual(
         controller.get_game_data_for(controller.MOVER),
         controller._get_game_data_for(controller._player1)
     )
     self.assertDictEqual(
         controller.get_game_data_for(controller.RESPONDER),
         controller._get_game_data_for(controller._player2)
     )
开发者ID:drtyrsa,项目名称:durak,代码行数:32,代码来源:tests.py

示例3: test_game_data_for_private

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
 def test_game_data_for_private(self):
     controller = GameController()
     controller._trump = DurakCard('6H')
     controller._deck = [DurakCard('7S'), DurakCard('8D')]
     controller._on_table = [DurakCard('9C'), DurakCard('TH')]
     controller._discarded = [DurakCard('JD'), DurakCard('QS')]
     controller._player1.cards = CardSet(
         cards=(DurakCard('AC'), DurakCard('8S'), DurakCard('KS')),
         trump=controller._trump
     )
     controller._player2.cards = CardSet(
         cards=(DurakCard('KD'),), trump=controller._trump
     )
     self.assertDictEqual(
         controller._get_game_data_for(controller._player1), {
             'trump': str(controller._trump),
             'deck_count': len(controller._deck),
             'enemy_count': len(controller._player2.cards),
             'on_table': map(str, controller._on_table),
             'discarded': map(str, controller._discarded),
         }
     )
     self.assertDictEqual(
         controller._get_game_data_for(controller._player2), {
             'trump': str(controller._trump),
             'deck_count': len(controller._deck),
             'enemy_count': len(controller._player1.cards),
             'on_table': map(str, controller._on_table),
             'discarded': map(str, controller._discarded),
         }
     )
开发者ID:drtyrsa,项目名称:durak,代码行数:33,代码来源:tests.py

示例4: test_deal_cards_and_return_value

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
    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,代码行数:55,代码来源:tests.py

示例5: test_deal_clears_the_table

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
    def test_deal_clears_the_table(self):
        controller = GameController()
        controller._trump = DurakCard('6H')
        controller._state = controller.States.DEALING
        controller._no_response = True
        controller._discarded = []
        controller._to_move = controller._player1
        controller._player1.cards = set()
        controller._player2.cards = set()
        controller._deck = []
        controller._on_table = Table([DurakCard('6S'), DurakCard('6H')])
        controller._on_table.given_more = {DurakCard('7S'), DurakCard('7H')}
        controller._logger_enabled = False

        controller.deal()

        self.assertSequenceEqual(controller._on_table, [])
        self.assertItemsEqual(controller._on_table.given_more, set())
开发者ID:drtyrsa,项目名称:durak,代码行数:20,代码来源:tests.py

示例6: test_deal_no_cards_needed

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
    def test_deal_no_cards_needed(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'),
            DurakCard('8S'),
            DurakCard('8H'),
            DurakCard('9S'),
            DurakCard('9H')
        }
        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

        controller.deal()

        self.assertItemsEqual(
            controller._player1.cards, {
                DurakCard('6S'),
                DurakCard('6H'),
                DurakCard('8S'),
                DurakCard('8H'),
                DurakCard('9S'),
                DurakCard('9H')
            }
        )
开发者ID:drtyrsa,项目名称:durak,代码行数:45,代码来源:tests.py

示例7: test_deal_with_response

# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _discarded [as 别名]
    def test_deal_with_response(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('JH')}
        controller._player2.cards = {DurakCard('JS')}
        controller._deck = []
        controller._on_table = Table([DurakCard('6S'), DurakCard('6H')])
        controller._logger_enabled = False

        controller.deal()

        self.assertSequenceEqual(
            controller._discarded, [DurakCard('6S'), DurakCard('6H')]
        )
        self.assertEqual(controller._to_move, controller._player2)
        self.assertEqual(controller._state, controller.States.MOVING)
开发者ID:drtyrsa,项目名称:durak,代码行数:22,代码来源:tests.py


注:本文中的durak.controller.GameController._discarded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。