Пример #1
0
 def test_game_computer_turn_cant_move(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 2, game.ky)] = Computer_checkers(game.kx * 2,
                                                              game.ky,
                                                              game.kx,
                                                              (255, 0, 0))
     game.objects[(game.kx * 2, game.ky * 3)] = Player_checkers(game.kx * 2,
                                                                game.ky * 3,
                                                                game.kx,
                                                                (0, 0, 0))
     game.objects[(game.kx * 2, game.ky * 5)] = Player_checkers(game.kx * 2,
                                                                game.ky * 5,
                                                                game.kx,
                                                                (0, 0, 0))
     game.objects[(game.kx * 5, game.ky * 2)] = Player_checkers(game.kx * 5,
                                                                game.ky * 2,
                                                                game.kx,
                                                                (0, 0, 0))
     game.objects[(game.kx * 8, game.ky * 3)] = Player_checkers(game.kx * 8,
                                                                game.ky * 3,
                                                                game.kx,
                                                                (0, 0, 0))
     game.computer_turn()
     self.assertTrue(game.objects[(game.kx * 2, game.ky)] is not None)
Пример #2
0
 def test_game_run_heroku(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.player_c = 1
     game.computer_c = 1
     game.objects[(game.kx * 5, game.ky * 4)] = Player_checkers(game.kx * 5,
                                                                game.ky * 4,
                                                                game.kx,
                                                                (0, 0, 0))
     game.objects[(game.kx * 8, game.ky)] = Computer_checkers(game.kx * 8,
                                                              game.ky,
                                                              game.kx,
                                                              (255, 0, 0))
     game.handle_mouse_down((game.kx * 5, game.ky * 4))
     game.handle_events = MagicMock(
         return_value=game.handle_mouse_down((game.kx * 5, game.ky * 2)))
     conf = dict()
     conf['0'] = str(775 - game.kx * 8) + '-' + str(
         800 - game.ky) + '-' + str(
         775 - game.kx * 2) + '-' + str(800 - game.ky * 3) + '-0'
     game.get_config = MagicMock(return_value=conf)
     game.run_heroku()
     self.assertTrue(True)
Пример #3
0
 def test_game_computer_turn_move_checker_become_king(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 5, game.ky * 18)] = Computer_checkers(
         game.kx * 5, game.ky * 18, game.kx, (255, 0, 0))
     game.computer_turn()
     game.computer_turn()
     game.computer_turn()
     self.assertTrue(True)
Пример #4
0
 def test_game_handle_mouse_down_get_active_checker(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 2, game.ky)] = Player_checkers(game.kx * 2,
                                                            game.ky,
                                                            game.kx,
                                                            (0, 0, 0))
     game.handle_mouse_down((game.kx * 2, game.ky))
     self.assertEqual(game.active_checker,
                      game.objects.get((game.kx * 2, game.ky)))
Пример #5
0
 def test_game_computer_turn_move_and_eat_checker_up_right(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 2, game.ky * 5)] = Computer_checkers(
         game.kx * 2, game.ky * 5, game.kx, (255, 0, 0))
     game.objects[(game.kx * 5, game.ky * 4)] = Player_checkers(game.kx * 5,
                                                                game.ky * 4,
                                                                game.kx,
                                                                (0, 0, 0))
     game.computer_turn()
     self.assertTrue(game.objects[(game.kx * 5, game.ky * 4)] is None)
Пример #6
0
 def test_game_computer_turn_move_and_eat_checker_down_left_king(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 8, game.ky * 3)] = Computer_checkers(
         game.kx * 8, game.ky * 3, game.kx, (255, 0, 0))
     game.objects[(game.kx * 8, game.ky * 3)].checkers_type = "king"
     game.objects[(game.kx * 5, game.ky * 4)] = Player_checkers(game.kx * 5,
                                                                game.ky * 4,
                                                                game.kx,
                                                                (0, 0, 0))
     game.computer_turn()
     self.assertTrue(game.objects[(game.kx * 5, game.ky * 4)] is None)
Пример #7
0
 def test_game_handle_mouse_down_move_checker_up_right(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 5, game.ky * 4)] = Player_checkers(game.kx * 5,
                                                                game.ky * 4,
                                                                game.kx,
                                                                (0, 0, 0))
     game.handle_mouse_down((game.kx * 5, game.ky * 4))
     game.handle_mouse_down((game.kx * 8, game.ky * 3))
     self.assertEqual(game.active_checker, None)
     game.handle_mouse_down((game.kx * 8, game.ky * 3))
     self.assertEqual(game.active_checker,
                      game.objects.get((game.kx * 8, game.ky * 3)))
Пример #8
0
 def test_game_run_computer(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.player_c = 1
     game.computer_c = 1
     game.objects[(game.kx * 5, game.ky * 2)] = Computer_checkers(
         game.kx * 5, game.ky * 2, game.kx, (255, 0, 0))
     game.objects[(game.kx * 5, game.ky * 4)] = Player_checkers(game.kx * 5,
                                                                game.ky * 4,
                                                                game.kx,
                                                                (0, 0, 0))
     game.turn = "Computer"
     game.run_computer()
     self.assertTrue(True)
Пример #9
0
 def test_game_computer_turn_move_checker(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 5, game.ky * 2)] = Computer_checkers(
         game.kx * 5, game.ky * 2, game.kx, (255, 0, 0))
     game.objects[(game.kx * 5, game.ky * 6)] = Player_checkers(game.kx * 5,
                                                                game.ky * 6,
                                                                game.kx,
                                                                (0, 0, 0))
     game.objects[(game.kx * 5, game.ky * 8)] = Player_checkers(game.kx * 5,
                                                                game.ky * 8,
                                                                game.kx,
                                                                (0, 0, 0))
     game.computer_turn()
     game.computer_turn()
     self.assertEqual(None, game.objects.get((game.kx * 5, game.ky * 4)))
Пример #10
0
 def test_game_handle_mouse_down_move_and_eat_checker_up_right_king(self):
     x_size = 775
     y_size = 800
     game = Game("Checkers 100", x_size, y_size, "1.png", 120)
     game.objects = dict()
     game.objects[(game.kx * 2, game.ky * 5)] = Player_checkers(game.kx * 2,
                                                                game.ky * 5,
                                                                game.kx,
                                                                (0, 0, 0))
     game.objects[(game.kx * 2, game.ky * 5)].checkers_type = "king"
     game.objects[(game.kx * 5, game.ky * 4)] = Computer_checkers(
         game.kx * 5, game.ky * 4, game.kx, (255, 0, 0))
     game.handle_mouse_down((game.kx * 2, game.ky * 5))
     game.handle_mouse_down((game.kx * 8, game.ky * 3))
     self.assertEqual(game.active_checker, None)
     game.handle_mouse_down((game.kx * 8, game.ky * 3))
     self.assertEqual(game.active_checker,
                      game.objects.get((game.kx * 8, game.ky * 3)))