Example #1
0
    def run(self):
        timeout = 2
        round_ = None

        while not self.stopped():
            try:
                stat = live_stats_queue.get(True, 2)
            except Queue.Empty:
                continue
            if stat['type'] == 'kill':
                # Detect if is an autokill !!!
                # Check rank
                player = stat['data']['killer']
                round_ = stat['data']['round']
                if round_ is None:
                    continue
                data = {}
                data['kstats'], data['vstats'], data['pstats'] = get_player_stats(player)
                score = get_player_score(player, data)
                if score > 0 and score in [x[1] for x in ranks]:
                    # New rank
                    new_rank = get_rank(player, data)
                    rank_name = ranks[new_rank][0]
                    msg = """%s is now "%s" """ % (player, rank_name)
                    econ_command_queue.put({'type': 'broadcast', 'data': {'message': msg}})
                # Check live achievements
                for key, achievement in achievement_livestat_list.items():
                    achievement(stat['data'])
            if stat['type'] == 'join':
                player = stat['data']['player']
                rank = get_rank(player)
                rank_name = ranks[rank][0]
                msg = "WELCOME to the '%s' %s" % (rank_name, player)
                econ_command_queue.put({'type': 'broadcast', 'data': {'message': msg}})
Example #2
0
def player_badges(player, gametype):
    player_stats = get_stats(player, gametype)
    kills, _, items = get_player_stats(player)

    badge_result = dict([(x, 0) for x in badge_list])
    for badge, limits in badge_list.items():
        if badge in kills['weapon']:
            badge_result[badge] = 0
            for i, l in enumerate(limits):
                if kills['weapon'][badge] > l:
                    badge_result[badge] = i + 1
        elif badge in items:
            badge_result[badge] = 0
            for i, l in enumerate(limits):
                if items[badge] > l:
                    badge_result[badge] = i + 1
        elif badge == 'winner':
            badge_result[badge] = 0
            for i, l in enumerate(limits):
                if player_stats.get('first', 0) > l:
                    badge_result[badge] = i + 1

    return {'results': badge_result}