本文整理汇总了Python中durak.controller.GameController._to_move方法的典型用法代码示例。如果您正苦于以下问题:Python GameController._to_move方法的具体用法?Python GameController._to_move怎么用?Python GameController._to_move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类durak.controller.GameController
的用法示例。
在下文中一共展示了GameController._to_move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_move_property
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
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)
示例2: test_is_player1_to_move
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
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())
示例3: test_to_respond
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
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)
示例4: test_register_give_more_is_error_if_player_can_not_give_these_cards
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_give_more_is_error_if_player_can_not_give_these_cards(self):
controller = GameController()
controller._state = controller.States.GIVING_MORE
controller._no_response = True
controller._to_move = controller._player1
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(
cards=(DurakCard('AC'), DurakCard('AH'), DurakCard('6H')),
trump=controller._trump
)
controller._player2.cards = CardSet(
cards=(
DurakCard('7C'),
DurakCard('7H'),
DurakCard('7D'),
DurakCard('7S'),
),
trump=controller._trump
)
controller._on_table = [DurakCard('6D')]
with self.assertRaises(exes.InvalidCard):
controller.register_give_more([
DurakCard('AC'), DurakCard('AH'), DurakCard('6H')
])
示例5: test_game_data_for_public
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [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)
)
示例6: test_successful_register_give_more
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
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)
示例7: test_deal_with_no_response
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [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)
示例8: test_register_response_goes_to_dealing_if_card_is_none_and_mover_has_no_cards
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_response_goes_to_dealing_if_card_is_none_and_mover_has_no_cards(self):
controller = GameController()
controller._state = controller.States.RESPONDING
controller._to_move = controller._player1
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(cards=(), trump=controller._trump)
controller.register_response(None)
self.assertEqual(controller._state, controller.States.DEALING)
self.assertTrue(controller._no_response)
示例9: test_deal_cards_and_return_value
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [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')},
})
示例10: test_register_move_is_error_if_player_does_have_this_card
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_move_is_error_if_player_does_have_this_card(self):
controller = GameController()
controller._state = controller.States.MOVING
controller._to_move = controller._player1
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(
cards=(DurakCard('AC'), DurakCard('AH')), trump=controller._trump
)
controller._on_table = []
with self.assertRaises(exes.PlayerDoesNotHaveCard):
controller.register_move(DurakCard('6D'))
示例11: test_register_response_is_error_if_player_can_not_add_this_card
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_response_is_error_if_player_can_not_add_this_card(self):
controller = GameController()
controller._state = controller.States.RESPONDING
controller._to_move = controller._player2
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(
cards=(DurakCard('AC'), DurakCard('AH')), trump=controller._trump
)
controller._on_table = [DurakCard('6D')]
with self.assertRaises(exes.InvalidCard):
controller.register_response(DurakCard('AC'))
示例12: test_check_for_game_over_does_nothing_if_responder_can_beat_with_last_card
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_check_for_game_over_does_nothing_if_responder_can_beat_with_last_card(self):
controller = GameController()
controller._state = controller.States.RESPONDING
controller._deck = []
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(cards=(), trump=controller._trump)
controller._player2.cards = CardSet(
cards=(DurakCard('KD'),), trump=controller._trump
)
controller._to_move = controller._player1
controller._on_table = [DurakCard('QD')]
controller._check_for_game_over()
self.assertEqual(controller._state, controller.States.RESPONDING)
示例13: test_register_response_goes_to_giving_more_if_card_is_none
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_response_goes_to_giving_more_if_card_is_none(self):
controller = GameController()
controller._state = controller.States.RESPONDING
controller._to_move = controller._player1
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(
cards=(DurakCard('AC'),), trump=controller._trump
)
controller.register_response(None)
self.assertEqual(controller._state, controller.States.GIVING_MORE)
self.assertTrue(controller._no_response)
示例14: test_register_response_not_allows_moving_if_moving_has_no_cards
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_response_not_allows_moving_if_moving_has_no_cards(self):
controller = GameController()
controller._state = controller.States.RESPONDING
controller._to_move = controller._player2
controller._trump = DurakCard('6H')
controller._deck = [DurakCard('JH')]
controller._player1.cards = CardSet(
cards=(DurakCard('AC'), DurakCard('AH')), trump=controller._trump
)
controller._player2.cards = CardSet(cards=(), trump=controller._trump)
controller._on_table = [DurakCard('6D')]
controller.register_response(DurakCard('AH'))
self.assertEqual(controller.state, controller.States.DEALING)
示例15: test_register_give_more_is_error_if_max_count_is_exceeded
# 需要导入模块: from durak.controller import GameController [as 别名]
# 或者: from durak.controller.GameController import _to_move [as 别名]
def test_register_give_more_is_error_if_max_count_is_exceeded(self):
controller = GameController()
controller._state = controller.States.GIVING_MORE
controller._no_response = True
controller._to_move = controller._player1
controller._trump = DurakCard('6H')
controller._player1.cards = CardSet(
cards=(DurakCard('AC'), DurakCard('AH')), trump=controller._trump
)
controller._player2.cards = CardSet(
cards=(DurakCard('7C'),), trump=controller._trump
)
controller._on_table = [DurakCard('6D')]
with self.assertRaises(exes.TooMuchGiveMoreCards):
controller.register_give_more([DurakCard('6S'), DurakCard('6H')])