Exemple #1
0
    def on_score(self, e):
        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game score
        game_stats.kills += e.value

        # Increment score count for the player
        if not e.player in game_stats.players:
            game_stats.players[e.player] = GameItemStats()
        game_stats.players[e.player].score += e.value
Exemple #2
0
    def on_score(self, e):
        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game score
        game_stats.kills += e.value

        # Increment score count for the player
        if not e.player in game_stats.players:
            game_stats.players[e.player] = GameItemStats()
        game_stats.players[e.player].score += e.value
Exemple #3
0
    def on_revive(self, e):
        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game teamwork
        game_stats.teamwork += 1

        # Increment teamwork for the giver
        if not e.giver in game_stats.players:
            game_stats.players[e.giver] = GameItemStats()
        game_stats.players[e.giver].teamwork += 1
Exemple #4
0
    def on_death(self, e):
        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game deaths
        game_stats.deaths += 1

        # Increment the victim deaths
        if not e.player in game_stats.players:
            game_stats.players[e.player] = GameItemStats()
        game_stats.players[e.player].deaths += 1
Exemple #5
0
    def on_revive(self, e):
        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game teamwork
        game_stats.teamwork += 1

        # Increment teamwork for the giver
        if not e.giver in game_stats.players:
            game_stats.players[e.giver] = GameItemStats()
        game_stats.players[e.giver].teamwork += 1
Exemple #6
0
    def on_death(self, e):
        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game deaths
        game_stats.deaths += 1

        # Increment the victim deaths
        if not e.player in game_stats.players:
            game_stats.players[e.player] = GameItemStats()
        game_stats.players[e.player].deaths += 1
Exemple #7
0
    def on_kill(self, e):

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

        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game kills
        game_stats.kills += 1

        # Increment the attacker kills
        if not e.attacker in game_stats.players:
            game_stats.players[e.attacker] = GameItemStats()
        game_stats.players[e.attacker].kills += 1
Exemple #8
0
    def on_kill(self, e):

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

        game_stats = stat_mgr.get_game_stats(model_mgr.get_game())

        # Increment the total game kills
        game_stats.kills += 1

        # Increment the attacker kills
        if not e.attacker in game_stats.players:
            game_stats.players[e.attacker] = GameItemStats()
        game_stats.players[e.attacker].kills += 1
Exemple #9
0
    def get_game(self, id):
        '''
        Provides details for a specific game based on the given game identifier.

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

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

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

        # Get the stats for the requested game
        game_stats = stat_mgr.get_game_stats(game)

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

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

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

        map_obj = model_mgr.get_map(game.map_id)
        return { 'id': game.id, 'name': map_obj.name, 'columns' : columns,
                'rows': rows }
Exemple #10
0
    def get_game(self, id):
        '''
        Provides details for a specific game based on the given game identifier.

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

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

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

        # Get the stats for the requested game
        game_stats = stat_mgr.get_game_stats(game)

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

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

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

        map_obj = model_mgr.get_map(game.map_id)
        return {
            'id': game.id,
            'name': map_obj.name,
            'columns': columns,
            'rows': rows
        }