Skip to content

Commit

Permalink
Change position and lineupSlot
Browse files Browse the repository at this point in the history
Offset lookups for the forward positions to the new POSITION_MAP assignments for the position and lineupSlot since they don't align with the number values in the eligibleSlots fields.
  • Loading branch information
samthom1 authored Nov 20, 2023
1 parent 6e616b0 commit 0bfd824
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')
if json_parsing(data, 'defaultPositionId')>3
else json_parsing(data, 'defaultPositionId')-1, '')
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId')
if 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

0 comments on commit 0bfd824

Please sign in to comment.