Example #1
0
    def test_if_try_to_jump_over_enemy_figure(self):

        board = ChessBoard()
        testBoard = [['br', 'bn', 'bb', 'bq', 'bk', 'bb', 'bn', 'br'],
                     ['bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp', '  '],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  '],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', 'bp'],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', 'wr'],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  '],
                     ['wp', 'wp', 'wp', 'wp', 'wp', 'wp', 'wp', '  '],
                     ['wr', 'wn', 'wb', 'wq', 'wk', 'wb', 'wn', '  ']]

        set_board(board, testBoard)

        selected_figure = Point(7, 4, "wr")
        final_position = Point(7, 0)

        next_cell_while_moving = Point(7, 3)

        motion = board._make_motion(selected_figure, final_position)

        step_x, step_y = board._set_step_to_move(motion)
        prepare_moving = Point(step_x, step_y)

        self.assertTrue(board._try_jump_enemy(
            next_cell_while_moving, selected_figure, prepare_moving, motion))
Example #2
0
    def test_waiting_to_make_a_full_turn(self):

        board = ChessBoard()
        testBoard = [['br', 'bn', 'bb', 'bq', 'bk', 'bb', 'bn', 'br'],
                     ['bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp'],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  '],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  '],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  '],
                     ['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  '],
                     ['wp', 'wp', 'wp', 'wp', 'wp', 'wp', 'wp', '  '],
                     ['wr', 'wn', 'wb', 'wq', 'wk', 'wb', 'wn', 'wr']]

        set_board(board, testBoard)

        selected_figure = Point(7, 7, "wr")
        final_position = Point(7, 3)
        motion = board._make_motion(selected_figure, final_position)

        step_x, step_y = board._set_step_to_move(motion)
        prepare_moving = Point(step_x, step_y)

        self.assertTrue(
            board.waiting_to_finish_this_turn(prepare_moving, motion))