Skip to content

Commit

Permalink
Merge pull request #505 from samthom1/UpdateHockeyPositions
Browse files Browse the repository at this point in the history
Update hockey positions
  • Loading branch information
cwendt94 authored Dec 1, 2023
2 parents 5a3bc2e + 018747d commit cff22b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
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
4 changes: 3 additions & 1 deletion espn_api/hockey/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ 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.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'), '')
self.eligibleSlots = [POSITION_MAP.get(pos, '') for pos in json_parsing(data, 'eligibleSlots')]
self.acquisitionType = json_parsing(data, 'acquisitionType')
Expand Down

0 comments on commit cff22b5

Please sign in to comment.