1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2026-01-09 13:45:13 +00:00

Compare commits

..

No commits in common. "628fd5c19a38c1d7388916619dbe8234b3f72736" and "850eee7783f2e4212851d344a9b6ff07098f797b" have entirely different histories.

8 changed files with 12 additions and 76 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -1,12 +1,11 @@
from module.base.button import ButtonWrapper
from module.base.decorator import run_once, Config
from module.base.decorator import run_once
from module.base.timer import Timer
from module.exception import GameNotRunningError, GamePageUnknownError, RequestHumanTakeover
from module.exception import GameNotRunningError, GamePageUnknownError
from module.logger import logger
from module.ocr.ocr import Ocr, Digit
from module.ocr.ocr import Ocr
from tasks.base.main_page import MainPage
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
@ -14,16 +13,6 @@ class UI(MainPage):
ui_current: Page
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):
"""
Args:
@ -61,7 +50,6 @@ class UI(MainPage):
timeout = Timer(10, count=20).start()
back_timer = Timer(0.5, count=2)
u2_back = True
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
@ -89,19 +77,9 @@ class UI(MainPage):
logger.info("Additional ui page handled")
timeout.reset()
continue
# 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()
continue
if back_timer.reached_and_reset():
logger.info("Unknown page, try to back")
if u2_back:
self.device.u2.press("back")
u2_back = False
else:
self.device.click(BACK)
u2_back = True
self.device.click(BACK)
app_check()
minicap_check()
@ -198,12 +176,10 @@ class UI(MainPage):
if self.ui_current == destination:
logger.info("Already at %s" % destination)
self.close_popup(destination.check_button)
return False
else:
logger.info("Goto %s" % destination)
self.ui_goto(destination, skip_first_screenshot=True)
self.close_popup(destination.check_button)
return True
def ui_ensure_index(
@ -423,18 +399,3 @@ class UI(MainPage):
button (Button):
"""
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):
break
self.device.u2.press("back")
if timer.reached():
logger.error("Failed to close popup")
raise RequestHumanTakeover
while not wait.reached():
pass

View File

@ -51,24 +51,6 @@ LOGIN_LOADING = ButtonWrapper(
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(
name='SURVEY',
jp=None,

View File

@ -1,11 +1,11 @@
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, SURVEY
from tasks.base.assets.assets_base_page import MAIN_GO_TO_MAIL
class Login(UI):
@ -94,8 +94,10 @@ class Login(UI):
continue
if self.ui_additional():
continue
if not self.appear_trademark_year():
# press emulator back button when random popup in main
if self.appear(MAIN_GO_TO_MAIL) and not self.match_color(MAIN_GO_TO_MAIL):
self.device.u2.press("back")
continue
return True

View File

@ -114,7 +114,6 @@ class Schedule(ScheduleUI):
def run(self):
self.ui_ensure(page_schedule)
self.task = self.valid_task
self.set_clickx()
action_timer = Timer(0.5, 1)
status = ScheduleStatus.OCR

View File

@ -1,5 +1,4 @@
from module.base.timer import Timer
from module.base.decorator import Config
from module.logger import logger
from module.ocr.ocr import DigitCounter
from tasks.base.ui import UI
@ -8,19 +7,12 @@ from tasks.schedule.assets.assets_schedule import *
from tasks.schedule.scroll_select import ScrollSelect
import numpy as np
SCROLL_SELECT = ScrollSelect(window_button=SCROLL, first_item_button=FIRST_ITEM, expected_button=LOCATIONS, clickx=1116)
xs = np.linspace(299, 995, 3, dtype=int)
ys = np.linspace(268, 573, 3, dtype=int)
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):
timer = Timer(8, 10).start()
while 1:

View File

@ -33,10 +33,10 @@ class TacticalChallenge(TacticalChallengeUI):
return self.config.stored.TacticalChallengeTicket.value
def _player_select(self, select):
if not select:
if select:
return random.choice(self.select_players)
else:
return self.select_players[select-1]
return self.select_players[select]
def _handle_challenge(self, status):
match status: