Skip to content

Commit a3429db

Browse files
committed
fix: not update todayDrop bug && sometimes miss drop bug
1 parent a73d41b commit a3429db

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

EsportsHelper/GUIThread.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from EsportsHelper.Stats import stats
1717
from EsportsHelper.Utils import colorFlicker, getWebhookInfo, \
1818
getConfigInfo, getLiveRegionsInfo, getNextMatchTimeInfo, \
19-
getDropInfo, getSleepBalloonsInfo, cleanBriefInfo, \
19+
getSessionDropInfo, getSleepBalloonsInfo, cleanBriefInfo, \
2020
getLiveInfo, getInfo, getWarningInfo, formatExc, getSleepPeriodInfo
2121

2222
_ = i18n.getText
@@ -87,7 +87,7 @@ def run(self):
8787
)
8888

8989
is_dockerized = config.isDockerized
90-
dropInfo = getDropInfo()
90+
sessionDropInfo = getSessionDropInfo()
9191
configInfo = getConfigInfo()
9292
webhookInfo = getWebhookInfo()
9393
sleepPeriodInfo = getSleepPeriodInfo()
@@ -97,7 +97,7 @@ def run(self):
9797
style="bold yellow", title_align="left",
9898
title=_('电竞助手', color="bold blue") + str(config.version) + " " + sleepPeriodInfo,
9999
subtitle_align="right", subtitle=configInfo)),
100-
Layout(name="drop", renderable=Panel(dropInfo,
100+
Layout(name="drop", renderable=Panel(sessionDropInfo,
101101
title=_('运行期间掉宝', color="bold yellow"),
102102
title_align="left", style="bold yellow", subtitle=webhookInfo + " 一 " + todayDropsInfo, subtitle_align="right"))
103103
)
@@ -133,16 +133,14 @@ def run(self):
133133
frameCount = 0
134134
with Live(layout, auto_refresh=False, console=console) as live:
135135
while True:
136-
drops = ""
137-
if stats.sessionDropsDict:
138-
for key in stats.sessionDropsDict:
139-
drops += f"{key}: {stats.sessionDropsDict.get(key)}\t"
140-
dropInfo = drops if drops else _("暂无掉落", "bold yellow")
136+
sessionDropInfo = getSessionDropInfo()
141137
webhookInfo = getWebhookInfo()
142138
sessionDropNumber = len(stats.currentDropsList) - len(stats.initDropsList)
143-
Layout(name="drop", renderable=Panel(dropInfo,
144-
title=_('运行期间掉宝', color="bold yellow"),
145-
title_align="left", style="bold yellow", subtitle=webhookInfo + " " + todayDropsInfo, subtitle_align="right"))
139+
todayDropsInfo = _("今日掉宝", "bold yellow") + f":{stats.todayDrops}"
140+
layout["upper"]["banner"]["drop"].update(Panel(sessionDropInfo,
141+
title=_('运行期间掉宝', color="bold yellow"),
142+
title_align="left", style="bold yellow",
143+
subtitle=webhookInfo + " 一 " + todayDropsInfo, subtitle_align="right"))
146144
layout["upper"]["table"].update(setAccountTable(frameCount))
147145

148146
cleanBriefInfo()
@@ -167,7 +165,9 @@ def run(self):
167165
title_align="left", style="bold yellow"))
168166
layout["lower"]["live2"].update(Panel("\n".join(liveInfo2), style="bold yellow", title_align="left", title=modeInfo,
169167
subtitle=_("请我喝一杯咖啡", "bold cyan") + ":https://github.com/Yudaotor", subtitle_align="right"))
170-
layout["lower"]["info1"].update(Panel("\n".join(info1), subtitle=_("观看属地", "bold yellow") + ":" + watchRegion, subtitle_align="right", title=_("简略日志", "bold yellow"), title_align="left", style="bold yellow"))
168+
layout["lower"]["info1"].update(
169+
Panel("\n".join(info1), subtitle=_("观看属地", "bold yellow") + ":" + watchRegion, subtitle_align="right", title=_("简略日志", "bold yellow"),
170+
title_align="left", style="bold yellow"))
171171
layout["lower"]["info2"].update(
172172
Panel("\n".join(info2), subtitle=_("(详细请见log文件)", "bold yellow"), subtitle_align="right", style="bold yellow", title_align="right",
173173
title=_("代挂:闲鱼店铺搜Khalilc", "bold yellow")))

EsportsHelper/Rewards.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def checkNewDrops(self):
541541
with open(f'./dropsHistory/{strftime("%Y%m%d-")}drops.txt', "a+"):
542542
pass
543543
stats.todayDrops = 0
544-
newDropList = [drop for drop in stats.currentDropsList if stats.lastDropCheckTime <= drop.get("unlockedDateMillis", -1)]
544+
newDropList = [drop for drop in stats.currentDropsList if (stats.lastDropCheckTime - 6000) <= drop.get("unlockedDateMillis", -1)]
545545
# newDropList = [drop for drop in stats.currentDropsList if drop.get("cappedDrop", False)]
546546
if len(newDropList) > 0:
547547
newDrops = parseDropList(newDropList)

EsportsHelper/Utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ def checkRewardPage(driver, isInit=False):
504504
getRewardByLog(driver, isInit)
505505
if isInit:
506506
log.info(_log("初始化reward网站成功"))
507+
setTodayDropsNumber(isInit=True)
507508
if config.exportDrops:
508509
try:
509510
log.info(_log("总掉落文件生成中..."))
@@ -831,7 +832,7 @@ def getNextMatchTimeInfo():
831832
return nextMatchTime
832833

833834

834-
def getDropInfo():
835+
def getSessionDropInfo():
835836
"""
836837
Retrieves information about dropped rewards during the current session.
837838
@@ -1101,14 +1102,17 @@ def debugScreen(driver, lint="normal"):
11011102
log.error(formatExc(format_exc()))
11021103

11031104

1104-
def setTodayDropsNumber():
1105+
def setTodayDropsNumber(isInit=False):
11051106
"""
11061107
Set the number of drops for today.
11071108
11081109
This function retrieves all drop items from the current drop list (stats.currentDropsList) that have a drop time after midnight today and sets the count as stats.todayDrops.
11091110
11101111
"""
1111-
dropsList = stats.currentDropsList
1112+
if isInit:
1113+
dropsList = stats.initDropsList
1114+
else:
1115+
dropsList = stats.currentDropsList
11121116
currentTime = datetime.now()
11131117
midnightTime = currentTime.replace(hour=0, minute=0, second=0, microsecond=0)
11141118
midnightMillis = midnightTime.timestamp() * 1000

EsportsHelper/Webdriver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def addWebdriverOptions(options):
6161
- None
6262
"""
6363
if checkPort("localhost", 9222):
64-
log.error(_log("检测到端口9222被占用"))
64+
log.info(_log("检测到端口9222被占用"))
6565
if checkPort("localhost", 9229):
6666
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
6767
sock.bind(("localhost", 0))
@@ -78,10 +78,10 @@ def addWebdriverOptions(options):
7878
stats.debugPort = port
7979
else:
8080
stats.debugPort = 9229
81-
log.error(_log("使用默认端口9229"))
81+
log.info(_log("使用默认端口9229"))
8282
else:
8383
stats.debugPort = 9222
84-
log.error(_log("使用默认端口9222"))
84+
log.info(_log("使用默认端口9222"))
8585
options.add_argument("--disable-extensions")
8686
options.add_argument('--disable-audio-output')
8787
options.add_argument('--autoplay-policy=no-user-gesture-required')

0 commit comments

Comments
 (0)