コード例 #1
0
    def get_kit(self, id):
        '''
        Provides details for a specific kit based on the given kit identifier.

        Args:
           id (string): The unique identifier of a kit.

        Returns:
            kit (object): Detailed information for a specific kit.
        '''

        # Get the model for the requested kit
        kit = model_mgr.get_kit(id)
        if not kit: raise cherrypy.HTTPError(404)

        # Get the stats for the requested kit
        kit_stats = stat_mgr.get_kit_stats(kit)

        # Build a list of column descriptors
        columns = [{
            'name': 'Players',
            'data': 'player'
        }, {
            'name': 'Score',
            'data': 'number',
            'sorted': False
        }, {
            'name': 'Kills',
            'data': 'number'
        }, {
            'name': 'Deaths',
            'data': 'number'
        }]

        # Build a list of kit statistics
        rows = list()
        for player in kit_stats.players:
            if player != models.players.EMPTY:
                object_stats = kit_stats.players[player]
                player_tuple = {
                    'id': player.id,
                    'name': player.name,
                    'photo': player.photo_s
                }
                rows.append([
                    player_tuple, object_stats.score, object_stats.kills,
                    object_stats.deaths
                ])

        # Sort the results by score
        rows.sort(key=lambda r: r[1], reverse=True)

        return {
            'id': kit.id,
            'name': kit.name,
            'columns': columns,
            'rows': rows
        }
コード例 #2
0
ファイル: kit_scores.py プロジェクト: Hagrid78/bf2-stats
    def on_score(self, e):

        # Get the last known kit for the player
        # Player may be dead and would not have a kit
        player_kit = event_mgr.get_last_kit(e.player)
        kit_stats = stat_mgr.get_kit_stats(player_kit)

        # Increment the total kit score
        kit_stats.score += e.value

        # Increment score count for the player
        if not e.player in kit_stats.players:
            kit_stats.players[e.player] = KitItemStats()
        kit_stats.players[e.player].score += e.value
コード例 #3
0
ファイル: kit_scores.py プロジェクト: Hagrid78/bf2-stats
    def on_death(self, e):

        # Get the last known kit for the player
        # Player will no longer have an active kit at this point
        player_kit = event_mgr.get_last_kit(e.player)
        kit_stats = stat_mgr.get_kit_stats(player_kit)

        # Increment the total kit deaths
        kit_stats.deaths += 1

        # Increment the player deaths
        if not e.player in kit_stats.players:
            kit_stats.players[e.player] = KitItemStats()
        kit_stats.players[e.player].deaths += 1
コード例 #4
0
ファイル: kit_scores.py プロジェクト: chrisw1229/bf2-stats
    def on_score(self, e):

        # Get the last known kit for the player
        # Player may be dead and would not have a kit
        player_kit = event_mgr.get_last_kit(e.player)
        kit_stats = stat_mgr.get_kit_stats(player_kit)

        # Increment the total kit score
        kit_stats.score += e.value

        # Increment score count for the player
        if not e.player in kit_stats.players:
            kit_stats.players[e.player] = KitItemStats()
        kit_stats.players[e.player].score += e.value
コード例 #5
0
ファイル: kit_scores.py プロジェクト: chrisw1229/bf2-stats
    def on_death(self, e):

        # Get the last known kit for the player
        # Player will no longer have an active kit at this point
        player_kit = event_mgr.get_last_kit(e.player)
        kit_stats = stat_mgr.get_kit_stats(player_kit)

        # Increment the total kit deaths
        kit_stats.deaths += 1

        # Increment the player deaths
        if not e.player in kit_stats.players:
            kit_stats.players[e.player] = KitItemStats()
        kit_stats.players[e.player].deaths += 1
コード例 #6
0
ファイル: kit_scores.py プロジェクト: Hagrid78/bf2-stats
    def on_kill(self, e):

        # Ignore suicides and team kills
        if not e.valid_kill:
            return

        # Get the last known kit for the attacker
        # Attacker may be dead and may not have an active kit
        attacker_kit = event_mgr.get_last_kit(e.attacker)
        kit_stats = stat_mgr.get_kit_stats(attacker_kit)

        # Increment the total kit kills
        kit_stats.kills += 1

        # Increment the attacker kills
        if not e.attacker in kit_stats.players:
            kit_stats.players[e.attacker] = KitItemStats()
        kit_stats.players[e.attacker].kills += 1
コード例 #7
0
ファイル: kit_scores.py プロジェクト: chrisw1229/bf2-stats
    def on_kill(self, e):

        # Ignore suicides and team kills
        if not e.valid_kill:
            return

        # Get the last known kit for the attacker
        # Attacker may be dead and may not have an active kit
        attacker_kit = event_mgr.get_last_kit(e.attacker)
        kit_stats = stat_mgr.get_kit_stats(attacker_kit)

        # Increment the total kit kills
        kit_stats.kills += 1

        # Increment the attacker kills
        if not e.attacker in kit_stats.players:
            kit_stats.players[e.attacker] = KitItemStats()
        kit_stats.players[e.attacker].kills += 1
コード例 #8
0
ファイル: kits.py プロジェクト: chrisw1229/bf2-stats
    def get_kit(self, id):
        '''
        Provides details for a specific kit based on the given kit identifier.

        Args:
           id (string): The unique identifier of a kit.

        Returns:
            kit (object): Detailed information for a specific kit.
        '''

        # Get the model for the requested kit
        kit = model_mgr.get_kit(id)
        if not kit: raise cherrypy.HTTPError(404)

        # Get the stats for the requested kit
        kit_stats = stat_mgr.get_kit_stats(kit)

        # Build a list of column descriptors
        columns = [{ 'name': 'Players', 'data': 'player' },
                { 'name': 'Score', 'data': 'number', 'sorted': False },
                { 'name': 'Kills', 'data': 'number' },
                { 'name': 'Deaths', 'data': 'number' }]

        # Build a list of kit statistics
        rows = list()
        for player in kit_stats.players:
            if player != models.players.EMPTY:
                object_stats = kit_stats.players[player]
                player_tuple = {
                    'id': player.id,
                    'name': player.name,
                    'photo': player.photo_s
                }
                rows.append([player_tuple, object_stats.score,
                        object_stats.kills, object_stats.deaths])

        # Sort the results by score
        rows.sort(key=lambda r: r[1], reverse=True)

        return { 'id': kit.id, 'name': kit.name, 'columns' : columns,
                'rows': rows }