mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-18 10:55:12 +00:00
style: format
This commit is contained in:
parent
e5f91e0c0a
commit
e6a3b79733
@ -1,7 +1,7 @@
|
|||||||
from module.base.base import ModuleBase
|
from module.base.base import ModuleBase
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from tasks.base.assets.assets_base_popup import *
|
|
||||||
from tasks.base.assets.assets_base_page import LOADING_CHECK
|
from tasks.base.assets.assets_base_page import LOADING_CHECK
|
||||||
|
from tasks.base.assets.assets_base_popup import *
|
||||||
|
|
||||||
|
|
||||||
class PopupHandler(ModuleBase):
|
class PopupHandler(ModuleBase):
|
||||||
@ -123,4 +123,3 @@ class PopupHandler(ModuleBase):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -5,10 +5,10 @@ from module.base.utils import get_color
|
|||||||
from module.exception import GameNotRunningError, GamePageUnknownError, RequestHumanTakeover
|
from module.exception import GameNotRunningError, GamePageUnknownError, RequestHumanTakeover
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Ocr, Digit
|
from module.ocr.ocr import Ocr, Digit
|
||||||
|
from tasks.base.assets.assets_base_page import BACK
|
||||||
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.login.assets.assets_login import LOGIN_LOADING, OCR_YEAR
|
||||||
from tasks.base.assets.assets_base_page import BACK
|
|
||||||
|
|
||||||
|
|
||||||
class UI(MainPage):
|
class UI(MainPage):
|
||||||
@ -191,7 +191,6 @@ class UI(MainPage):
|
|||||||
logger.info("Unknown page, try to back")
|
logger.info("Unknown page, try to back")
|
||||||
back_timer.reset()
|
back_timer.reset()
|
||||||
|
|
||||||
|
|
||||||
# Reset connection
|
# Reset connection
|
||||||
Page.clear_connection()
|
Page.clear_connection()
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ class Login(UI):
|
|||||||
GameTooManyClickError:
|
GameTooManyClickError:
|
||||||
GameNotRunningError:
|
GameNotRunningError:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _page_main_twice_confirm():
|
def _page_main_twice_confirm():
|
||||||
if self.ui_page_appear(page_main):
|
if self.ui_page_appear(page_main):
|
||||||
timer = Timer(1).start()
|
timer = Timer(1).start()
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
from module.base.timer import Timer
|
|
||||||
from module.exception import RequestHumanTakeover
|
|
||||||
from module.logger import logger
|
|
||||||
from tasks.mission.ui import MissionUI, CommissionsUI, SWITCH_QUEST
|
|
||||||
from tasks.stage.ap import AP
|
|
||||||
from tasks.cafe.cafe import Cafe
|
|
||||||
from tasks.circle.circle import Circle
|
|
||||||
from tasks.task.task import Task
|
|
||||||
from tasks.mail.mail import Mail
|
|
||||||
from tasks.item.data_update import DataUpdate
|
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
from filelock import FileLock
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
from filelock import FileLock
|
||||||
|
|
||||||
|
from module.base.timer import Timer
|
||||||
|
from module.logger import logger
|
||||||
|
from tasks.cafe.cafe import Cafe
|
||||||
|
from tasks.circle.circle import Circle
|
||||||
|
from tasks.item.data_update import DataUpdate
|
||||||
|
from tasks.mail.mail import Mail
|
||||||
|
from tasks.mission.ui import MissionUI, CommissionsUI, SWITCH_QUEST
|
||||||
|
from tasks.task.task import Task
|
||||||
|
|
||||||
|
|
||||||
class MissionStatus(Enum):
|
class MissionStatus(Enum):
|
||||||
AP = 0 # Calculate AP and decide to terminate Mission module or not
|
AP = 0 # Calculate AP and decide to terminate Mission module or not
|
||||||
@ -196,7 +196,8 @@ class Mission(MissionUI, CommissionsUI):
|
|||||||
Check if AP related modules such as cafe, circle, task, mail are enabled and run them if they are.
|
Check if AP related modules such as cafe, circle, task, mail are enabled and run them if they are.
|
||||||
task_call only works after the current task is finished so is not suitable.
|
task_call only works after the current task is finished so is not suitable.
|
||||||
"""
|
"""
|
||||||
cafe_reward = self.config.cross_get(["Cafe", "Scheduler", "Enable"]) and self.config.cross_get(["Cafe", "Cafe", "Reward"])
|
cafe_reward = self.config.cross_get(["Cafe", "Scheduler", "Enable"]) and self.config.cross_get(
|
||||||
|
["Cafe", "Cafe", "Reward"])
|
||||||
circle = self.config.cross_get(["Circle", "Scheduler", "Enable"])
|
circle = self.config.cross_get(["Circle", "Scheduler", "Enable"])
|
||||||
task = self.config.cross_get(["Task", "Scheduler", "Enable"])
|
task = self.config.cross_get(["Task", "Scheduler", "Enable"])
|
||||||
mail = self.config.cross_get(["Mail", "Scheduler", "Enable"])
|
mail = self.config.cross_get(["Mail", "Scheduler", "Enable"])
|
||||||
@ -280,4 +281,3 @@ class Mission(MissionUI, CommissionsUI):
|
|||||||
|
|
||||||
# delay mission to 7 hours if there are still stages in the queue
|
# delay mission to 7 hours if there are still stages in the queue
|
||||||
self.config.task_delay(minute=420) if self.task else self.config.task_delay(server_update=True)
|
self.config.task_delay(minute=420) if self.task else self.config.task_delay(server_update=True)
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ui.switch import Switch
|
|
||||||
from module.ocr.ocr import Digit
|
from module.ocr.ocr import Digit
|
||||||
|
from module.ui.switch import Switch
|
||||||
from tasks.base.assets.assets_base_page import BACK, MISSION_CHECK, EVENT_CHECK, WORK_GO_TO_EVENT
|
from tasks.base.assets.assets_base_page import BACK, MISSION_CHECK, EVENT_CHECK, WORK_GO_TO_EVENT
|
||||||
from tasks.base.page import page_mission, page_commissions, page_work # ,page_event
|
from tasks.base.page import page_mission, page_commissions, page_work # ,page_event
|
||||||
from tasks.base.ui import UI
|
from tasks.base.ui import UI
|
||||||
@ -136,8 +136,10 @@ class MissionUI(UI, AP):
|
|||||||
while not timer.reached_and_reset():
|
while not timer.reached_and_reset():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CommissionsUI(UI, AP):
|
class CommissionsUI(UI, AP):
|
||||||
"""Works the same way as select_bounty"""
|
"""Works the same way as select_bounty"""
|
||||||
|
|
||||||
def select_commission(self, mode):
|
def select_commission(self, mode):
|
||||||
if mode == "CR":
|
if mode == "CR":
|
||||||
dest_enter, dest_check = SELECT_CR, CHECK_CR
|
dest_enter, dest_check = SELECT_CR, CHECK_CR
|
||||||
|
|||||||
@ -2,9 +2,9 @@ from enum import Enum
|
|||||||
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from tasks.tactical_challenge.assets.assets_tactical_challenge import *
|
|
||||||
from tasks.momotalk.ui import MomoTalkUI
|
from tasks.momotalk.ui import MomoTalkUI
|
||||||
|
|
||||||
|
|
||||||
class MomoTalkStatus(Enum):
|
class MomoTalkStatus(Enum):
|
||||||
OPEN = 0
|
OPEN = 0
|
||||||
SORT = 1
|
SORT = 1
|
||||||
@ -13,6 +13,7 @@ class MomoTalkStatus(Enum):
|
|||||||
STORY = 4
|
STORY = 4
|
||||||
FINISHED = -1
|
FINISHED = -1
|
||||||
|
|
||||||
|
|
||||||
class MomoTalk(MomoTalkUI):
|
class MomoTalk(MomoTalkUI):
|
||||||
def handle_momotalk(self, status):
|
def handle_momotalk(self, status):
|
||||||
match status:
|
match status:
|
||||||
@ -58,4 +59,3 @@ class MomoTalk(MomoTalkUI):
|
|||||||
break
|
break
|
||||||
|
|
||||||
self.config.task_delay(server_update=True)
|
self.config.task_delay(server_update=True)
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ REPLY_TEMPLATE = REPLY.matched_button.image
|
|||||||
STORY_TEMPLATE = STORY.matched_button.image
|
STORY_TEMPLATE = STORY.matched_button.image
|
||||||
CHATTING_TEMPLATE = CHATTING.matched_button.image
|
CHATTING_TEMPLATE = CHATTING.matched_button.image
|
||||||
|
|
||||||
|
|
||||||
class MomoTalkUI(UI):
|
class MomoTalkUI(UI):
|
||||||
def __init__(self, config, device):
|
def __init__(self, config, device):
|
||||||
super().__init__(config, device)
|
super().__init__(config, device)
|
||||||
@ -184,5 +185,3 @@ class MomoTalkUI(UI):
|
|||||||
while not timer.reached_and_reset():
|
while not timer.reached_and_reset():
|
||||||
pass
|
pass
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
|
import re
|
||||||
from enum import Flag
|
from enum import Flag
|
||||||
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.exception import RequestHumanTakeover
|
from module.exception import RequestHumanTakeover
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from tasks.base.assets.assets_base_page import BACK
|
from tasks.base.assets.assets_base_page import BACK
|
||||||
|
from tasks.base.assets.assets_base_page import SCHEDULE_CHECK
|
||||||
from tasks.base.page import page_schedule
|
from tasks.base.page import page_schedule
|
||||||
from tasks.schedule.ui import ScheduleUI
|
from tasks.schedule.ui import ScheduleUI
|
||||||
from tasks.base.assets.assets_base_page import SCHEDULE_CHECK
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
class ScheduleStatus(Flag):
|
class ScheduleStatus(Flag):
|
||||||
OCR = 0
|
OCR = 0
|
||||||
@ -28,7 +28,8 @@ class Schedule(ScheduleUI):
|
|||||||
|
|
||||||
for choice in choices:
|
for choice in choices:
|
||||||
location, classrooms = schedule_config[choice]["Location"], schedule_config[choice]["Classrooms"]
|
location, classrooms = schedule_config[choice]["Location"], schedule_config[choice]["Classrooms"]
|
||||||
if location == "None" or not classrooms or (isinstance(classrooms, str) and classrooms.replace(" ", "") == ""):
|
if location == "None" or not classrooms or (
|
||||||
|
isinstance(classrooms, str) and classrooms.replace(" ", "") == ""):
|
||||||
continue
|
continue
|
||||||
elif isinstance(classrooms, int):
|
elif isinstance(classrooms, int):
|
||||||
classrooms_list = [str(classrooms)]
|
classrooms_list = [str(classrooms)]
|
||||||
|
|||||||
@ -3,8 +3,8 @@ Original Author: sanmusen214(https://github.com/sanmusen214)
|
|||||||
Adapted from https://github.com/sanmusen214/BAAH/blob/1.2/modules/AllTask/SubTask/ScrollSelect.py
|
Adapted from https://github.com/sanmusen214/BAAH/blob/1.2/modules/AllTask/SubTask/ScrollSelect.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from module.logger import logger
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
|
from module.logger import logger
|
||||||
|
|
||||||
|
|
||||||
class ScrollSelect:
|
class ScrollSelect:
|
||||||
@ -30,7 +30,9 @@ class ScrollSelect:
|
|||||||
finalclick: bool
|
finalclick: bool
|
||||||
Whether to click on clickx and the last row after the sliding ends
|
Whether to click on clickx and the last row after the sliding ends
|
||||||
"""
|
"""
|
||||||
def __init__(self, window_button, first_item_button, expected_button, clickx, swipeoffsetx=-100, finalclick=True) -> None:
|
|
||||||
|
def __init__(self, window_button, first_item_button, expected_button, clickx, swipeoffsetx=-100,
|
||||||
|
finalclick=True) -> None:
|
||||||
# TODO: Actually, only concerned about the height of one element, completely displaying the Y of the first button, completely displaying the Y of the bottom button, the number of complete elements that the window can contain, the height of the last element in the window, and the left offset and response distance.
|
# TODO: Actually, only concerned about the height of one element, completely displaying the Y of the first button, completely displaying the Y of the bottom button, the number of complete elements that the window can contain, the height of the last element in the window, and the left offset and response distance.
|
||||||
self.window_starty = window_button.area[1]
|
self.window_starty = window_button.area[1]
|
||||||
self.window_endy = window_button.area[3]
|
self.window_endy = window_button.area[3]
|
||||||
@ -54,7 +56,8 @@ class ScrollSelect:
|
|||||||
main.device.swipe((x1, y1), (x1, y1 - (distance + responsey)), duration=2)
|
main.device.swipe((x1, y1), (x1, y1 - (distance + responsey)), duration=2)
|
||||||
else:
|
else:
|
||||||
# Effective swipe distance for the Chinese server is 60
|
# Effective swipe distance for the Chinese server is 60
|
||||||
main.device.swipe((x1, y1), (x1, int(y1 - (distance + responsey - 4 * (1 + distance / 100)))), duration=1 + distance / 100)
|
main.device.swipe((x1, y1), (x1, int(y1 - (distance + responsey - 4 * (1 + distance / 100)))),
|
||||||
|
duration=1 + distance / 100)
|
||||||
|
|
||||||
def select_location(self, main, target_index) -> None:
|
def select_location(self, main, target_index) -> None:
|
||||||
click_coords = main.device.click_methods.get(main.config.Emulator_ControlMethod, main.device.click_adb)
|
click_coords = main.device.click_methods.get(main.config.Emulator_ControlMethod, main.device.click_adb)
|
||||||
@ -86,7 +89,8 @@ class ScrollSelect:
|
|||||||
scrolltotal_distance = (target_index - itemcount) * self.itemheight + hiddenlastitemheight
|
scrolltotal_distance = (target_index - itemcount) * self.itemheight + hiddenlastitemheight
|
||||||
logger.info("Height hidden by the last element: %d" % hiddenlastitemheight)
|
logger.info("Height hidden by the last element: %d" % hiddenlastitemheight)
|
||||||
# First, slide up the hidden part, add a little distance to let the system recognize it as a swipe event
|
# First, slide up the hidden part, add a little distance to let the system recognize it as a swipe event
|
||||||
self.compute_swipe(main, self.clickx + self.swipeoffsetx, scroll_start_from_y, hiddenlastitemheight, self.responsey)
|
self.compute_swipe(main, self.clickx + self.swipeoffsetx, scroll_start_from_y, hiddenlastitemheight,
|
||||||
|
self.responsey)
|
||||||
logger.info(f"Swipe distance: {hiddenlastitemheight}")
|
logger.info(f"Swipe distance: {hiddenlastitemheight}")
|
||||||
# Update scrolltotal_distance
|
# Update scrolltotal_distance
|
||||||
scrolltotal_distance -= hiddenlastitemheight
|
scrolltotal_distance -= hiddenlastitemheight
|
||||||
@ -97,11 +101,13 @@ class ScrollSelect:
|
|||||||
else:
|
else:
|
||||||
scroll_distance = (itemcount - 1) * self.itemheight
|
scroll_distance = (itemcount - 1) * self.itemheight
|
||||||
while scroll_distance <= scrolltotal_distance:
|
while scroll_distance <= scrolltotal_distance:
|
||||||
self.compute_swipe(main, self.clickx + self.swipeoffsetx, scroll_start_from_y, scroll_distance, self.responsey)
|
self.compute_swipe(main, self.clickx + self.swipeoffsetx, scroll_start_from_y, scroll_distance,
|
||||||
|
self.responsey)
|
||||||
scrolltotal_distance -= scroll_distance
|
scrolltotal_distance -= scroll_distance
|
||||||
if scrolltotal_distance > 5:
|
if scrolltotal_distance > 5:
|
||||||
# Last slide
|
# Last slide
|
||||||
self.compute_swipe(main, self.clickx + self.swipeoffsetx, scroll_start_from_y, scrolltotal_distance, self.responsey)
|
self.compute_swipe(main, self.clickx + self.swipeoffsetx, scroll_start_from_y, scrolltotal_distance,
|
||||||
|
self.responsey)
|
||||||
if self.finalclick:
|
if self.finalclick:
|
||||||
# Click on the last row
|
# Click on the last row
|
||||||
self.run_until(main,
|
self.run_until(main,
|
||||||
@ -146,4 +152,3 @@ class ScrollSelect:
|
|||||||
timer = Timer(0.5).start()
|
timer = Timer(0.5).start()
|
||||||
while not timer.reached_and_reset():
|
while not timer.reached_and_reset():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -1,17 +1,19 @@
|
|||||||
from module.base.timer import Timer
|
import numpy as np
|
||||||
|
|
||||||
from module.base.decorator import Config
|
from module.base.decorator import Config
|
||||||
|
from module.base.timer import Timer
|
||||||
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.assets.assets_base_page import SCHEDULE_CHECK
|
from tasks.base.assets.assets_base_page import SCHEDULE_CHECK
|
||||||
|
from tasks.base.ui import UI
|
||||||
from tasks.schedule.assets.assets_schedule import *
|
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
|
|
||||||
|
|
||||||
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')
|
@Config.when(Emulator_GameLanguage='jp')
|
||||||
def set_clickx(self):
|
def set_clickx(self):
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
from enum import Flag
|
from enum import Flag
|
||||||
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.exception import RequestHumanTakeover
|
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ui.switch import Switch
|
from module.ui.switch import Switch
|
||||||
from tasks.base.assets.assets_base_page import BACK
|
from tasks.base.assets.assets_base_page import BACK
|
||||||
@ -18,6 +17,7 @@ class ShopStatus(Flag):
|
|||||||
END = 4
|
END = 4
|
||||||
FINISH = -1
|
FINISH = -1
|
||||||
|
|
||||||
|
|
||||||
class Shop(ShopUI):
|
class Shop(ShopUI):
|
||||||
@property
|
@property
|
||||||
def shop_info(self):
|
def shop_info(self):
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from module.base.timer import Timer
|
|
||||||
from module.base.base import ModuleBase
|
from module.base.base import ModuleBase
|
||||||
|
from module.base.timer import Timer
|
||||||
from module.base.utils import area_size
|
from module.base.utils import area_size
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import DigitCounter
|
from module.ocr.ocr import DigitCounter
|
||||||
@ -16,6 +16,7 @@ ITEM_POSITIONS = {
|
|||||||
17: (650, 460), 18: (805, 460), 19: (960, 460), 20: (1110, 460),
|
17: (650, 460), 18: (805, 460), 19: (960, 460), 20: (1110, 460),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ShopUI(UI):
|
class ShopUI(UI):
|
||||||
def __init__(self, config, device):
|
def __init__(self, config, device):
|
||||||
super().__init__(config, device)
|
super().__init__(config, device)
|
||||||
@ -109,7 +110,8 @@ class ShopUI(UI):
|
|||||||
self.swipe_flags[8], self.swipe_flags[16] = False, False
|
self.swipe_flags[8], self.swipe_flags[16] = False, False
|
||||||
|
|
||||||
def make_purchase(self):
|
def make_purchase(self):
|
||||||
if self.match_color(PURCHASE) and self.select_then_check(PURCHASE, CONFIRM_PURCHASE) and self.appear_then_click(CONFIRM_PURCHASE):
|
if self.match_color(PURCHASE) and self.select_then_check(PURCHASE, CONFIRM_PURCHASE) and self.appear_then_click(
|
||||||
|
CONFIRM_PURCHASE):
|
||||||
return True
|
return True
|
||||||
logger.warning("No items were selected. Unable to purchase.")
|
logger.warning("No items were selected. Unable to purchase.")
|
||||||
return False
|
return False
|
||||||
@ -135,4 +137,3 @@ class ShopUI(UI):
|
|||||||
logger.warning('Invalid count')
|
logger.warning('Invalid count')
|
||||||
return False
|
return False
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user