mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 22:05:12 +00:00
Compare commits
3 Commits
44b6d5cdf8
...
54aa1bafb5
| Author | SHA1 | Date | |
|---|---|---|---|
| 54aa1bafb5 | |||
| d756b0dc3f | |||
| e71118c09e |
@ -41,8 +41,9 @@ class Bounty(BountyUI):
|
||||
if action == 'stop':
|
||||
raise RequestHumanTakeover
|
||||
elif action == 'skip':
|
||||
self.config.task_delay(server_update=True)
|
||||
self.config.task_stop()
|
||||
with self.config.multi_set():
|
||||
self.config.task_delay(server_update=True)
|
||||
self.config.task_stop()
|
||||
|
||||
@property
|
||||
def is_ticket_enough(self) -> bool:
|
||||
|
||||
@ -12,7 +12,10 @@ class DataUpdate(UI):
|
||||
Page:
|
||||
in: page_work
|
||||
"""
|
||||
ap = DigitCounter(OCR_AP).ocr_single_line(self.device.image)
|
||||
ap, _, ap_total = DigitCounter(OCR_AP).ocr_single_line(self.device.image)
|
||||
if ap_total == 0:
|
||||
logger.warning('Invalid AP')
|
||||
return False
|
||||
# Data for Credit and Pyroxene
|
||||
ocr = Digit(OCR_DATA)
|
||||
timeout = Timer(2, count=6).start()
|
||||
@ -21,27 +24,28 @@ class DataUpdate(UI):
|
||||
if len(data) != 2:
|
||||
data = [data[0], data[-1]]
|
||||
logger.attr('Data', data)
|
||||
credit, pyroxene = [int(''.join([v for v in d.ocr_text if v.isdigit()])) for d in data]
|
||||
credit, pyroxene = [int(''.join(filter(lambda x: x.isdigit(), d.ocr_text))) for d in data]
|
||||
if credit > 0 or pyroxene > 0:
|
||||
break
|
||||
|
||||
logger.warning(f'Invalid credit and pyroxene: {data}')
|
||||
if timeout.reached():
|
||||
logger.warning('Get data timeout')
|
||||
break
|
||||
return False
|
||||
|
||||
logger.attr('Credit', credit)
|
||||
logger.attr('Pyroxene', pyroxene)
|
||||
with self.config.multi_set():
|
||||
self.config.stored.AP.set(ap[0], ap[2])
|
||||
self.config.stored.AP.set(ap, ap_total)
|
||||
self.config.stored.Credit.value = credit
|
||||
self.config.stored.Pyroxene.value = pyroxene
|
||||
|
||||
return ap, credit, pyroxene
|
||||
return True
|
||||
|
||||
def run(self):
|
||||
self.ui_ensure(page_work, acquire_lang_checked=False)
|
||||
|
||||
with self.config.multi_set():
|
||||
self._get_data()
|
||||
if self._get_data():
|
||||
self.config.task_delay(server_update=True)
|
||||
else:
|
||||
self.config.task_delay(minute=1)
|
||||
|
||||
@ -42,8 +42,9 @@ class Scrimmage(ScrimmageUI):
|
||||
if action == 'stop':
|
||||
raise RequestHumanTakeover
|
||||
elif action == 'skip':
|
||||
self.config.task_delay(server_update=True)
|
||||
self.config.task_stop()
|
||||
with self.config.multi_set():
|
||||
self.config.task_delay(server_update=True)
|
||||
self.config.task_stop()
|
||||
|
||||
@property
|
||||
def is_ticket_enough(self) -> bool:
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from module.base.base import ModuleBase
|
||||
from module.base.button import ClickButton, match_template
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import area_pad, area_size, area_offset
|
||||
from module.logger import logger
|
||||
@ -130,21 +128,6 @@ class StageList:
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _match_clickable_points(image, template, threshold=0.85):
|
||||
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
||||
template = cv2.cvtColor(template, cv2.COLOR_RGB2GRAY)
|
||||
|
||||
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
||||
loc = np.where(res >= threshold)
|
||||
return [point for point in zip(*loc[::-1])]
|
||||
|
||||
def is_sweepable(self, image, main: ModuleBase, skip_first_screenshot=True) -> bool:
|
||||
if not skip_first_screenshot:
|
||||
main.device.screenshot()
|
||||
|
||||
return match_template(image, self.sweepable.matched_button.image)
|
||||
|
||||
def select_index_enter(
|
||||
self,
|
||||
main: ModuleBase,
|
||||
@ -181,23 +164,21 @@ class StageList:
|
||||
|
||||
stage_item_box = area_pad((*offset, *area_size(self.stage_item)))
|
||||
search_box = area_offset(stage_item_box, index_box.box[:2])
|
||||
search_image = main.image_crop(search_box)
|
||||
self.sweepable.load_search(search_box)
|
||||
|
||||
if sweepable and not self.is_sweepable(search_image, main, skip_first_screenshot):
|
||||
if sweepable and not main.appear(self.sweepable):
|
||||
logger.warning(f'Index {index} is not sweepable')
|
||||
return False
|
||||
|
||||
points = self._match_clickable_points(search_image, self.enter.matched_button.image)
|
||||
self.enter.load_search(search_box)
|
||||
click_button = self.enter.match_multi_template(main.device.image)
|
||||
|
||||
if not points:
|
||||
if not click_button:
|
||||
logger.warning(f'No clickable {self.enter.name}')
|
||||
continue
|
||||
|
||||
point = area_offset((0, 0, *area_size(self.enter.button)), points[0])
|
||||
click_button = ClickButton(area_offset(point, search_box[:2]), name=self.enter.name)
|
||||
|
||||
if click_interval.reached_and_reset():
|
||||
main.device.click(click_button)
|
||||
main.device.click(click_button[0])
|
||||
return True
|
||||
|
||||
if timeout.reached():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user