Skip to content

Commit

Permalink
fix: not update todayDrop bug && sometimes miss drop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yudaotor committed Feb 21, 2024
1 parent a73d41b commit a3429db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
24 changes: 12 additions & 12 deletions EsportsHelper/GUIThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from EsportsHelper.Stats import stats
from EsportsHelper.Utils import colorFlicker, getWebhookInfo, \
getConfigInfo, getLiveRegionsInfo, getNextMatchTimeInfo, \
getDropInfo, getSleepBalloonsInfo, cleanBriefInfo, \
getSessionDropInfo, getSleepBalloonsInfo, cleanBriefInfo, \
getLiveInfo, getInfo, getWarningInfo, formatExc, getSleepPeriodInfo

_ = i18n.getText
Expand Down Expand Up @@ -87,7 +87,7 @@ def run(self):
)

is_dockerized = config.isDockerized
dropInfo = getDropInfo()
sessionDropInfo = getSessionDropInfo()
configInfo = getConfigInfo()
webhookInfo = getWebhookInfo()
sleepPeriodInfo = getSleepPeriodInfo()
Expand All @@ -97,7 +97,7 @@ def run(self):
style="bold yellow", title_align="left",
title=_('电竞助手', color="bold blue") + str(config.version) + " " + sleepPeriodInfo,
subtitle_align="right", subtitle=configInfo)),
Layout(name="drop", renderable=Panel(dropInfo,
Layout(name="drop", renderable=Panel(sessionDropInfo,
title=_('运行期间掉宝', color="bold yellow"),
title_align="left", style="bold yellow", subtitle=webhookInfo + " 一 " + todayDropsInfo, subtitle_align="right"))
)
Expand Down Expand Up @@ -133,16 +133,14 @@ def run(self):
frameCount = 0
with Live(layout, auto_refresh=False, console=console) as live:
while True:
drops = ""
if stats.sessionDropsDict:
for key in stats.sessionDropsDict:
drops += f"{key}: {stats.sessionDropsDict.get(key)}\t"
dropInfo = drops if drops else _("暂无掉落", "bold yellow")
sessionDropInfo = getSessionDropInfo()
webhookInfo = getWebhookInfo()
sessionDropNumber = len(stats.currentDropsList) - len(stats.initDropsList)
Layout(name="drop", renderable=Panel(dropInfo,
title=_('运行期间掉宝', color="bold yellow"),
title_align="left", style="bold yellow", subtitle=webhookInfo + " " + todayDropsInfo, subtitle_align="right"))
todayDropsInfo = _("今日掉宝", "bold yellow") + f":{stats.todayDrops}"
layout["upper"]["banner"]["drop"].update(Panel(sessionDropInfo,
title=_('运行期间掉宝', color="bold yellow"),
title_align="left", style="bold yellow",
subtitle=webhookInfo + " 一 " + todayDropsInfo, subtitle_align="right"))
layout["upper"]["table"].update(setAccountTable(frameCount))

cleanBriefInfo()
Expand All @@ -167,7 +165,9 @@ def run(self):
title_align="left", style="bold yellow"))
layout["lower"]["live2"].update(Panel("\n".join(liveInfo2), style="bold yellow", title_align="left", title=modeInfo,
subtitle=_("请我喝一杯咖啡", "bold cyan") + ":https://github.com/Yudaotor", subtitle_align="right"))
layout["lower"]["info1"].update(Panel("\n".join(info1), subtitle=_("观看属地", "bold yellow") + ":" + watchRegion, subtitle_align="right", title=_("简略日志", "bold yellow"), title_align="left", style="bold yellow"))
layout["lower"]["info1"].update(
Panel("\n".join(info1), subtitle=_("观看属地", "bold yellow") + ":" + watchRegion, subtitle_align="right", title=_("简略日志", "bold yellow"),
title_align="left", style="bold yellow"))
layout["lower"]["info2"].update(
Panel("\n".join(info2), subtitle=_("(详细请见log文件)", "bold yellow"), subtitle_align="right", style="bold yellow", title_align="right",
title=_("代挂:闲鱼店铺搜Khalilc", "bold yellow")))
Expand Down
2 changes: 1 addition & 1 deletion EsportsHelper/Rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def checkNewDrops(self):
with open(f'./dropsHistory/{strftime("%Y%m%d-")}drops.txt', "a+"):
pass
stats.todayDrops = 0
newDropList = [drop for drop in stats.currentDropsList if stats.lastDropCheckTime <= drop.get("unlockedDateMillis", -1)]
newDropList = [drop for drop in stats.currentDropsList if (stats.lastDropCheckTime - 6000) <= drop.get("unlockedDateMillis", -1)]
# newDropList = [drop for drop in stats.currentDropsList if drop.get("cappedDrop", False)]
if len(newDropList) > 0:
newDrops = parseDropList(newDropList)
Expand Down
10 changes: 7 additions & 3 deletions EsportsHelper/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ def checkRewardPage(driver, isInit=False):
getRewardByLog(driver, isInit)
if isInit:
log.info(_log("初始化reward网站成功"))
setTodayDropsNumber(isInit=True)
if config.exportDrops:
try:
log.info(_log("总掉落文件生成中..."))
Expand Down Expand Up @@ -831,7 +832,7 @@ def getNextMatchTimeInfo():
return nextMatchTime


def getDropInfo():
def getSessionDropInfo():
"""
Retrieves information about dropped rewards during the current session.
Expand Down Expand Up @@ -1101,14 +1102,17 @@ def debugScreen(driver, lint="normal"):
log.error(formatExc(format_exc()))


def setTodayDropsNumber():
def setTodayDropsNumber(isInit=False):
"""
Set the number of drops for today.
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.
"""
dropsList = stats.currentDropsList
if isInit:
dropsList = stats.initDropsList
else:
dropsList = stats.currentDropsList
currentTime = datetime.now()
midnightTime = currentTime.replace(hour=0, minute=0, second=0, microsecond=0)
midnightMillis = midnightTime.timestamp() * 1000
Expand Down
6 changes: 3 additions & 3 deletions EsportsHelper/Webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def addWebdriverOptions(options):
- None
"""
if checkPort("localhost", 9222):
log.error(_log("检测到端口9222被占用"))
log.info(_log("检测到端口9222被占用"))
if checkPort("localhost", 9229):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("localhost", 0))
Expand All @@ -78,10 +78,10 @@ def addWebdriverOptions(options):
stats.debugPort = port
else:
stats.debugPort = 9229
log.error(_log("使用默认端口9229"))
log.info(_log("使用默认端口9229"))
else:
stats.debugPort = 9222
log.error(_log("使用默认端口9222"))
log.info(_log("使用默认端口9222"))
options.add_argument("--disable-extensions")
options.add_argument('--disable-audio-output')
options.add_argument('--autoplay-policy=no-user-gesture-required')
Expand Down

0 comments on commit a3429db

Please sign in to comment.