1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2025-12-16 19:55:12 +00:00

perf: login

This commit is contained in:
RedDeadDepresso 2024-01-09 19:57:30 +00:00
parent 15ece02855
commit 64a26cf836
3 changed files with 16 additions and 21 deletions

View File

@ -186,3 +186,6 @@ class Device(Screenshot, Control, AppControl, Platform):
super().app_stop()
self.stuck_record_clear()
self.click_record_clear()
def back(self):
self.u2.press("back")

View File

@ -98,7 +98,7 @@ class UI(MainPage):
continue
logger.info("Unknown page, try to back")
if u2_back:
self.device.u2.press("back")
self.device.back()
u2_back = False
else:
self.device.click(BACK)
@ -178,7 +178,11 @@ class UI(MainPage):
continue
if back_timer.reached_and_reset():
self.device.u2.press("back")
if self.match_color(LOGIN_LOADING, interval=5, threshold=80) or self.appear_trademark_year():
from tasks.login.login import Login
Login(self.config, self.device).handle_app_login()
continue
self.device.back()
logger.info("Unknown page, try to back")
# Reset connection
@ -439,7 +443,7 @@ class UI(MainPage):
self.device.screenshot()
if self.match_color(check_button):
break
self.device.u2.press("back")
self.device.back()
if timer.reached():
logger.error("Failed to close popup")
raise RequestHumanTakeover

View File

@ -1,11 +1,9 @@
from module.base.timer import Timer
from module.base.decorator import Config
from module.ocr.ocr import Digit
from module.exception import GameNotRunningError
from module.logger import logger
from tasks.base.page import page_main
from tasks.base.ui import UI
from tasks.login.assets.assets_login import LOGIN_CONFIRM, LOGIN_LOADING, UPDATE, SURVEY, OCR_YEAR
from tasks.login.assets.assets_login import LOGIN_CONFIRM, LOGIN_LOADING, UPDATE
class Login(UI):
@ -31,20 +29,11 @@ class Login(UI):
return True
return False
@Config.when(Emulator_GameLanguage='en')
def _handle_survey(self):
if self.appear_then_click(SURVEY):
return True
return False
@Config.when(Emulator_GameLanguage=None)
def _handle_survey(self):
pass
logger.hr('App login')
orientation_timer = Timer(5)
startup_timer = Timer(5).start()
app_timer = Timer(5).start()
back_timer = Timer(2).start()
login_success = False
while 1:
@ -73,10 +62,11 @@ class Login(UI):
break
# Watch resource downloading and loading
loading = False
if self.match_color(LOGIN_LOADING, interval=5, threshold=45):
logger.info('Game resources downloading or loading')
self.device.stuck_record_clear()
loading = True
# Login
if self.appear_then_click(LOGIN_CONFIRM):
login_success = True
@ -90,12 +80,10 @@ class Login(UI):
# continue
if self.appear_then_click(UPDATE):
continue
if _handle_survey(self):
continue
if self.ui_additional():
continue
if not self.appear_trademark_year():
self.device.u2.press("back")
if not loading and back_timer.reached_and_reset() and not self.appear_trademark_year():
self.device.back()
return True