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
Push — develop ( a94a27...bcb073 )
by Michael
01:04
created

server.Player.getAddress()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 2
rs 10
1
import weakref
2
3
from enum import IntEnum, unique
4
5
from .abc.base_player import BasePlayer
0 ignored issues
show
Bug introduced by
The name base_player does not seem to exist in module abc.
Loading history...
Configuration introduced by
The import abc.base_player could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
6
7
@unique
8
class PlayerState(IntEnum):
9
    IDLE = 1,
10
    PLAYING = 2,
11
    HOSTING = 3,
12
    JOINING = 4,
13
    SEARCHING_LADDER = 5,
14
15
class Player(BasePlayer):
16
    """
17
    Standard player object used for representing signed-in players.
18
19
    In the context of a game, the Game object holds game-specific
20
    information about players.
21
    """
22
    def __init__(self, login=None, session=0, ip=None, port=None, id=0,
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
23
                 global_rating=None, ladder_rating=None, clan=None, numGames=0, permissionGroup=0, lobby_connection=None):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (122/120).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
24
        super().__init__(id, login)
25
26
        # The id of the user in the `login` table of the database.
27
        self.session = session
28
        self.ip = ip
29
        self._game_port = port
30
31
        if global_rating is None:
32
            global_rating = (1500, 500)
33
        if ladder_rating is None:
34
            ladder_rating = (1500, 500)
35
        self.global_rating = global_rating
36
        self.ladder_rating = ladder_rating
37
38
        #social
39
        self.avatar = None
40
        self.clan = clan
41
        self.country = None
42
43
        self.friends = set()
44
        self.foes = set()
45
46
        self.league = None
47
48
        self.admin = permissionGroup >= 2
49
        self.mod = permissionGroup >= 1
50
        
51
        self.numGames = numGames
52
53
        self.state = PlayerState.IDLE
54
55
        self.expandLadder = 0
56
        self.faction = 1
57
58
        self._lobby_connection = lambda: None
59
        if lobby_connection is not None:
60
            self.lobby_connection = lobby_connection
61
62
        self._game = lambda: None
63
        self._game_connection = lambda: None
64
65
    @property
66
    def lobby_connection(self) -> "LobbyConnection":
67
        """
68
        Weak reference to the LobbyConnection of this player
69
        """
70
        return self._lobby_connection()
71
72
    @lobby_connection.setter
73
    def lobby_connection(self, value: "LobbyConnection"):
74
        self._lobby_connection = weakref.ref(value)
75
76
    @property
77
    def game(self):
78
        """
79
        Weak reference to the Game object that this player wants to join or is currently in
80
        """
81
        return self._game()
82
83
    @game.setter
84
    def game(self, value):
85
        self._game = weakref.ref(value)
86
87
    @game.deleter
88
    def game(self):
89
        self._game = lambda: None
90
91
    @property
92
    def game_connection(self):
93
        """
94
        Weak reference to the GameConnection object for this player
95
        :return:
96
        """
97
        return self._game_connection()
98
99
    @game_connection.setter
100
    def game_connection(self, value):
101
        self._game_connection = weakref.ref(value)
102
103
    @game_connection.deleter
104
    def game_connection(self):
105
        self._game_connection = lambda: None
106
107
    @property
108
    def in_game(self):
109
        return self.game is not None
110
111
    @property
112
    def game_port(self):
113
        return self._game_port or 6112
114
115
    @game_port.setter
116
    def game_port(self, value):
117
        self._game_port = value
118
119
    @property
120
    def address_and_port(self):
121
        return "{}:{}".format(self.ip, self.game_port)
122
123
    def notify_potential_match(self, player, potential):
0 ignored issues
show
Unused Code introduced by
The argument player seems to be unused.
Loading history...
124
        if self.lobby_connection:
125
            self.lobby_connection.sendJSON({
126
                'command': 'matchmaker_info',
127
                'potential': potential
128
            })
129
130
    def to_dict(self):
131
        """
132
        Return a dictionary representing this player object
133
        :return:
134
        """
135
        def filter_none(t):
136
            _, v = t
137
            return v is not None
138
        return dict(filter(filter_none, (
139
            ('id', self.id),
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
140
            ('login', self.login),
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named login.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
141
            ('global_rating', self.global_rating),
142
            ('ladder_rating', self.ladder_rating),
143
            ('number_of_games', self.numGames),
144
            ('avatar', self.avatar),
145
            ('country', self.country),
146
            ('clan', self.clan)
147
        )))
148
149
    def __str__(self):
150
        return "Player({}, {}, {}, {})".format(self.login, self.id, self.global_rating, self.ladder_rating)
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named login.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
151
152
    def __repr__(self):
153
        return self.__str__()
154
155
    def __hash__(self):
156
        return self.id
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
157
158
    def __eq__(self, other):
159
        if not isinstance(other, BasePlayer):
160
            return False
161
        else:
162
            return self.id == other.id
0 ignored issues
show
Bug introduced by
The Instance of Player does not seem to have a member named id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
163