def load_player_info(self): team_num_prop = self.team_num_prop() # Parse player structs, 16 is the maximum amount of players for i in range(16): # Check if player, skip if not if self.parts[0][3][i][2] == '\x00\x00\x00\x00': continue player_struct = self.parts[0][3][i] player = PlayerSummary(player_struct[0][0]) player.race = RACE_CODES[''.join(reversed(player_struct[2]))] teamnumstring = self.player_props[player.pid][team_num_prop] player.teamid = int( teamnumstring.replace("\x00", "").replace("T", "")) player.is_winner = (player_struct[1][0] == 0) if player.is_winner: self.winners.append(player.pid) # Is the player an ai? if type(player_struct[0][1]) == type(int()): player.is_ai = True else: player.is_ai = False player.bnetid = player_struct[0][1][0][3] player.subregion = player_struct[0][1][0][2] # int player.unknown1 = player_struct[0][1][0] # {0:long1, 1:long2} # Example: # { 0: 3405691582L, 1: 11402158793782460416L} player.unknown2 = player_struct[0][1][1] self.players.append(player) self.player[player.pid] = player if not player.teamid in self.teams: self.team[player.teamid] = list() self.team[player.teamid].append(player.pid) self.teams = [self.team[tid] for tid in sorted(self.team.keys())]
def load_player_info(self): team_num_prop = self.team_num_prop() # Parse player structs, 16 is the maximum amount of players for i in range(16): # Check if player, skip if not if self.parts[0][3][i][2] == '\x00\x00\x00\x00': continue player_struct = self.parts[0][3][i] player = PlayerSummary(player_struct[0][0]) player.race = RACE_CODES[''.join(reversed(player_struct[2]))] teamnumstring = self.player_props[player.pid][team_num_prop] player.teamid = int(teamnumstring.replace("\x00","").replace("T","")) player.is_winner = (player_struct[1][0] == 0) if player.is_winner: self.winners.append(player.pid) # Is the player an ai? if type(player_struct[0][1]) == type(int()): player.is_ai = True else: player.is_ai = False player.bnetid = player_struct[0][1][0][3] player.subregion = player_struct[0][1][0][2] # int player.unknown1 = player_struct[0][1][0] # {0:long1, 1:long2} # Example: # { 0: 3405691582L, 1: 11402158793782460416L} player.unknown2 = player_struct[0][1][1] self.players.append(player) self.player[player.pid] = player if not player.teamid in self.teams: self.team[player.teamid] = list() self.team[player.teamid].append(player.pid) self.teams = [self.team[tid] for tid in sorted(self.team.keys())]
def load_player_info(self): # Parse player structs, 16 is the maximum amount of players for i in range(16): # Check if player, skip if not if self.parts[0][3][i][2] == '\x00\x00\x00\x00': continue player_struct = self.parts[0][3][i] player = PlayerSummary(player_struct[0][0]) player.race = RACE_CODES[''.join(reversed(player_struct[2]))] # TODO: Grab team id from lobby_player_properties player.teamid = 0 player.is_winner = (player_struct[1][0] == 0) if player.is_winner: self.winners.append(player.pid) # Is the player an ai? if type(player_struct[0][1]) == type(int()): player.is_ai = True else: player.is_ai = False player.bnetid = player_struct[0][1][0][3] player.subregion = player_struct[0][1][0][2] # int player.unknown1 = player_struct[0][1][0] # {0:long1, 1:long2} # Example: # { 0: 3405691582L, 1: 11402158793782460416L} player.unknown2 = player_struct[0][1][1] self.players.append(player) self.player[player.pid] = player if not player.teamid in self.teams: self.team[player.teamid] = list() self.team[player.teamid].append(player.pid)
def load_players(self): for index, struct in enumerate(self.parts[0][3]): if not struct[0] or not struct[0][1]: continue # Slot is closed player = PlayerSummary(struct[0][0]) stats = self.player_stats.get(index, dict()) settings = self.player_settings[index] player.is_ai = not isinstance(struct[0][1], dict) if not player.is_ai: player.gateway = self.gateway player.subregion = struct[0][1][0][2] player.region = REGIONS[player.gateway].get( player.subregion, 'Unknown') player.bnetid = struct[0][1][0][3] player.unknown1 = struct[0][1][0] player.unknown2 = struct[0][1][1] # Either a referee or a spectator, nothing else to do if settings.get('Participant Role', '') != 'Participant': self.observers.append(player) continue player.play_race = LOBBY_PROPERTIES[0xBB9][1].get(struct[2], None) player.is_winner = isinstance(struct[1], dict) and struct[1][0] == 0 if player.is_winner: self.winners.append(player.pid) team_id = int(settings['Team'].split(' ')[1]) if team_id not in self.team: self.team[team_id] = Team(team_id) self.teams.append(self.team[team_id]) player.team = self.team[team_id] self.team[team_id].players.append(player) # We can just copy these settings right over player.color = utils.Color(name=settings.get('Color', None)) player.pick_race = settings.get('Race', None) player.handicap = settings.get('Handicap', None) # Overview Tab player.resource_score = stats.get('Resources', None) player.structure_score = stats.get('Structures', None) player.unit_score = stats.get('Units', None) player.overview_score = stats.get('Overview', None) # Units Tab player.units_killed = stats.get('Killed Unit Count', None) player.structures_built = stats.get('Structures Built', None) player.units_trained = stats.get('Units Trained', None) player.structures_razed = stats.get('Structures Razed Count', None) # Graphs Tab # Keep income_graph for backwards compatibility player.army_graph = stats.get('Army Value') player.resource_collection_graph = stats.get( 'Resource Collection Rate', None) player.income_graph = player.resource_collection_graph # HotS Stats player.upgrade_spending_graph = stats.get('Upgrade Spending', None) player.workers_active_graph = stats.get('Workers Active', None) player.enemies_destroyed = stats.get('Enemies Destroyed:', None) player.time_supply_capped = stats.get('Time Supply Capped', None) player.idle_production_time = stats.get('Idle Production Time', None) player.resources_spent = stats.get('Resources Spent:', None) player.apm = stats.get('APM', None) # Economic Breakdown Tab if isinstance(player.income_graph, Graph): values = player.income_graph.values player.resource_collection_rate = int( sum(values) / len(values)) else: # In old s2gs files the field with this name was actually a number not a graph player.resource_collection_rate = player.income_graph player.resource_collection_graph = None player.income_graph = None player.avg_unspent_resources = stats.get( 'Average Unspent Resources', None) player.workers_created = stats.get('Workers Created', None) # Build Orders Tab player.build_order = self.build_orders.get(index, None) self.players.append(player) self.player[player.pid] = player
def load_players(self): for index, struct in enumerate(self.parts[0][3]): if not struct[0] or not struct[0][1]: continue # Slot is closed player = PlayerSummary(struct[0][0]) stats = self.player_stats.get(index, dict()) settings = self.player_settings[index] player.is_ai = not isinstance(struct[0][1], dict) if not player.is_ai: player.region = self.region player.subregion = struct[0][1][0][2] player.bnetid = struct[0][1][0][3] player.unknown1 = struct[0][1][0] player.unknown2 = struct[0][1][1] # Either a referee or a spectator, nothing else to do if settings.get('Participant Role', '') != 'Participant': self.observers.append(player) continue player.play_race = LOBBY_PROPERTIES[0xBB9][1].get(struct[2], None) player.is_winner = isinstance(struct[1], dict) and struct[1][0] == 0 if player.is_winner: self.winners.append(player.pid) team_id = int(settings['Team'].split(' ')[1]) if team_id not in self.team: self.team[team_id] = Team(team_id) self.teams.append(self.team[team_id]) player.team = self.team[team_id] self.team[team_id].players.append(player) # We can just copy these settings right over player.color = utils.Color(name=settings.get('Color', None)) player.pick_race = settings.get('Race', None) player.handicap = settings.get('Handicap', None) # Overview Tab player.resource_score = stats.get('Resources', None) player.structure_score = stats.get('Structures', None) player.unit_score = stats.get('Units', None) player.overview_score = stats.get('Overview', None) # Units Tab player.units_killed = stats.get('Killed Unit Count', None) player.structures_built = stats.get('Structures Built', None) player.units_trained = stats.get('Units Trained', None) player.structures_razed = stats.get('Structures Razed Count', None) # Graphs Tab # Keep income_graph for backwards compatibility player.army_graph = stats.get('Army Value') player.resource_collection_graph = stats.get('Resource Collection Rate', None) player.income_graph = player.resource_collection_graph # HotS Stats player.upgrade_spending_graph = stats.get('Upgrade Spending', None) player.workers_active_graph = stats.get('Workers Active', None) player.enemies_destroyed = stats.get('Enemies Destroyed:', None) player.time_supply_capped = stats.get('Time Supply Capped', None) player.idle_production_time = stats.get('Idle Production Time', None) player.resources_spent = stats.get('Resources Spent:', None) player.apm = stats.get('APM', None) # Economic Breakdown Tab if isinstance(player.income_graph, Graph): values = player.income_graph.values player.resource_collection_rate = int(sum(values)/len(values)) else: # In old s2gs files the field with this name was actually a number not a graph player.resource_collection_rate = player.income_graph player.resource_collection_graph = None player.income_graph = None player.avg_unspent_resources = stats.get('Average Unspent Resources', None) player.workers_created = stats.get('Workers Created', None) # Build Orders Tab player.build_order = self.build_orders.get(index, None) self.players.append(player) self.player[player.pid] = player
def load_players(self): for index, struct in enumerate(self.parts[0][3]): if not struct[0][1]: continue # Slot is closed player = PlayerSummary(struct[0][0]) stats = self.player_stats[index] settings = self.player_settings[index] player.is_ai = not isinstance(struct[0][1], dict) if not player.is_ai: player.gateway = self.gateway player.subregion = struct[0][1][0][2] player.region = REGIONS[player.gateway].get(player.subregion, 'Unknown') player.bnetid = struct[0][1][0][3] player.unknown1 = struct[0][1][0] player.unknown2 = struct[0][1][1] # Either a referee or a spectator, nothing else to do if settings['Participant Role'] != 'Participant': self.observers.append(player) continue player.play_race = RACE_CODES.get(struct[2], None) player.is_winner = isinstance(struct[1],dict) and struct[1][0] == 0 if player.is_winner: self.winners.append(player.pid) team_id = int(settings['Team'].split(' ')[1]) if team_id not in self.teams: self.teams[team_id] = Team(team_id) player.team = self.teams[team_id] self.teams[team_id].players.append(player) # We can just copy these settings right over # TODO: Get the hex from the color string? player.color = Color(name=settings.get('Color', None)) player.pick_race = settings.get('Race', None) player.handicap = settings.get('Handicap', None) # Overview Tab player.resource_score = stats.get('Resources', None) player.structure_score = stats.get('Structures', None) player.unit_score = stats.get('Units', None) player.overview_score = stats.get('Overview', None) # Economic Breakdown Tab player.avg_unspent_resources = stats.get('Average Unspent Resources', None) player.resource_collection_rate = stats.get('Resource Collection Rate', None) player.workers_created = stats.get('Workers Created', None) # Units Tab player.units_killed = stats.get('Killed Unit Count', None) player.structures_built = stats.get('Structures Built', None) player.units_trained = stats.get('Units Trained', None) player.structures_razed = stats.get('Structures Razed Count', None) # Graphs Tab player.army_graph = stats.get('Army Graph') player.income_graph = stats.get('Income Graph', None) # Build Orders Tab player.build_order = self.build_orders.get(index, None) self.players.append(player) self.player[player.pid] = player