Skip to content

Commit

Permalink
BUG修复: 如果对局中有长时间未进行游戏的召唤师(查不到战绩)会因最近队友(对手)功能引发异常的BUG
Browse files Browse the repository at this point in the history
BUG修复: 兼容外服 riot id 改动引发的各种问题
BUG修复: 如果历史战绩中存在AI, 会因"战绩隐藏"标记引发异常的BUG
  • Loading branch information
Hpero4 committed Nov 23, 2023
1 parent 5e12b15 commit a13e923
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
4 changes: 3 additions & 1 deletion app/lol/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 # 兼容外服
7 changes: 5 additions & 2 deletions app/lol/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions app/view/career_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
44 changes: 23 additions & 21 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -766,7 +766,7 @@ def _():
champions = getRecentChampions(games['games'])

self.careerInterface.careerInfoChanged.emit(
{'name': name,
{'name': summoner.completeName,
'icon': icon,
'level': level,
'xpSinceLastLevel': xpSinceLastLevel,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a13e923

Please sign in to comment.