LoL战绩查询+实力查询(窗口化版,管理员运行,附exe文件下载)

链接:https://pan.baidu.com/s/16LdUBMTVcNuMtgUQc2XTCw?pwd=3oc4
需要管理员权限运行

战绩查询源代码:

import tkinter as tk
import tkinter.ttk as ttk
import datetime
import requests as req
import subprocess

req.packages.urllib3.disable_warnings()

champions_name = ['null', '安妮', '奥拉夫', '加里奥', '卡牌', '赵信', '螃蟹', '妖姬',
                  '吸血鬼', '稻草人', '天使', '剑圣', '牛头', '瑞兹', '塞恩', '轮子妈',
                  '奶妈', '提莫', '小炮', '狼人', '雪人', '赏金', '寒冰', '蛮王',
                  '武器', '莫甘娜', '时光', '炼金', '寡妇', '老鼠', '死歌', '大虫子',
                  '阿木木', '龙龟', '冰鸟', '小丑', '蒙多', '琴女', '卡萨丁', '刀妹',
                  '风女', '船长', '飞机', '卡尔玛', '宝石', '小法师', 'null', 'null',
                  '巨魔', 'null', '乌鸦', '女警', 'null', '机器人', '石头人', '卡特', '梦魇', '大树', '鳄鱼',
                  '皇子', '蜘蛛', '发条', '猴子', '火男', '盲僧', 'null', 'null', 'VN',
                  '兰博', '蛇女', 'null', 'null', '上古领主', 'null', '大头', '狗头', '豹女',
                  '乌迪尔', '波比', '酒桶', '潘森', 'EZ', '铁男', '掘墓', '阿卡丽', '凯南',
                  '盖伦', 'null', 'null', '日女', '蚂蚱', '男刀', '锐雯', 'null', 'null',
                  'null', '大嘴', 'null', '慎', '拉克丝', 'null', '泽拉斯', '龙女', '狐狸',
                  '男枪', '小鱼', '狗熊', '狮子狗', 'null', 'null', '维鲁斯', '泰坦', '三只手',
                  '猪妹', '剑姬', '炸弹人', 'null', '璐璐', 'null', '德莱文', '人马',
                  '螳螂', '诺手', 'null', 'null', 'null', '杰斯', '冰女', 'null', 'null',
                  'null', '皎月', 'null', '奎因', '辛德拉', 'null', '龙王', 'null', 'null', 'null',
                  'null', '凯隐', '佐伊', '婕拉', 'null', '卡莎', 'null', '歌姬', 'null', 'null',
                  '纳尔', 'null', 'null', 'null', '扎克', 'null', 'null', '亚索', 'null', 'null', 'null',
                  '大眼', 'null', '岩雀', '青钢影', 'null', '阿克尚', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', '大卑', '布隆', '烬', '千珏', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', '泽丽', '金克斯', '塔姆', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', '狱卒', '破败王', '赛纳', '卢仙', 'null', '劫', 'null',
                  '克烈', 'null', 'null', 'null', 'null', '艾克', '琪亚娜', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', '蔚', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', '剑魔', '娜美', '沙皇', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', '猫咪', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', '沙弥拉', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', '锤石', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', '章鱼妈', '挖掘机', 'null', 'null', 'null', 'null', 'null', '翠神', 'null',
                  '滑板鞋', 'null', 'null', '巴德', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', '洛', '霞', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', '奥恩', '塞拉斯', '妮蔻', 'null', 'null', 'null', 'null',
                  '月男', 'null', 'null', '芮尔', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', '派克', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', '薇古丝', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', '永恩', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', '腕豪', '莉莉娅', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', '格温', '炼金男爵', 'null', 'null', 'null', 'null',
                  'null', 'null', '尼菈', 'null', '奎桑提', 'null', 'null', 'null', '小火龙', '丁真', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', '异画师', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', '狼狗', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null',
                  'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null']


def get_summoner(name, base_url):
    url = base_url + '/lol-summoner/v1/summoners'
    resp = req.get(url, data={'name': name}, verify=False)
    return resp.json()


def get_match_history(name, base_url):
    uid = get_summoner(name, base_url)['puuid']
    url = base_url + '/lol-match-history/v1/products/lol/' + str(uid) + '/matches'
    resp = req.get(url, data={}, verify=False)
    return resp.json()


def parse_history(history):
    data = []
    index = 1
    for i in history['games']['games']:
        start_time = datetime.datetime.strptime(i['gameCreationDate'][:19],
                                                '%Y-%m-%dT%H:%M:%S')
        start_time = start_time + datetime.timedelta(hours=8)
        start_time = start_time.strftime('%Y-%m-%d %H:%M:%S')
        data.append([index, start_time,
                     champions_name[i['participants'][0]['championId']],
                     ('负×', '胜√')[i['participants'][0]['stats']['win']],
                     str(i['participants'][0]['stats']['kills']),
                     str(i['participants'][0]['stats']['deaths']),
                     str(i['participants'][0]['stats']['assists']),
                     i['gameMode']])
        index = index + 1
    return data


class app(tk.Tk):
    def __init__(self):
        super().__init__()
        self.token = ''
        self.port = ''
        self.is_ready = False
        self.geometry('580x620')
        self.title('LoL战绩查询')
        # self.iconbitmap('./lmh.ico')

        tk.Label(self, text='使用前,登录一个同区账号!并点击获取参数--->', ).place(x=90, y=13)
        self.label_is_ready = tk.Label(self, text='当 前 未 获 取 参 数', fg='red')
        self.label_is_ready.place(x=160, y=30)
        tk.Button(self, text='检测参数', width=15, height=2, command=self.get_token_port).place(x=400, y=10)

        tk.Label(self, text='————————————————————————————————————————').place(x=20, y=60)

        tk.Label(self, text='需要查询的 名字 / 名字#123 :').place(x=52, y=80)
        self.name_text = tk.Text(self, width=30, height=1)
        self.name_text.place(x=220, y=83)
        tk.Button(self, text='查询战绩', width=10, height=1, command=self.search).place(x=450, y=75)

        self.table = ttk.Treeview(self, columns=['序号', '时间', '英雄', '胜负', '击杀', '死亡', '助攻', '地图'],
                                  show='headings', height=23)
        self.table.column('序号', width=35, anchor='center')
        self.table.column('时间', width=180, anchor='center')
        self.table.column('英雄', width=100, anchor='center')
        self.table.column('胜负', width=35, anchor='center')
        self.table.column('击杀', width=35, anchor='center')
        self.table.column('死亡', width=35, anchor='center')
        self.table.column('助攻', width=35, anchor='center')
        self.table.column('地图', width=100, anchor='center')
        self.table.heading('序号', text='序号')
        self.table.heading('时间', text='时间')
        self.table.heading('英雄', text='英雄')
        self.table.heading('胜负', text='胜负')
        self.table.heading('击杀', text='击杀')
        self.table.heading('死亡', text='死亡')
        self.table.heading('助攻', text='助攻')
        self.table.heading('地图', text='地图')
        self.table.place(x=10, y=120)

        self.get_token_port()

    def get_token_port(self):
        try:
            cmd = 'wmic PROCESS WHERE name="LeagueClientUx.exe" GET commandline'
            result = subprocess.run(cmd, capture_output=True)
            out = str(result.stdout).strip()
            # print(out)

            temp = out
            temp = temp[temp.index('--remoting-auth-token') + 22:]
            self.token = temp[:temp.index('"')]
            # print(self.token)

            temp = out
            temp = temp[temp.index('--app-port') + 11:]
            self.port = temp[:temp.index('"')]
            # print(self.port)

            self.is_ready = True
            self.label_is_ready.config(fg='green')
            self.label_is_ready.config(text='已 成 功 获 取 参 数')
        except:
            self.token = ''
            self.port = ''
            self.is_ready = False
            self.label_is_ready.config(fg='red')
            self.label_is_ready.config(text='当 前 未 获 取 参 数')

    def search(self):
        if not self.is_ready:
            return
        name = self.name_text.get('1.0', tk.END).strip()
        base_url = 'https://riot:' + self.token + '@127.0.0.1:' + self.port
        data = parse_history(get_match_history(name, base_url))
        # data = [[1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 4, 5, 6, 7, 8, 9]]

        for item in self.table.get_children():
            self.table.delete(item)

        for item in data:
            self.table.insert('', 'end', 'item' + str(item[0]), values=item)


if __name__ == '__main__':
    root = app()
    root.mainloop()

实力查询源代码:

import tkinter as tk
import subprocess
import requests as req
import datetime

req.packages.urllib3.disable_warnings()


def level(score):
    if score < 95:
        return '牛马'
    if score < 105:
        return '下等马'
    if score < 125:
        return '中等马'
    if score < 150:
        return '上等马'
    if score < 180:
        return '小代'
    return '通天带'


class app(tk.Tk):
    def __init__(self):
        super().__init__()
        self.names = []
        self.ids = []
        self.uids = []
        self.is_ready = False
        self.geometry('570x400')
        self.title('LoL实力查询')
        self.base_url = ''

        tk.Label(self, text='使用前,登录一个同区账号!并点击获取参数--->', ).place(x=90, y=13)
        self.label_is_ready = tk.Label(self, text='当 前 未 获 取 参 数', fg='red')
        self.label_is_ready.place(x=160, y=30)
        tk.Button(self, text='获取参数', width=15, height=2, command=self.get_base_url).place(x=400, y=10)

        tk.Label(self, text='————————————————————————————————————————').place(x=20, y=60)

        tk.Label(self, text='需要查询的 名字#123 :').place(x=30, y=80)
        self.name_text = tk.Text(self, width=23, height=1)
        self.name_text.place(x=170, y=83)
        tk.Button(self, text='查询实力', width=7, height=1, command=self.search).place(x=350, y=75)
        tk.Button(self, text='队友实力', width=7, height=1, command=self.search_team).place(x=415, y=75)
        tk.Button(self, text='全局实力', width=7, height=1, command=self.search_game).place(x=480, y=75)
        self.print_text = tk.Text(self, width=65, height=20)
        self.print_text.place(x=50, y=120)

        self.get_base_url()

    def get_base_url(self):
        try:
            cmd = 'wmic PROCESS WHERE name="LeagueClientUx.exe" GET commandline'
            result = subprocess.run(cmd, capture_output=True)
            out = str(result.stdout).strip()
            # print(out)

            temp = out
            temp = temp[temp.index('--remoting-auth-token') + 22:]
            token = temp[:temp.index('"')]
            # print(self.token)

            temp = out
            temp = temp[temp.index('--app-port') + 11:]
            port = temp[:temp.index('"')]
            # print(self.port)

            self.base_url = 'https://riot:' + token + '@127.0.0.1:' + port
            self.is_ready = True
            self.label_is_ready.config(fg='green')
            self.label_is_ready.config(text='已 成 功 获 取 参 数')
        except:
            self.base_url = ''
            self.is_ready = False
            self.label_is_ready.config(fg='red')
            self.label_is_ready.config(text='当 前 未 获 取 参 数')

    def get_conv_id(self):
        url = self.base_url + '/lol-chat/v1/conversations'
        resp = req.get(url, data={}, verify=False)
        for conv in resp.json():
            if conv['type'] == 'championSelect':
                return conv['id']

    def get_ids_in_chat(self):
        url = self.base_url + '/lol-chat/v1/conversations/' + self.get_conv_id() + '/messages'
        resp = req.get(url, data={}, verify=False)
        data = resp.json()
        for conv in data:
            if conv['type'] == 'system' and conv['body'] == 'joined_room':
                self.ids.append(conv['fromSummonerId'])

    def get_uids_names(self):
        url = self.base_url + '/lol-summoner/v2/summoners?ids=' + str(self.ids)
        resp = req.get(url, data={}, verify=False)
        data = resp.json()
        for summoner in data:
            self.uids.append(summoner['puuid'])
            self.names.append(summoner['gameName'])

    def get_info(self):
        self.get_ids_in_chat()
        self.get_uids_names()

    def get_history(self, uid):
        url = self.base_url + '/lol-match-history/v1/products/lol/' + str(uid) + '/matches'
        resp = req.get(url, data={}, verify=False)
        return resp.json()['games']['games']

    def get_game(self, game_id):
        url = self.base_url + '/lol-match-history/v1/games/' + str(game_id)
        resp = req.get(url, data={}, verify=False)
        return resp.json()

    def analyse_history(self, i):
        history = self.get_history(self.uids[i])
        current_games_num = 0
        current_score = 0
        other_games_num = 0
        other_score = 0
        current_time = datetime.datetime.now()
        for h in history:
            if (not h['queueId'] == 420 and not h['queueId'] == 430
                    and not h['queueId'] == 440 and not h['queueId'] == 450):
                continue
            g = self.get_game(h['gameId'])
            score = 100
            summoner_id = h['participantIdentities'][0]['player']['summonerId']

            is_not_sup = not h['participants'][0]['timeline']['role'] == 'SUPPORT'
            start_time_plus_5_hours = datetime.datetime.strptime(h['gameCreationDate'][:19],
                                                                 '%Y-%m-%dT%H:%M:%S') + datetime.timedelta(hours=13)
            duration = h['gameDuration']
            team_id = h['participants'][0]['teamId']
            self_index = -1
            temp = g['participantIdentities']
            for i in range(0, len(temp)):
                if temp[i]['player']['summonerId'] == summoner_id:
                    self_index = i
                    break

            stats = h['participants'][0]['stats']
            team = g['participants']

            kill = stats['kills']
            death = stats['deaths']
            assist = stats['assists']
            gold = stats['goldEarned']
            damage = stats['totalDamageDealtToChampions']
            vision = stats['visionScore']
            minion = stats['totalMinionsKilled']

            team_kill = []
            team_death = []
            team_assist = []
            team_gold = []
            team_damage = []
            team_vision = []
            team_minion = []

            for i in range(0, len(team)):
                if i == self_index:
                    continue
                player = team[i]
                if not player['teamId'] == team_id:
                    continue

                team_kill.append(player['stats']['kills'])
                team_death.append(player['stats']['deaths'])
                team_assist.append(player['stats']['assists'])
                team_gold.append(player['stats']['goldEarned'])
                team_damage.append(player['stats']['totalDamageDealtToChampions'])
                team_vision.append(player['stats']['visionScore'])
                team_minion.append(player['stats']['totalMinionsKilled'])

            if stats['firstBloodAssist']:
                score += 5
            if stats['firstBloodKill']:
                score += 10
            if stats['tripleKills'] > 0:
                score += 5
            if stats['quadraKills'] > 0:
                score += 10
            if stats['pentaKills'] > 0:
                score += 20

            # 参团率
            rank = 1
            self_i = kill + assist
            for i in range(0, len(team_kill)):
                if team_kill[i] + team_assist[i] >= self_i:
                    rank += 1
            if rank == 1:
                score += 10
            if rank == 2:
                score += 5
            if rank == 4:
                score += -5
            if rank == 5:
                score += -10

            # 金钱
            rank = 1
            for i in team_gold:
                if i >= gold:
                    rank += 1
            if rank == 1:
                score += 10
            if rank == 2:
                score += 5
            if rank == 4 and is_not_sup:
                score += -5
            if rank == 5 and is_not_sup:
                score += -10

            # 伤害
            rank = 1
            for i in team_damage:
                if i >= damage:
                    rank += 1
            if rank == 1:
                score += 10
            if rank == 2:
                score += 5

            # 伤转
            rank = 1
            self_i = damage / gold
            for i in range(0, len(team_damage)):
                if team_damage[i] / team_gold[i] >= self_i:
                    rank += 1
            if rank == 1:
                score += 10
            if rank == 2:
                score += 5

            # 视野分
            rank = 1
            for i in team_vision:
                if i >= vision:
                    rank += 1
            if rank == 1:
                score += 10
            if rank == 2:
                score += 5

            # 分均补兵
            minion_pre_min = minion / duration / 60
            if minion_pre_min > 8:
                score += 5
            elif minion_pre_min > 9:
                score += 10
            elif minion_pre_min > 10:
                score += 20

            # 击杀占比
            total_kill = kill
            for i in team_kill:
                total_kill += i
            if not total_kill == 0:
                if kill / total_kill > .5:
                    if kill > 5:
                        score += 10
                    elif kill > 10:
                        score += 20
                    elif kill > 15:
                        score += 40
                elif kill / total_kill > .4:
                    if kill > 5:
                        score += 5
                    elif kill > 10:
                        score += 10
                    elif kill > 15:
                        score += 20

            # 伤害占比
            temp = damage
            for i in team_damage:
                temp += i
            if not temp == 0:
                if damage / temp > .4:
                    if kill > 5:
                        score += 10
                    elif kill > 10:
                        score += 20
                    elif kill > 15:
                        score += 40
                elif damage / temp > .3:
                    if kill > 5:
                        score += 5
                    elif kill > 10:
                        score += 10
                    elif kill > 15:
                        score += 20

            # 助攻占比
            temp = assist
            for i in team_assist:
                temp += i
            if not temp == 0:
                if assist / temp > .5:
                    if assist > 5:
                        score += 5
                    elif assist > 10:
                        score += 10
                    elif assist > 15:
                        score += 20
                    elif assist > 18:
                        score += 25
                    elif assist > 20:
                        score += 30
                elif assist / temp > .4:
                    if assist > 5:
                        score += 3
                    elif assist > 10:
                        score += 5
                    elif assist > 15:
                        score += 15
                    elif assist > 20:
                        score += 20

            if death == 0 and total_kill == 0:
                score += (kill + assist) - 2 + (kill / 5 * (kill + assist))
            elif death == 0:
                score += (kill + assist) - 2 + (kill / 5 * (kill + assist) / total_kill)
            elif total_kill == 0:
                score += (kill + assist) / death - 2 + ((kill - death) / 5 * (kill + assist))
            else:
                score += (kill + assist) / death - 2 + ((kill - death) / 5 * (kill + assist) / total_kill)

            if start_time_plus_5_hours > current_time:
                current_score += score
                current_games_num += 1
            else:
                other_score += score
                other_games_num += 1
        # 加权
        if current_games_num == 0 and other_score == 0:
            return -1
        if other_games_num == 0:
            return current_score / current_games_num
        if current_games_num == 0:
            return other_score / other_games_num
        return (current_score / current_games_num) * .8 + (other_score / other_games_num) * .2

    def get_summoner(self, name):
        url = self.base_url + '/lol-summoner/v1/summoners'
        resp = req.get(url, data={'name': name}, verify=False)
        self.ids.append(resp.json()['summonerId'])
        self.uids.append(resp.json()['puuid'])

    def get_ids_from_game(self):
        url = self.base_url + '/lol-gameflow/v1/session'
        resp = req.get(url, data={}, verify=False)
        ids_s = []
        i = []
        for player in resp.json()['gameData']['teamOne']:
            try:
                i.append(player['summonerId'])
            except:
                self.print_text.insert('1.0', '是不是有人机啊?\n')
        ids_s.append(i)

        j = []
        for player in resp.json()['gameData']['teamTwo']:
            try:
                j.append(player['summonerId'])
            except:
                self.print_text.insert('1.0', '是不是有人机啊?\n')
        ids_s.append(j)
        return ids_s

    def search(self):
        if not self.is_ready:
            self.print_text.insert('1.0', '\n未获取参数\n')
            return

        self.print_text.insert('1.0', '+++++++++++++++++++++++++++++++++++++++++++++++\n')
        name = self.name_text.get('1.0', tk.END).strip()
        self.names = [name]
        self.ids = []
        self.uids = []
        try:
            self.get_summoner(name)
            for i in range(0, len(self.names)):
                score = self.analyse_history(i)
                self.print_text.insert('1.0', ('[' + name.split('#')[0] + '] 评为 [' + level(score) + ']\n'))
        except:
            self.print_text.insert('1.0', '\n没找到这人\n')

    def search_team(self):
        if not self.is_ready:
            self.print_text.insert('1.0', '\n未获取参数\n')
            return

        self.print_text.insert('1.0', '+++++++++++++++++++++++++++++++++++++++++++++++\n')
        self.names = []
        self.ids = []
        self.uids = []
        try:
            self.get_info()
            for i in range(0, len(self.ids)):
                score = self.analyse_history(i)
                self.print_text.insert('1.0', '[' + self.names[i] + '] 评为 [' + level(score) + ']\n')
        except:
            self.print_text.insert('1.0', '\n没找到房间\n')

    def search_game(self):
        if not self.is_ready:
            self.print_text.insert('1.0', '\n未获取参数\n')
            return

        self.print_text.insert('1.0', '+++++++++++++++++++++++++++++++++++++++++++++++\n')

        try:
            ids_s = self.get_ids_from_game()
            if not len(ids_s[0]) == 0:
                self.names = []
                self.ids = []
                self.uids = []
                self.ids = ids_s[0]
                self.get_uids_names()
                for i in range(0, len(self.ids)):
                    score = self.analyse_history(i)
                    self.print_text.insert('1.0', '[' + self.names[i] + '] 评为 [' + level(score) + ']\n')
                self.print_text.insert('1.0', '左下蓝色方:\n')

            if not len(ids_s[1]) == 0:
                self.names = []
                self.ids = []
                self.uids = []
                ids_s = self.get_ids_from_game()
                self.ids = ids_s[1]
                self.get_uids_names()
                for i in range(0, len(self.ids)):
                    score = self.analyse_history(i)
                    self.print_text.insert('1.0', '[' + self.names[i] + '] 评为 [' + level(score) + ']\n')
                self.print_text.insert('1.0', '右上红色方:\n')

        except:
            self.print_text.insert('1.0', '\n没找到游戏\n')


if __name__ == '__main__':
    root = app()
    root.mainloop()

posted @ 2024-04-29 14:38  蓝火BlueFlameAshe  阅读(845)  评论(0编辑  收藏  举报