From a13e923e6318bddfb9ae04ba7ccc11413770fbfa Mon Sep 17 00:00:00 2001 From: Hpero4 Date: Fri, 24 Nov 2023 00:31:44 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D:=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E5=AF=B9=E5=B1=80=E4=B8=AD=E6=9C=89=E9=95=BF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=9C=AA=E8=BF=9B=E8=A1=8C=E6=B8=B8=E6=88=8F=E7=9A=84=E5=8F=AC?= =?UTF-8?q?=E5=94=A4=E5=B8=88(=E6=9F=A5=E4=B8=8D=E5=88=B0=E6=88=98?= =?UTF-8?q?=E7=BB=A9)=E4=BC=9A=E5=9B=A0=E6=9C=80=E8=BF=91=E9=98=9F?= =?UTF-8?q?=E5=8F=8B(=E5=AF=B9=E6=89=8B)=E5=8A=9F=E8=83=BD=E5=BC=95?= =?UTF-8?q?=E5=8F=91=E5=BC=82=E5=B8=B8=E7=9A=84BUG=20BUG=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?:=20=E5=85=BC=E5=AE=B9=E5=A4=96=E6=9C=8D=20riot=20id=20?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E5=BC=95=E5=8F=91=E7=9A=84=E5=90=84=E7=A7=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20BUG=E4=BF=AE=E5=A4=8D:=20=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=8E=86=E5=8F=B2=E6=88=98=E7=BB=A9=E4=B8=AD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8AI,=20=E4=BC=9A=E5=9B=A0"=E6=88=98=E7=BB=A9=E9=9A=90?= =?UTF-8?q?=E8=97=8F"=E6=A0=87=E8=AE=B0=E5=BC=95=E5=8F=91=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lol/entries.py | 4 +++- app/lol/tools.py | 7 ++++-- app/view/career_interface.py | 4 ++-- app/view/main_window.py | 44 +++++++++++++++++++----------------- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/app/lol/entries.py b/app/lol/entries.py index d5d175e1..a10e52ab 100644 --- a/app/lol/entries.py +++ b/app/lol/entries.py @@ -2,10 +2,12 @@ class Summoner: def __init__(self, data: dict): self.summonerId = data['summonerId'] - self.name = data['displayName'] + self.name = data.get("gameName") or data['displayName'] # 兼容外服 self.profileIconId = data['profileIconId'] self.puuid = data['puuid'] self.level = data['summonerLevel'] self.xpSinceLastLevel = data['xpSinceLastLevel'] self.xpUntilNextLevel = data['xpUntilNextLevel'] self.isPublic = data["privacy"] == "PUBLIC" + self.tagLine = data.get("tagLine", "") + self.completeName = "#".join((self.name, self.tagLine)) if self.tagLine else self.name # 兼容外服 diff --git a/app/lol/tools.py b/app/lol/tools.py index ad11f73d..969d7d5c 100644 --- a/app/lol/tools.py +++ b/app/lol/tools.py @@ -266,11 +266,14 @@ def processGameDetailData(puuid, game): for participant in game['participantIdentities']: participantId = participant['participantId'] - summonerName = participant['player']['summonerName'] + summonerName = participant['player'].get('gameName') or participant['player'].get('summonerName') # 兼容外服 summonerPuuid = participant['player']['puuid'] isCurrent = (summonerPuuid == puuid) - isPublic = connector.getSummonerByName(summonerName)["privacy"] == "PUBLIC" + if summonerPuuid == '00000000-0000-0000-0000-000000000000': # AI + isPublic = True + else: + isPublic = connector.getSummonerByPuuid(summonerPuuid)["privacy"] == "PUBLIC" for summoner in game['participants']: if summoner['participantId'] == participantId: diff --git a/app/view/career_interface.py b/app/view/career_interface.py index 8cde35ba..594ebf49 100644 --- a/app/view/career_interface.py +++ b/app/view/career_interface.py @@ -559,7 +559,7 @@ def _(): summonerIcon = connector.getProfileIcon(p['icon']) summoners[p['puuid']] = { "name": p['name'], 'icon': summonerIcon, - "total": 0, "wins": 0, "losses": 0} + "total": 0, "wins": 0, "losses": 0, "puuid": p["puuid"]} summoners[p['puuid']]['total'] += 1 @@ -674,7 +674,7 @@ def __init__(self, summoner, parent=None): self.name.clicked.connect( lambda: self.parent().parent().parent().parent() - .parent().summonerNameClicked.emit(self.name.text())) + .parent().summonerNameClicked.emit(summoner['puuid'])) def __initWidget(self): self.name.setFixedWidth(180) diff --git a/app/view/main_window.py b/app/view/main_window.py index 8af22671..172d88c8 100644 --- a/app/view/main_window.py +++ b/app/view/main_window.py @@ -372,7 +372,7 @@ def __changeCareerToCurrentSummoner(self): iconId = self.currentSummoner.profileIconId icon = connector.getProfileIcon(iconId) - name = self.currentSummoner.name + name = self.currentSummoner.completeName level = self.currentSummoner.level xpSinceLastLevel = self.currentSummoner.xpSinceLastLevel xpUntilNextLevel = self.currentSummoner.xpUntilNextLevel @@ -513,7 +513,7 @@ def __onCurrentSummonerProfileChanged(self, data: dict): self.currentSummoner = Summoner(data) def _(): - name = self.currentSummoner.name + name = self.currentSummoner.completeName iconId = self.currentSummoner.profileIconId icon = connector.getProfileIcon(iconId) @@ -645,7 +645,7 @@ def __onGameInfoInterfaceGamesSummonerNameClicked(self, name): def __onSearchInterfaceCareerButtonClicked(self): self.careerInterface.showLoadingPage.emit() - name = self.searchInterface.currentSummonerName + name = self.searchInterface.currentSummonerName # 搜的那个人 def _(): summoner = Summoner(connector.getSummonerByName(name)) @@ -715,12 +715,12 @@ def _(): threading.Thread(target=_).start() self.checkAndSwitchTo(self.careerInterface) - def __onTeammateFlyoutSummonerNameClicked(self, name): + def __onTeammateFlyoutSummonerNameClicked(self, puuid): self.careerInterface.w.close() self.careerInterface.showLoadingPage.emit() def _(): - summoner = Summoner(connector.getSummonerByName(name)) + summoner = Summoner(connector.getSummonerByPuuid(puuid)) # 改为puuid, 兼容外服 iconId = summoner.profileIconId icon = connector.getProfileIcon(iconId) @@ -766,7 +766,7 @@ def _(): champions = getRecentChampions(games['games']) self.careerInterface.careerInfoChanged.emit( - {'name': name, + {'name': summoner.completeName, 'icon': icon, 'level': level, 'xpSinceLastLevel': xpSinceLastLevel, @@ -844,7 +844,7 @@ def _(): champions = getRecentChampions(games['games']) self.careerInterface.careerInfoChanged.emit( - {'name': summoner.name, + {'name': summoner.completeName, 'icon': icon, 'level': level, 'xpSinceLastLevel': xpSinceLastLevel, @@ -1083,15 +1083,16 @@ def process_item(item): ] fateFlag = None - if self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['summoners']]: - # 上把队友 - fateFlag = "ally" - elif self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['enemies']]: - # 上把对面 - fateFlag = "enemy" + if teammatesInfo: # 判个空, 避免太久没有打游戏的玩家或新号引发异常 + if self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['summoners']]: + # 上把队友 + fateFlag = "ally" + elif self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['enemies']]: + # 上把对面 + fateFlag = "enemy" return { - "name": summoner["displayName"], + "name": summoner["gameName"] or summoner["displayName"], "icon": icon, "level": summoner["summonerLevel"], "rankInfo": rankInfo, @@ -1261,15 +1262,16 @@ def process_item(item, isAllys=False): ] fateFlag = None - if self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['summoners']]: - # 上把队友 - fateFlag = "ally" - elif self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['enemies']]: - # 上把对面 - fateFlag = "enemy" + if teammatesInfo: # 判个空, 避免太久没有打游戏的玩家或新号引发异常 + if self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['summoners']]: + # 上把队友 + fateFlag = "ally" + elif self.currentSummoner.summonerId in [t['summonerId'] for t in teammatesInfo[0]['enemies']]: + # 上把对面 + fateFlag = "enemy" return { - "name": summoner["displayName"], + "name": summoner.get("gameName") or summoner["displayName"], "icon": icon, "level": summoner["summonerLevel"], "rankInfo": rankInfo,