Skip to content

Commit a9799eb

Browse files
committed
Add player.region support.
The player region is generated based on the gateway, subregion pairing.
1 parent 794115b commit a9799eb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

sc2reader/constants.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,17 @@
145145
'232323': 'Dark grey',
146146
'E55BB0': 'Pink'
147147
}
148+
REGIONS = {
149+
'us': {
150+
1: 'us',
151+
2: 'la',
152+
},
153+
'eu': {
154+
1: 'eu',
155+
2: 'ru',
156+
},
157+
'kr': {
158+
1: 'kr',
159+
2: 'tw',
160+
}
161+
}

sc2reader/processors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .objects import *
33
from .utils import key_in_bases, windows_to_unix, Length
44
from datetime import datetime
5+
from .constants import REGIONS
56

67
def Full(replay):
78
# Populate replay with details
@@ -70,7 +71,6 @@ def Full(replay):
7071
# * replay.details
7172
# * replay.attribute.events
7273
#
73-
# TODO: get a map of gateway, subregion# => subregion in here
7474
# TODO: recognize current locale and use that instead of western
7575
# TODO: fill in the LOCALIZED_RACES table
7676
player = Player(pid,pdata.name,replay)
@@ -93,6 +93,7 @@ def Full(replay):
9393
player.type = attributes['Player Type']
9494
player.uid = pdata.bnet.uid
9595
player.subregion = pdata.bnet.subregion
96+
player.region = REGIONS[replay.gateway][player.subregion]
9697
player.handicap = pdata.handicap
9798

9899
# We need initData for the gateway which is required to build the url!

0 commit comments

Comments
 (0)