GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#14)
by Theo
01:55
created

directional()   A

Complexity

Conditions 3

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
c 1
b 0
f 1
dl 0
loc 2
rs 10
ccs 2
cts 2
cp 1
crap 3
1
# pylint: disable=W0613
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
# allow unused variables so all movement functions can have same parameter definition
3 1
import operator
4
5
6 1
def get_all_potential_end_locations(start, directions, board):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
7 1
    ends = []
8 1
    for direction in directions:
9 1
        new_start = start
10 1
        location = tuple(map(operator.add, new_start, direction))
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
11 1
        while location in board:
12 1
            ends.append(location)
13 1
            new_start = location
14 1
            location = tuple(map(operator.add, new_start, direction))
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
15 1
    return ends
16
17
18 1
def distance_of_one(board, start, directions, potential_end_locations, player_direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
19 1
    return [x for x in get_one_move_away(start, directions) if x in potential_end_locations]
20
21
22 1
def get_one_move_away(start, directions):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
23 1
    ret_val = [tuple(map(operator.add, move, start)) for move in directions]
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
24 1
    return ret_val
25
26
27 1
def cant_jump_pieces(board, start, directions, potential_end_locations, player_directionv):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
28 1
    end_locations = potential_end_locations
29 1
    for location in potential_end_locations:
30
        # get a direction from start
31
        # remove all locations beyond location
32 1
        direction = tuple(map(operator.sub, location, start))
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
33 1
        dividor = max(map(abs, direction))
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
34 1
        direction = tuple(map(operator.floordiv, direction, (dividor, dividor)))
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
35 1
        location_to_remove = start
36 1
        found_piece = False
37 1
        print("start: {}".format(start))
38 1
        print("direction: {}".format(direction))
39 1
        print("location: {}".format(location))
40 1
        while True:
41 1
            location_to_remove = tuple(map(operator.add, location_to_remove, direction))
0 ignored issues
show
introduced by
Used builtin function 'map'
Loading history...
42 1
            if not found_piece and board[location_to_remove]:
43 1
                found_piece = True
44 1
                print("{} has a piece".format(location_to_remove))
45 1
            elif location_to_remove in end_locations and found_piece:
46 1
                print("removing {} from board".format(location_to_remove))
47 1
                end_locations.remove(location_to_remove)
48 1
            elif location_to_remove not in board:
49
                # import pdb
50
                # pdb.set_trace()
51 1
                print("{} not in board".format(location_to_remove))
52 1
                break
53
            else:
54 1
                print("floating somehwere {}".format(location_to_remove))
55 1
                print("had found piece: {}".format(found_piece))
56 1
                print("in potential_end_locations: {}".format(location_to_remove in potential_end_locations))
57 1
                print("in else: {}".format(potential_end_locations))
58 1
    return end_locations
59
60
61 1
def doesnt_land_on_own_piece(board, start, directions, potential_end_locations, player_direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
62 1
    ends = []
63 1
    for end in potential_end_locations:
64 1
        if board[end]:
65 1
            if board[start].color != board[end].color:
66 1
                ends.append(end)
67
        else:
68 1
            ends.append(end)
69 1
    return ends
70
71
72 1
def doesnt_land_on_piece(board, start, directions, potential_end_locations, player_direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
73 1
    return [end for end in potential_end_locations if not board[end]]
74
75
76 1
def ends_on_enemy(board, start, directions, potential_end_locations, player_direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
77 1
    ends = []
78 1
    for end in potential_end_locations:
79 1
        if board[end] is not None and board[end].color != board[start].color:
80 1
            ends.append(end)
81 1
    return ends
82
83
84 1
def directional(board, start, directions, potential_end_locations, player_direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
85 1
    return [end for end in potential_end_locations if is_directional(start, end, player_direction)]
86
87
88 1
def is_directional(start, end, direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
89 1
    direct = True
90 1
    direct = direct and _directional_helper(start[0], end[0], direction[0])
91 1
    direct = direct and _directional_helper(start[1], end[1], direction[1])
92 1
    return direct
93
94
95 1
def _directional_helper(start, end, direct):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
96 1
    if direct > 0:
97 1
        if end < start:
98 1
            return False
99 1
    elif direct < 0:
100 1
        if end > start:
101 1
            return False
102 1
    return True
103
104
105 1
def first_move(board, start, directions, potential_end_locations, player_direction):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
106
    return potential_end_locations if board[start].move_count == 0 else []
107