mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 22:05: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.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_popup import *
|
||||
|
||||
|
||||
class PopupHandler(ModuleBase):
|
||||
@ -123,4 +123,3 @@ class PopupHandler(ModuleBase):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@ -5,10 +5,10 @@ from module.base.utils import get_color
|
||||
from module.exception import GameNotRunningError, GamePageUnknownError, RequestHumanTakeover
|
||||
from module.logger import logger
|
||||
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.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
|
||||
|
||||
|
||||
class UI(MainPage):
|
||||
@ -191,7 +191,6 @@ class UI(MainPage):
|
||||
logger.info("Unknown page, try to back")
|
||||
back_timer.reset()
|
||||
|
||||
|
||||
# Reset connection
|
||||
Page.clear_connection()
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ class Login(UI):
|
||||
GameTooManyClickError:
|
||||
GameNotRunningError:
|
||||
"""
|
||||
|
||||
def _page_main_twice_confirm():
|
||||
if self.ui_page_appear(page_main):
|
||||
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 math
|
||||
from filelock import FileLock
|
||||
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):
|
||||
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.
|
||||
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"])
|
||||
task = self.config.cross_get(["Task", "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
|
||||
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.logger import logger
|
||||
from module.ui.switch import Switch
|
||||
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.page import page_mission, page_commissions, page_work # ,page_event
|
||||
from tasks.base.ui import UI
|
||||
@ -136,8 +136,10 @@ class MissionUI(UI, AP):
|
||||
while not timer.reached_and_reset():
|
||||
pass
|
||||
|
||||
|
||||
class CommissionsUI(UI, AP):
|
||||
"""Works the same way as select_bounty"""
|
||||
|
||||
def select_commission(self, mode):
|
||||
if mode == "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.logger import logger
|
||||
from tasks.tactical_challenge.assets.assets_tactical_challenge import *
|
||||
from tasks.momotalk.ui import MomoTalkUI
|
||||
|
||||
|
||||
class MomoTalkStatus(Enum):
|
||||
OPEN = 0
|
||||
SORT = 1
|
||||
@ -13,6 +13,7 @@ class MomoTalkStatus(Enum):
|
||||
STORY = 4
|
||||
FINISHED = -1
|
||||
|
||||
|
||||
class MomoTalk(MomoTalkUI):
|
||||
def handle_momotalk(self, status):
|
||||
match status:
|
||||
@ -58,4 +59,3 @@ class MomoTalk(MomoTalkUI):
|
||||
break
|
||||
|
||||
self.config.task_delay(server_update=True)
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ REPLY_TEMPLATE = REPLY.matched_button.image
|
||||
STORY_TEMPLATE = STORY.matched_button.image
|
||||
CHATTING_TEMPLATE = CHATTING.matched_button.image
|
||||
|
||||
|
||||
class MomoTalkUI(UI):
|
||||
def __init__(self, config, device):
|
||||
super().__init__(config, device)
|
||||
@ -184,5 +185,3 @@ class MomoTalkUI(UI):
|
||||
while not timer.reached_and_reset():
|
||||
pass
|
||||
break
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import re
|
||||
from enum import Flag
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.exception import RequestHumanTakeover
|
||||
from module.logger import logger
|
||||
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.schedule.ui import ScheduleUI
|
||||
from tasks.base.assets.assets_base_page import SCHEDULE_CHECK
|
||||
|
||||
import re
|
||||
|
||||
class ScheduleStatus(Flag):
|
||||
OCR = 0
|
||||
@ -28,7 +28,8 @@ class Schedule(ScheduleUI):
|
||||
|
||||
for choice in choices:
|
||||
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
|
||||
elif isinstance(classrooms, int):
|
||||
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
|
||||
"""
|
||||
|
||||
from module.logger import logger
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
|
||||
|
||||
class ScrollSelect:
|
||||
@ -30,7 +30,9 @@ class ScrollSelect:
|
||||
finalclick: bool
|
||||
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.
|
||||
self.window_starty = window_button.area[1]
|
||||
self.window_endy = window_button.area[3]
|
||||
@ -54,7 +56,8 @@ class ScrollSelect:
|
||||
main.device.swipe((x1, y1), (x1, y1 - (distance + responsey)), duration=2)
|
||||
else:
|
||||
# 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:
|
||||
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
|
||||
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
|
||||
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}")
|
||||
# Update scrolltotal_distance
|
||||
scrolltotal_distance -= hiddenlastitemheight
|
||||
@ -97,11 +101,13 @@ class ScrollSelect:
|
||||
else:
|
||||
scroll_distance = (itemcount - 1) * self.itemheight
|
||||
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
|
||||
if scrolltotal_distance > 5:
|
||||
# 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:
|
||||
# Click on the last row
|
||||
self.run_until(main,
|
||||
@ -146,4 +152,3 @@ class ScrollSelect:
|
||||
timer = Timer(0.5).start()
|
||||
while not timer.reached_and_reset():
|
||||
pass
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
from module.base.timer import Timer
|
||||
import numpy as np
|
||||
|
||||
from module.base.decorator import Config
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
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.ui import UI
|
||||
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):
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from enum import Flag
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.exception import RequestHumanTakeover
|
||||
from module.logger import logger
|
||||
from module.ui.switch import Switch
|
||||
from tasks.base.assets.assets_base_page import BACK
|
||||
@ -18,6 +17,7 @@ class ShopStatus(Flag):
|
||||
END = 4
|
||||
FINISH = -1
|
||||
|
||||
|
||||
class Shop(ShopUI):
|
||||
@property
|
||||
def shop_info(self):
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from module.base.timer import Timer
|
||||
from module.base.base import ModuleBase
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import area_size
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import DigitCounter
|
||||
@ -16,6 +16,7 @@ ITEM_POSITIONS = {
|
||||
17: (650, 460), 18: (805, 460), 19: (960, 460), 20: (1110, 460),
|
||||
}
|
||||
|
||||
|
||||
class ShopUI(UI):
|
||||
def __init__(self, config, device):
|
||||
super().__init__(config, device)
|
||||
@ -109,7 +110,8 @@ class ShopUI(UI):
|
||||
self.swipe_flags[8], self.swipe_flags[16] = False, False
|
||||
|
||||
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
|
||||
logger.warning("No items were selected. Unable to purchase.")
|
||||
return False
|
||||
@ -135,4 +137,3 @@ class ShopUI(UI):
|
||||
logger.warning('Invalid count')
|
||||
return False
|
||||
return count
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user