Parse a player.

def _parse_player(self, index, attributes, postgame, game_type):
        """Parse a player."""
        try:
            voobly_user = voobly.user(self._voobly_session, attributes.player_name,
                                      ladder_ids=VOOBLY_LADDERS.values())
            voobly_ladder = '{} {}'.format(game_type, self._diplomacy['type'])
            voobly_ladder_id = VOOBLY_LADDERS.get(voobly_ladder)
            if voobly_ladder_id in voobly_user['ladders']:
                voobly_rating = voobly_user['ladders'].get(voobly_ladder_id).get('rating')
            else:
                voobly_rating = None
        except voobly.VooblyError:
            voobly_user = None
            voobly_rating = None
        player = {
            'index': index,
            'number': attributes.player_color + 1,
            'color': mgz.const.PLAYER_COLORS[attributes.player_color],
            'coordinates': {
                'x': attributes.camera_x,
                'y': attributes.camera_y
            },
            'action_histogram': dict(self._actions_by_player[index]),
            'apm': _calculate_apm(index, self._actions_by_player,
                                  self._actions_without_player, self._time / 1000),
            'name': attributes.player_name,
            'civilization': mgz.const.CIVILIZATION_NAMES[attributes.civilization],
            'position': self._compass_position(attributes.camera_x, attributes.camera_y),
            'research': self._research.get(index, []),
            'build': self._build.get(index, []),
            'voobly': {
                'rating_game': self._ratings.get(attributes.player_name),
                'rating_current': voobly_rating,
                'nation': voobly_user['nationid'] if voobly_user else None,
                'uid': voobly_user['uid'] if voobly_user else None
            },
            'ages': {},
            'achievements': {}
        }
        if postgame:
            achievements = None
            # player index doesn't always match order of postgame achievements! (restores?)
            for ach in postgame.achievements:
                if attributes.player_name == ach.player_name:
                    achievements = ach
            if not achievements:
                return player
            player['score'] = achievements.total_score
            player['mvp'] = achievements.mvp
            player['winner'] = achievements.victory
            player['achievements'] = {
                'units_killed': achievements.military.units_killed,
                'units_lost': achievements.military.units_lost,
                'buildings_razed': achievements.military.buildings_razed,
                'buildings_lost': achievements.military.buildings_lost,
                'conversions': achievements.military.units_converted,
                'food_collected': achievements.economy.food_collected,
                'wood_collected': achievements.economy.wood_collected,
                'gold_collected': achievements.economy.gold_collected,
                'stone_collected': achievements.economy.stone_collected,
                'tribute_sent': achievements.economy.tribute_sent,
                'tribute_received': achievements.economy.tribute_received,
                'trade_gold': achievements.economy.trade_gold,
                'relic_gold': achievements.economy.relic_gold,
                'explored_percent': achievements.technology.explored_percent,
                'total_castles': achievements.society.total_castles,
                'relics_collected': achievements.society.relics_captured,
                'villager_high': achievements.society.villager_high
            }
            player['ages'] = {
                'feudal': _timestamp_to_time(achievements.technology.feudal_time),
                'castle': _timestamp_to_time(achievements.technology.castle_time),
                'imperial': _timestamp_to_time(achievements.technology.imperial_time)
            }
        return player