Skip to content

Commit

Permalink
完善自动BP
Browse files Browse the repository at this point in the history
修复了不生效的bug
同时使之能够支持预选时亮起英雄防止被队友ban
  • Loading branch information
Ninohana authored Feb 13, 2024
1 parent 12f8018 commit 0e129ad
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,32 +971,30 @@ def __onChampSelectChanged(self, data):
return

# 自动 BP
# todo: 存在重复的data订阅数据需要做处理
def selectOrBan():
localPlayerCellId = data["data"]["localPlayerCellId"]
actions = data["data"]["actions"]

for action in actions:
action = action[0]

if action["actorCellId"] == localPlayerCellId and action["isInProgress"] and not action["completed"]:
actionId = action["id"]

if action["type"] == "pick":
if (cfg.get(cfg.enableAutoSelectChampion)):

championId = connector.manager.getChampionIdByName(
cfg.get(cfg.autoSelectChampion))
connector.selectChampion(action["id"], championId)
break
elif action["type"] == "ban":
if (cfg.get(cfg.enableAutoBanChampion) and data["data"]["bans"]["numBans"] > 0):
championId = connector.manager.getChampionIdByName(
cfg.get(cfg.autoBanChampion))
connector.banChampion(actionId, championId)
return

threading.Thread(target=selectOrBan).start()
isAutoBan = cfg.get(cfg.enableAutoBanChampion)
isAutoSelect = cfg.get(cfg.enableAutoSelectChampion)
if isAutoBan or isAutoSelect:
def selectOrBan():
localPlayerCellId = data["data"]["localPlayerCellId"]
actions = data["data"]["actions"]
for actionGroup in actions:
for action in actionGroup:
if (action["actorCellId"] == localPlayerCellId
and not action["completed"]):
actionId = action["id"]
if action["type"] == "pick" and isAutoSelect:
championId = connector.manager.getChampionIdByName(
cfg.get(cfg.autoSelectChampion))
connector.selectChampion(actionId, championId)
break
elif action["type"] == "ban" and isAutoBan:
if action["isInProgress"]:
championId = connector.manager.getChampionIdByName(
cfg.get(cfg.autoBanChampion))
connector.banChampion(actionId, championId)
break

threading.Thread(target=selectOrBan).start()

# 更新头像
summonersOrder = []
Expand Down

0 comments on commit 0e129ad

Please sign in to comment.