mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 19:55:12 +00:00
Compare commits
11 Commits
85448c50b8
...
88720dae3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88720dae3e | ||
|
|
b22681b71a | ||
|
|
1b1304442f | ||
|
|
455c3219ec | ||
|
|
64a26cf836 | ||
|
|
15ece02855 | ||
|
|
628fd5c19a | ||
|
|
4164262753 | ||
|
|
8fc6d1fedc | ||
|
|
df43305ade | ||
|
|
56aab11f52 |
BIN
assets/en/login/OCR_YEAR.png
Normal file
BIN
assets/en/login/OCR_YEAR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
BIN
assets/zht/login/OCR_YEAR.png
Normal file
BIN
assets/zht/login/OCR_YEAR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
@ -368,7 +368,9 @@ class AzurLaneAutoScript:
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
from module.device.platform.platform_windows import PlatformWindows
|
from module.device.platform.platform_windows import PlatformWindows
|
||||||
|
from deploy.Windows.alas import AlasManager
|
||||||
PlatformWindows(self.config).kill_process_by_regex("aas\.exe")
|
PlatformWindows(self.config).kill_process_by_regex("aas\.exe")
|
||||||
|
AlasManager().alas_kill()
|
||||||
except:
|
except:
|
||||||
logger.error("Failed to stop AAS. It may be due to a lack of administrator privileges.")
|
logger.error("Failed to stop AAS. It may be due to a lack of administrator privileges.")
|
||||||
|
|
||||||
|
|||||||
@ -186,3 +186,6 @@ class Device(Screenshot, Control, AppControl, Platform):
|
|||||||
super().app_stop()
|
super().app_stop()
|
||||||
self.stuck_record_clear()
|
self.stuck_record_clear()
|
||||||
self.click_record_clear()
|
self.click_record_clear()
|
||||||
|
|
||||||
|
def back(self):
|
||||||
|
self.adb_shell("input keyevent 4")
|
||||||
@ -1,11 +1,12 @@
|
|||||||
from module.base.button import ButtonWrapper
|
from module.base.button import ButtonWrapper
|
||||||
from module.base.decorator import run_once
|
from module.base.decorator import run_once, Config
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.exception import GameNotRunningError, GamePageUnknownError
|
from module.exception import GameNotRunningError, GamePageUnknownError, RequestHumanTakeover
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Ocr
|
from module.ocr.ocr import Ocr, Digit
|
||||||
from tasks.base.main_page import MainPage
|
from tasks.base.main_page import MainPage
|
||||||
from tasks.base.page import Page, page_main
|
from tasks.base.page import Page, page_main
|
||||||
|
from tasks.login.assets.assets_login import LOGIN_LOADING, OCR_YEAR
|
||||||
from tasks.base.assets.assets_base_page import BACK
|
from tasks.base.assets.assets_base_page import BACK
|
||||||
|
|
||||||
|
|
||||||
@ -13,6 +14,16 @@ class UI(MainPage):
|
|||||||
ui_current: Page
|
ui_current: Page
|
||||||
ui_main_confirm_timer = Timer(0.2, count=2)
|
ui_main_confirm_timer = Timer(0.2, count=2)
|
||||||
|
|
||||||
|
@Config.when(Emulator_GameLanguage='zhs')
|
||||||
|
def appear_trademark_year(self):
|
||||||
|
ocr_year = Digit(OCR_YEAR).ocr_single_line(self.device.image)
|
||||||
|
return ocr_year == 2023
|
||||||
|
|
||||||
|
@Config.when(Emulator_GameLanguage=None)
|
||||||
|
def appear_trademark_year(self):
|
||||||
|
ocr_year = Digit(OCR_YEAR).ocr_single_line(self.device.image)
|
||||||
|
return ocr_year == 2021
|
||||||
|
|
||||||
def ui_page_appear(self, page):
|
def ui_page_appear(self, page):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
@ -50,6 +61,7 @@ class UI(MainPage):
|
|||||||
|
|
||||||
timeout = Timer(10, count=20).start()
|
timeout = Timer(10, count=20).start()
|
||||||
back_timer = Timer(0.5, count=2)
|
back_timer = Timer(0.5, count=2)
|
||||||
|
u2_back = True
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
skip_first_screenshot = False
|
skip_first_screenshot = False
|
||||||
@ -78,8 +90,19 @@ class UI(MainPage):
|
|||||||
timeout.reset()
|
timeout.reset()
|
||||||
continue
|
continue
|
||||||
if back_timer.reached_and_reset():
|
if back_timer.reached_and_reset():
|
||||||
|
# this might be bad but it works
|
||||||
|
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()
|
||||||
|
timeout.reset()
|
||||||
|
continue
|
||||||
logger.info("Unknown page, try to back")
|
logger.info("Unknown page, try to back")
|
||||||
self.device.click(BACK)
|
if u2_back:
|
||||||
|
self.device.back()
|
||||||
|
u2_back = False
|
||||||
|
else:
|
||||||
|
self.device.click(BACK)
|
||||||
|
u2_back = True
|
||||||
|
|
||||||
app_check()
|
app_check()
|
||||||
minicap_check()
|
minicap_check()
|
||||||
@ -107,7 +130,7 @@ class UI(MainPage):
|
|||||||
self.interval_clear(list(Page.iter_check_buttons()))
|
self.interval_clear(list(Page.iter_check_buttons()))
|
||||||
|
|
||||||
# loading_timer = Timer(0.5)
|
# loading_timer = Timer(0.5)
|
||||||
|
back_timer = Timer(10, 10)
|
||||||
logger.hr(f"UI goto {destination}")
|
logger.hr(f"UI goto {destination}")
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
@ -126,6 +149,7 @@ class UI(MainPage):
|
|||||||
# Destination page
|
# Destination page
|
||||||
if self.ui_page_appear(destination):
|
if self.ui_page_appear(destination):
|
||||||
logger.info(f'Page arrive: {destination}')
|
logger.info(f'Page arrive: {destination}')
|
||||||
|
self.close_popup(destination.check_button)
|
||||||
if self.ui_page_confirm(destination):
|
if self.ui_page_confirm(destination):
|
||||||
logger.info(f'Page arrive confirm {destination}')
|
logger.info(f'Page arrive confirm {destination}')
|
||||||
break
|
break
|
||||||
@ -137,6 +161,7 @@ class UI(MainPage):
|
|||||||
continue
|
continue
|
||||||
if self.appear(page.check_button, interval=5):
|
if self.appear(page.check_button, interval=5):
|
||||||
logger.info(f'Page switch: {page} -> {page.parent}')
|
logger.info(f'Page switch: {page} -> {page.parent}')
|
||||||
|
self.close_popup(page.check_button)
|
||||||
# self.handle_lang_check(page)
|
# self.handle_lang_check(page)
|
||||||
if self.ui_page_confirm(page):
|
if self.ui_page_confirm(page):
|
||||||
logger.info(f'Page arrive confirm {page}')
|
logger.info(f'Page arrive confirm {page}')
|
||||||
@ -152,6 +177,15 @@ class UI(MainPage):
|
|||||||
if self.ui_additional():
|
if self.ui_additional():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
back_timer.start()
|
||||||
|
if back_timer.reached_and_reset():
|
||||||
|
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
|
# Reset connection
|
||||||
Page.clear_connection()
|
Page.clear_connection()
|
||||||
|
|
||||||
@ -176,6 +210,7 @@ class UI(MainPage):
|
|||||||
|
|
||||||
if self.ui_current == destination:
|
if self.ui_current == destination:
|
||||||
logger.info("Already at %s" % destination)
|
logger.info("Already at %s" % destination)
|
||||||
|
self.close_popup(destination.check_button)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
logger.info("Goto %s" % destination)
|
logger.info("Goto %s" % destination)
|
||||||
@ -399,3 +434,18 @@ class UI(MainPage):
|
|||||||
button (Button):
|
button (Button):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def close_popup(self, check_button):
|
||||||
|
if not self.match_color(check_button):
|
||||||
|
timer = Timer(5, 5).start()
|
||||||
|
wait = Timer(1).start()
|
||||||
|
while 1:
|
||||||
|
self.device.screenshot()
|
||||||
|
if self.match_color(check_button) or not self.appear(check_button):
|
||||||
|
break
|
||||||
|
self.device.back()
|
||||||
|
if timer.reached():
|
||||||
|
logger.error("Failed to close popup")
|
||||||
|
raise RequestHumanTakeover
|
||||||
|
while not wait.reached():
|
||||||
|
pass
|
||||||
@ -51,6 +51,24 @@ LOGIN_LOADING = ButtonWrapper(
|
|||||||
button=(34, 682, 60, 707),
|
button=(34, 682, 60, 707),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
OCR_YEAR = ButtonWrapper(
|
||||||
|
name='OCR_YEAR',
|
||||||
|
jp=None,
|
||||||
|
en=Button(
|
||||||
|
file='./assets/en/login/OCR_YEAR.png',
|
||||||
|
area=(377, 689, 414, 701),
|
||||||
|
search=(357, 669, 434, 720),
|
||||||
|
color=(160, 157, 158),
|
||||||
|
button=(377, 689, 414, 701),
|
||||||
|
),
|
||||||
|
zht=Button(
|
||||||
|
file='./assets/zht/login/OCR_YEAR.png',
|
||||||
|
area=(377, 689, 414, 701),
|
||||||
|
search=(357, 669, 434, 720),
|
||||||
|
color=(160, 157, 158),
|
||||||
|
button=(377, 689, 414, 701),
|
||||||
|
),
|
||||||
|
)
|
||||||
SURVEY = ButtonWrapper(
|
SURVEY = ButtonWrapper(
|
||||||
name='SURVEY',
|
name='SURVEY',
|
||||||
jp=None,
|
jp=None,
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.base.decorator import Config
|
|
||||||
from module.exception import GameNotRunningError
|
from module.exception import GameNotRunningError
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from tasks.base.page import page_main
|
from tasks.base.page import page_main
|
||||||
from tasks.base.ui import UI
|
from tasks.base.ui import UI
|
||||||
from tasks.login.assets.assets_login import LOGIN_CONFIRM, LOGIN_LOADING, UPDATE, SURVEY
|
from tasks.login.assets.assets_login import LOGIN_CONFIRM, LOGIN_LOADING, UPDATE
|
||||||
from tasks.base.assets.assets_base_page import MAIN_GO_TO_MAIL
|
|
||||||
|
|
||||||
|
|
||||||
class Login(UI):
|
class Login(UI):
|
||||||
@ -31,20 +29,11 @@ class Login(UI):
|
|||||||
return True
|
return True
|
||||||
return False
|
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')
|
logger.hr('App login')
|
||||||
orientation_timer = Timer(5)
|
orientation_timer = Timer(5)
|
||||||
startup_timer = Timer(5).start()
|
startup_timer = Timer(5).start()
|
||||||
app_timer = Timer(5).start()
|
app_timer = Timer(5).start()
|
||||||
|
back_timer = Timer(2).start()
|
||||||
login_success = False
|
login_success = False
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
@ -73,10 +62,11 @@ class Login(UI):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Watch resource downloading and loading
|
# Watch resource downloading and loading
|
||||||
|
loading = False
|
||||||
if self.match_color(LOGIN_LOADING, interval=5, threshold=45):
|
if self.match_color(LOGIN_LOADING, interval=5, threshold=45):
|
||||||
logger.info('Game resources downloading or loading')
|
logger.info('Game resources downloading or loading')
|
||||||
self.device.stuck_record_clear()
|
self.device.stuck_record_clear()
|
||||||
|
loading = True
|
||||||
# Login
|
# Login
|
||||||
if self.appear_then_click(LOGIN_CONFIRM):
|
if self.appear_then_click(LOGIN_CONFIRM):
|
||||||
login_success = True
|
login_success = True
|
||||||
@ -90,14 +80,10 @@ class Login(UI):
|
|||||||
# continue
|
# continue
|
||||||
if self.appear_then_click(UPDATE):
|
if self.appear_then_click(UPDATE):
|
||||||
continue
|
continue
|
||||||
if _handle_survey(self):
|
|
||||||
continue
|
|
||||||
if self.ui_additional():
|
if self.ui_additional():
|
||||||
continue
|
continue
|
||||||
# press emulator back button when random popup in main
|
if not loading and back_timer.reached_and_reset() and not self.appear_trademark_year():
|
||||||
if self.appear(MAIN_GO_TO_MAIL) and not self.match_color(MAIN_GO_TO_MAIL):
|
self.device.back()
|
||||||
self.device.u2.press("back")
|
|
||||||
continue
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@ -114,6 +114,7 @@ class Schedule(ScheduleUI):
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.ui_ensure(page_schedule)
|
self.ui_ensure(page_schedule)
|
||||||
self.task = self.valid_task
|
self.task = self.valid_task
|
||||||
|
self.set_clickx()
|
||||||
action_timer = Timer(0.5, 1)
|
action_timer = Timer(0.5, 1)
|
||||||
status = ScheduleStatus.OCR
|
status = ScheduleStatus.OCR
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
|
from module.base.decorator import Config
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import DigitCounter
|
from module.ocr.ocr import DigitCounter
|
||||||
from tasks.base.ui import UI
|
from tasks.base.ui import UI
|
||||||
@ -7,12 +8,19 @@ from tasks.schedule.assets.assets_schedule import *
|
|||||||
from tasks.schedule.scroll_select import ScrollSelect
|
from tasks.schedule.scroll_select import ScrollSelect
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
SCROLL_SELECT = ScrollSelect(window_button=SCROLL, first_item_button=FIRST_ITEM, expected_button=LOCATIONS, clickx=1116)
|
SCROLL_SELECT = ScrollSelect(window_button=SCROLL, first_item_button=FIRST_ITEM, expected_button=LOCATIONS, clickx=1116)
|
||||||
xs = np.linspace(299, 995, 3, dtype=int)
|
xs = np.linspace(299, 995, 3, dtype=int)
|
||||||
ys = np.linspace(268, 573, 3, dtype=int)
|
ys = np.linspace(268, 573, 3, dtype=int)
|
||||||
|
|
||||||
class ScheduleUI(UI):
|
class ScheduleUI(UI):
|
||||||
|
@Config.when(Emulator_GameLanguage='jp')
|
||||||
|
def set_clickx(self):
|
||||||
|
SCROLL_SELECT.clickx = 1114
|
||||||
|
|
||||||
|
@Config.when(Emulator_GameLanguage=None)
|
||||||
|
def set_clickx(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def select_then_check(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
|
def select_then_check(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
|
||||||
timer = Timer(8, 10).start()
|
timer = Timer(8, 10).start()
|
||||||
while 1:
|
while 1:
|
||||||
|
|||||||
@ -33,10 +33,10 @@ class TacticalChallenge(TacticalChallengeUI):
|
|||||||
return self.config.stored.TacticalChallengeTicket.value
|
return self.config.stored.TacticalChallengeTicket.value
|
||||||
|
|
||||||
def _player_select(self, select):
|
def _player_select(self, select):
|
||||||
if select:
|
if not select:
|
||||||
return random.choice(self.select_players)
|
return random.choice(self.select_players)
|
||||||
else:
|
else:
|
||||||
return self.select_players[select]
|
return self.select_players[select-1]
|
||||||
|
|
||||||
def _handle_challenge(self, status):
|
def _handle_challenge(self, status):
|
||||||
match status:
|
match status:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user