Total Complexity | 10 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from abc import ABCMeta |
||
8 | class BasePlayer: |
||
9 | """ |
||
10 | Abstract base class for players |
||
11 | """ |
||
12 | __metaclass__ = ABCMeta |
||
13 | |||
14 | def __init__(self, id, login): |
||
15 | self._faction = 0 |
||
16 | self._global_rating = (1500, 500) |
||
17 | self._ladder_rating = (1500, 500) |
||
18 | |||
19 | self.id = id |
||
20 | self.login = login |
||
21 | |||
22 | @property |
||
23 | def global_rating(self): |
||
24 | return self._global_rating |
||
25 | |||
26 | @global_rating.setter |
||
27 | def global_rating(self, value: Rating): |
||
28 | if isinstance(value, Rating): |
||
29 | self._global_rating = (value.mu, value.sigma) |
||
30 | else: |
||
31 | self._global_rating = value |
||
32 | |||
33 | @property |
||
34 | def ladder_rating(self): |
||
35 | return self._ladder_rating |
||
36 | |||
37 | @ladder_rating.setter |
||
38 | def ladder_rating(self, value: Rating): |
||
39 | if isinstance(value, Rating): |
||
40 | self._ladder_rating = (value.mu, value.sigma) |
||
41 | else: |
||
42 | self._ladder_rating = value |
||
43 | |||
44 | @property |
||
45 | def faction(self): |
||
46 | return self._faction |
||
47 | |||
48 | @faction.setter |
||
49 | def faction(self, value): |
||
50 | if isinstance(value, str): |
||
51 | self._faction = Faction.from_string(value) |
||
52 | else: |
||
53 | self._faction = value |
||
54 |