-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathplayer.py
More file actions
33 lines (28 loc) · 891 Bytes
/
player.py
File metadata and controls
33 lines (28 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from json import JSONEncoder
class Player():
"""
Represents a player
"""
def __init__(self, item):
details = item['player'] # this is the original dictionary
self.playerid = details['id']
self.displayName = details['commonName'] if details['commonName'] is not '' else details['lastName']
self.position = details['position']
self.rating = details['rating']
self.details = details
self.maxBuy = item['buy']
self.sell = item['sell']
self.bin = item['bin']
try:
self.enabled = item['enabled']
except:
self.enabled = 'yes'
class PlayerEncoder(JSONEncoder):
def default(self, o):
return {
'buy' : o.maxBuy,
'sell': o.sell,
'bin' : o.bin,
'enabled': o.enabled,
'player' : o.details
}