コード例 #1
0
 def test_rule_game(self):
     controller1 = GameController([RulePlayer() for _ in range(4)], CardDeck(0))
     controller1.play()
     self.assertEqual(controller1.game.current_action, GameAction.GAME_OVER)
     for r in controller1.game.rounds:
         is_game_json_valid(game_to_json(r))
     controller2 = GameController([RulePlayer() for _ in range(4)], CardDeck(0))
     controller2.play()
     self.__check_two_games_equal(controller1.game, controller2.game)
コード例 #2
0
 def test_json_to_game_simple(self):
     json_str = '{"players": [{"index": 0, "order": 0, "hand": [1, 11, 5, 10, 25], "dropped_card": null}, ' \
           '{"index": 1, "order": 1, "hand": [26, 16, 20, 13, 29], "dropped_card": null}, ' \
           '{"index": 2, "order": 2, "hand": [9, 27, 24, 12, 3], "dropped_card": null}, ' \
           '{"index": 3, "order": 3, "hand": [0, 2, 18, 19, 17], "dropped_card": null}], ' \
           '"deck": [28, 4, 8, 21], "tricks": [], "trump_caller": null, "trump": null}'
     f_round = json_to_game(json_str)
     json_str2 = game_to_json(f_round)
     self.assertEqual(json_str, json_str2)
     is_game_json_valid(json_str2)
コード例 #3
0
 def test_game_to_json_simple(self):
     cards = CardDeck().deal_cards()
     players = [PlayerCards(i, i, cards[i]) for i in range(4)]
     game = Round(players, cards[4])
     json_game_str = game_to_json(game)
     is_game_json_valid(json_game_str)
コード例 #4
0
 def test_web_player(self):
     controller = GameController([RandomPlayer(0) for _ in range(4)], CardDeck(0))
     controller.play()
     self.assertEqual(controller.game.current_action, GameAction.GAME_OVER)
     for r in controller.game.rounds:
         is_game_json_valid(game_to_json(r))