Exemple #1
0
    def on_server_status(self, e):

        # Reset all the temporary accuracy values
        for player in model_mgr.get_players(True):
            self._update_accuracy(player)

        # Reset any active timers
        for player in model_mgr.get_players():
            player_stats = stat_mgr.get_player_stats(player)
            player_stats.commander_time.stop(e.tick)
            player_stats.leader_time.stop(e.tick)
            player_stats.play_time.stop(e.tick)
            player_stats.spec_time.stop(e.tick)
            player_stats.squad_time.stop(e.tick)
    def on_server_status(self, e):

        # Reset all the temporary accuracy values
        for player in model_mgr.get_players(True):
            self._update_accuracy(player)

        # Reset any active timers
        for player in model_mgr.get_players():
            player_stats = stat_mgr.get_player_stats(player)
            player_stats.commander_time.stop(e.tick)
            player_stats.leader_time.stop(e.tick)
            player_stats.play_time.stop(e.tick)
            player_stats.spec_time.stop(e.tick)
            player_stats.squad_time.stop(e.tick)
Exemple #3
0
    def on_loss(self, e):

        # Update the loss count for all the active players on the team
        for player in model_mgr.get_players(True):
            if player.team_id == e.team.id:
                player_stats = stat_mgr.get_player_stats(player)
                self.results[player] = player_stats.losses
Exemple #4
0
    def on_win(self, e):

        # Update the win count for all the active players on the team
        for player in model_mgr.get_players(True):
            if player.team_id == e.team.id:
                player_stats = stat_mgr.get_player_stats(player)
                self.results[player] = player_stats.wins
    def on_win(self, e):

        # Increment the win count for all the active players on the team
        for player in model_mgr.get_players(True):
            if player.team_id == e.team.id:
                player_stats = stat_mgr.get_player_stats(player)
                player_stats.wins += 1
Exemple #6
0
    def on_win(self, e):

        # Increment the win count for all the active players on the team
        for player in model_mgr.get_players(True):
            if player.team_id == e.team.id:
                player_stats = stat_mgr.get_player_stats(player)
                player_stats.wins += 1
Exemple #7
0
    def _update_place(self):

        # Sort the players by score
        players = model_mgr.get_players(True)
        players.sort(key=lambda p: stat_mgr.get_player_stats(p).score,
                     reverse=True)

        # Assign a place value to each player based on index
        last_score = None
        place = None
        for index, player in enumerate(players):
            player_stats = stat_mgr.get_player_stats(player)

            # Check whether the place should be incremented
            if last_score != player_stats.score:
                last_score = player_stats.score
                place = index + 1

            # Update the trend of the player
            if place < player_stats.place:
                player_stats.trend = '+'
            elif place > player_stats.place:
                player_stats.trend = '-'
            else:
                player_stats.trend = '='
            player_stats.place = place
    def _update_place(self):

        # Sort the players by score
        players = model_mgr.get_players(True)
        players.sort(key=lambda p: stat_mgr.get_player_stats(p).score,
                reverse=True)

        # Assign a place value to each player based on index
        last_score = None
        place = None
        for index, player in enumerate(players):
            player_stats = stat_mgr.get_player_stats(player)

            # Check whether the place should be incremented
            if last_score != player_stats.score:
                last_score = player_stats.score
                place = index + 1

            # Update the trend of the player
            if place < player_stats.place:
                player_stats.trend = '+'
            elif place > player_stats.place:
                player_stats.trend = '-'
            else:
                player_stats.trend = '='
            player_stats.place = place
    def on_vehicle_destroy(self, e):

        vpos = e.vehicle_pos

        for player in model_mgr.get_players():
            dist = stat_mgr.dist_3d(vpos, player.pos)
            if dist < 5:
                self.results[player] += 1
Exemple #10
0
    def on_vehicle_destroy(self, e):

        vpos = e.vehicle_pos

        for player in model_mgr.get_players():
            dist = stat_mgr.dist_3d(vpos, player.pos)
            if dist < 5:
                self.results[player] += 1
Exemple #11
0
    def on_server_status(self, e):

        # Disconnect all the registered players
        for player in model_mgr.get_players():
            player.connected = False

        # Reset the game models on server start
        model_mgr.reset_models()
Exemple #12
0
    def on_server_status(self, e):

        # Disconnect all the registered players
        for player in model_mgr.get_players():
            player.connected = False

        # Reset the game models on server start
        model_mgr.reset_models()
Exemple #13
0
    def _update_place_overall(self):

        # Sort the players by total score
        players = model_mgr.get_players()
        players.sort(key=lambda p: stat_mgr.get_player_stats(p).score_total,
                reverse=True)

        # Assign an overall place value to each player based on index
        last_score = None
        place = None
        for index, player in enumerate(players):
            player_stats = stat_mgr.get_player_stats(player)

            if last_score != player_stats.score_total:
                last_score = player_stats.score_total
                place = index + 1
            player_stats.place_overall = place
Exemple #14
0
    def _update_place_overall(self):

        # Sort the players by total score
        players = model_mgr.get_players()
        players.sort(key=lambda p: stat_mgr.get_player_stats(p).score_total,
                     reverse=True)

        # Assign an overall place value to each player based on index
        last_score = None
        place = None
        for index, player in enumerate(players):
            player_stats = stat_mgr.get_player_stats(player)

            if last_score != player_stats.score_total:
                last_score = player_stats.score_total
                place = index + 1
            player_stats.place_overall = place
Exemple #15
0
    def _get_packet_list(self):
        packets = list()

        # Add the current game info
        game = model_mgr.get_game()
        packets.append(self._get_game_packet(game))

        # Add the current player info
        for player in model_mgr.get_players(True):
            packets.append(self._get_player_stats_packet(player))

        # Add the current control point info
        for control_point in model_mgr.get_control_points(True):
            packets.append(self._get_control_point_packet(control_point))

        # Add the flag action history
        packets.extend(self.flag_packets)
        return packets
Exemple #16
0
    def on_game_status(self, e):
        if e.game.starting:

            # Store the game start tick to calculate elapsed time
            self.start_tick = e.tick

            # Clear cached packets when the game resets
            self.tick_to_packets.clear()
            del self.flag_packets[:]
            self.last_tick = None
        elif e.game.playing:

            # Create a packet to store the event info
            packet = self._get_game_packet(e.game)
            self._add_packet(e.tick, packet)

            # Add the player stats after the game reset
            for player in model_mgr.get_players(True):
                self._add_packet(e.tick, self._get_stats_packet(player))
Exemple #17
0
    def get_players(self):
        '''
        Provides an index of available players.

        Args:
            None

        Returns:
            players (list): Returns the list of all players.
        '''

        # Build an index of the available players
        results = list()
        for player in model_mgr.get_players():
            results.append({'id': player.id, 'name': player.name})

        # Sort the index by player name
        results.sort(key=lambda r: r['name'].lower())
        return results
Exemple #18
0
    def get_players(self):
        '''
        Provides an index of available players.

        Args:
            None

        Returns:
            players (list): Returns the list of all players.
        '''

        # Build an index of the available players
        results = list()
        for player in model_mgr.get_players():
            results.append({ 'id': player.id, 'name': player.name })

        # Sort the index by player name
        results.sort(key=lambda r: r['name'].lower())
        return results
Exemple #19
0
    def GET(self, id=None):
        '''
        Provides statistics that represent the overall performance of all players.

        Args:
           None

        Returns:
            leaders (object): Overall information for all players.
        '''

        # Build a list of columns
        columns = list()
        columns.append({'name': 'Players', 'data': 'player'})
        columns.append({'name': 'Score', 'data': 'number', 'sorted': False})
        columns.append({'name': 'Help', 'data': 'number'})
        columns.append({'name': 'Kills', 'data': 'number'})
        columns.append({'name': 'Deaths', 'data': 'number'})
        columns.append({'name': 'Time', 'data': 'string'})

        # Build a row of statistics for each player
        rows = list()
        for player in model_mgr.get_players():
            player_stats = stat_mgr.get_player_stats(player)
            player_tuple = {
                'id': player.id,
                'name': player.name,
                'photo': player.photo_s
            }
            rows.append([
                player_tuple, player_stats.score_total,
                player_stats.teamwork_total, player_stats.kills_total,
                player_stats.deaths_total, player_stats.play_time
            ])

        # Sort the results by score
        rows.sort(key=lambda r: r[1], reverse=True)
        return {'columns': columns, 'rows': rows}
Exemple #20
0
    def GET(self, id=None):
        '''
        Provides statistics that represent the overall performance of all players.

        Args:
           None

        Returns:
            leaders (object): Overall information for all players.
        '''
 
        # Build a list of columns
        columns = list()
        columns.append({ 'name': 'Players', 'data': 'player' })
        columns.append({ 'name': 'Score', 'data': 'number', 'sorted': False })
        columns.append({ 'name': 'Help', 'data': 'number' })
        columns.append({ 'name': 'Kills', 'data': 'number' })
        columns.append({ 'name': 'Deaths', 'data': 'number' })
        columns.append({ 'name': 'Time', 'data': 'string' })

        # Build a row of statistics for each player
        rows = list()
        for player in model_mgr.get_players():
            player_stats = stat_mgr.get_player_stats(player);
            player_tuple = {
                'id': player.id,
                'name': player.name,
                'photo': player.photo_s
            }
            rows.append([player_tuple, player_stats.score_total,
                    player_stats.teamwork_total, player_stats.kills_total,
                    player_stats.deaths_total, player_stats.play_time])

        # Sort the results by score
        rows.sort(key=lambda r: r[1], reverse=True)
        return { 'columns': columns, 'rows': rows }
Exemple #21
0
    def on_connect(self, e):
        players = model_mgr.get_players(True)

        overall_stats = stat_mgr.get_stats()
        overall_stats.players = max(overall_stats.players, len(players))