Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hockey position update #504

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions espn_api/hockey/constant.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#Constants
POSITION_MAP = {
# Remaining: F, IR, Util
0 : '0' # IR?
, 1 : 'Center'
, 2 : 'Left Wing'
, 3 : 'Right Wing'
0 : 'Center'
, 1 : 'Left Wing'
, 2 : 'Right Wing'
, 3 : 'Forward'
, 4 : 'Defense'
, 5 : 'Goalie'
, 6 : '6' # Forward ?
, 7 : '7' # Goalie, F (Goalie Bench?)
, 8 : '8' # Goalie, F
, 'Center': 1
, 'Left Wing' : 2
, 'Right Wing' : 3
, 6 : 'Util'
, 7 : 'Bench'
, 8 : 'IR'
, 'Center': 0
, 'Left Wing' : 1
, 'Right Wing' : 2
, 'Forward' : 3
, 'Defense' : 4
, 'Goalie' : 5
, 'Util' : 6
, 'Bench' : 7
, 'IR' : 8
}

STATS_IDENTIFIER = {
Expand Down
8 changes: 6 additions & 2 deletions espn_api/hockey/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ class Player(object):
def __init__(self, data):
self.name = json_parsing(data, 'fullName')
self.playerId = json_parsing(data, 'id')
self.position = POSITION_MAP.get(json_parsing(data, 'defaultPositionId'), '')
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId'), '')
self.position = POSITION_MAP.get(json_parsing(data, 'defaultPositionId')
if json_parsing(data, 'defaultPositionId') and json_parsing(data, 'defaultPositionId') > 3
else json_parsing(data, 'defaultPositionId')-1, '')
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId')
if data.get('lineupSlotId') and data.get('lineupSlotId') > 3
else data.get('lineupSlotId')-1, '')
self.eligibleSlots = [POSITION_MAP.get(pos, '') for pos in json_parsing(data, 'eligibleSlots')]
self.acquisitionType = json_parsing(data, 'acquisitionType')
self.proTeam = PRO_TEAM_MAP.get(json_parsing(data, 'proTeamId'), 'Unknown Team')
Expand Down
Loading