Merge pull request #556 from LmeSzinc/dev

Bug fix
This commit is contained in:
LmeSzinc 2024-06-30 04:44:20 +08:00 committed by GitHub
commit 4cabc7c6ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 6 deletions

View File

@ -355,7 +355,7 @@ class DigitCounter(Ocr):
Do OCR on a counter, such as `14/15`, and returns 14, 1, 15 Do OCR on a counter, such as `14/15`, and returns 14, 1, 15
Returns: Returns:
int: int, int, int: current, remain, total
""" """
result = super().after_process(result) result = super().after_process(result)
logger.attr(name=self.name, text=str(result)) logger.attr(name=self.name, text=str(result))

View File

@ -8,6 +8,23 @@ from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_NAV, KEYWORDS_D
from tasks.dungeon.ui import DUNGEON_LIST from tasks.dungeon.ui import DUNGEON_LIST
class OcrWeeklyLimit(DigitCounter):
def format_result(self, result) -> tuple[int, int, int]:
current, remain, total = super().format_result(result)
# [OCR_WEEKLY_LIMIT format] 3/3 -> (33, -30, 3)
if current == 11:
current = 1
remain = total - current
if current == 22:
current = 2
remain = total - current
if current == 33:
current = 3
remain = total - current
return current, remain, total
class WeeklyDungeon(Dungeon): class WeeklyDungeon(Dungeon):
def require_compulsory_support(self) -> bool: def require_compulsory_support(self) -> bool:
return False return False
@ -31,7 +48,7 @@ class WeeklyDungeon(Dungeon):
Pages: Pages:
in: page_guide, Survival_Index, KEYWORDS_DUNGEON_NAV.Echo_of_War in: page_guide, Survival_Index, KEYWORDS_DUNGEON_NAV.Echo_of_War
""" """
ocr = DigitCounter(OCR_WEEKLY_LIMIT) ocr = OcrWeeklyLimit(OCR_WEEKLY_LIMIT)
current, _, _ = ocr.ocr_single_line(self.device.image) current, _, _ = ocr.ocr_single_line(self.device.image)
total = self.config.stored.EchoOfWar.FIXED_TOTAL total = self.config.stored.EchoOfWar.FIXED_TOTAL
if current <= total: if current <= total:

View File

@ -16,8 +16,12 @@ class XPath:
""" """
登录界面元素 登录界面元素
""" """
# 帐号登录界面的进入游戏按钮,有这按钮说明帐号没登录 # 帐号登录界面的进入游戏按钮
ACCOUNT_LOGIN = '//*[@text="进入游戏"]' ACCOUNT_LOGIN = '//*[@text="进入游戏"]'
# 帐号登录界面,有这些按钮说明帐号没登录
ACCOUNT_PASSWORD_LOGIN = '//*[@text="账号密码"]'
ACCOUNT_REGISTER = '//*[@text="立即注册"]'
ACCOUNT_FORGET_PASSWORD = '//*[@text="忘记密码"]'
# 登录后的弹窗,获得免费时长 # 登录后的弹窗,获得免费时长
GET_REWARD = '//*[@text="点击空白区域关闭"]' GET_REWARD = '//*[@text="点击空白区域关闭"]'
# 用户协议和隐私政策更新提示 # 用户协议和隐私政策更新提示
@ -107,7 +111,11 @@ class LoginAndroidCloud(ModuleBase):
if self.appear(XPath.START_GAME): if self.appear(XPath.START_GAME):
logger.info('Login to cloud main page') logger.info('Login to cloud main page')
break break
if self.appear(XPath.ACCOUNT_LOGIN): if (
self.appear(XPath.ACCOUNT_REGISTER)
or self.appear(XPath.ACCOUNT_PASSWORD_LOGIN)
or self.appear(XPath.ACCOUNT_FORGET_PASSWORD)
):
logger.critical('Account not login, you must have login once before running') logger.critical('Account not login, you must have login once before running')
raise RequestHumanTakeover raise RequestHumanTakeover
if update_checker.started() and update_checker.reached(): if update_checker.started() and update_checker.reached():
@ -119,6 +127,8 @@ class LoginAndroidCloud(ModuleBase):
# Click # Click
if self.appear_then_click(XPath.GET_REWARD): if self.appear_then_click(XPath.GET_REWARD):
continue continue
if self.appear_then_click(XPath.ACCOUNT_LOGIN):
continue
if self.appear_then_click(XPath.POPUP_CONFIRM): if self.appear_then_click(XPath.POPUP_CONFIRM):
update_checker.start() update_checker.start()
continue continue
@ -395,12 +405,15 @@ class LoginAndroidCloud(ModuleBase):
if self.appear(XPath.START_GAME): if self.appear(XPath.START_GAME):
logger.info('Cloud game is in main page') logger.info('Cloud game is in main page')
return True return True
elif self.appear(XPath.FLOAT_DELAY): if self.appear(XPath.FLOAT_DELAY):
logger.info('Cloud game is in game with float window expanded') logger.info('Cloud game is in game with float window expanded')
return True return True
elif self.appear(XPath.POPUP_CONFIRM): if self.appear(XPath.POPUP_CONFIRM):
logger.info('Cloud game have a popup') logger.info('Cloud game have a popup')
return True return True
if self.appear(XPath.ACCOUNT_LOGIN):
logger.info('Cloud game is at account login')
return True
logger.info('Not in cloud page') logger.info('Not in cloud page')
return False return False