Skip to content

Commit

Permalink
Update player.py
Browse files Browse the repository at this point in the history
Shift position & lineupSlot lookups by one to account for incongruency with the position keys in the eligibleSlots field.
  • Loading branch information
samthom1 authored Nov 21, 2023
1 parent 3922a29 commit 7f52448
Showing 1 changed file with 6 additions and 2 deletions.
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') - 1
if json_parsing(data, 'defaultPositionId') and json_parsing(data, 'defaultPositionId') <= 3
else json_parsing(data, 'defaultPositionId'), '')
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId') - 1
if data.get('lineupSlotId') and data.get('lineupSlotId') <= 3
else data.get('lineupSlotId'), '')
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

0 comments on commit 7f52448

Please sign in to comment.