1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2025-12-16 19:55:12 +00:00

perf: momotalk

This commit is contained in:
RedDeadDepresso 2024-01-03 23:51:36 +00:00 committed by YoursFunny
parent a627f76197
commit ee87f92252
Signed by: YoursFunny
GPG Key ID: 207EDC3CD5B40F9C
2 changed files with 3 additions and 14 deletions

View File

@ -33,7 +33,7 @@ class MomoTalk(MomoTalkUI):
return MomoTalkStatus.OPEN
case MomoTalkStatus.STORY:
if self.skip_story():
return MomoTalkStatus.OPEN
return MomoTalkStatus.CHAT
case MomoTalkStatus.FINISHED:
return status
case _:

View File

@ -33,6 +33,7 @@ class MomoTalkUI(UI):
super().__init__(config, device)
self.swipe_vector_range = (0.65, 0.85)
self.list = CHAT_AREA
self.click_coords = self.device.click_methods.get(self.config.Emulator_ControlMethod, self.device.click_adb)
def swipe_page(self, direction: str, main: ModuleBase, vector_range=None, reverse=False):
"""
@ -58,16 +59,6 @@ class MomoTalkUI(UI):
vector = (-vector[0], -vector[1])
main.device.swipe_vector(vector, self.list.button)
def select_then_check(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper, similarity=0.85):
timer = Timer(5, 10).start()
while 1:
self.device.screenshot()
self.appear_then_click(dest_enter, interval=1, similarity=similarity)
if self.appear(dest_check, similarity=similarity):
return True
if timer.reached():
return False
def select_then_disappear(self, dest_enter: ButtonWrapper, dest_check: ButtonWrapper):
timer = Timer(5, 10).start()
while 1:
@ -94,10 +85,8 @@ class MomoTalkUI(UI):
def click_all(self, template, x_add=0, y_add=0):
"""
Find the all the locations of the template adding an offset if specified and click them.
TODO: filter coords that are not inside the chat area as otherwise it will close momotalk.
If after filter, no coords then swipe.
"""
click_coords = self.device.click_methods.get(self.config.Emulator_ControlMethod, self.device.click_adb)
image = self.device.screenshot()
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
threshold = 0.8
@ -109,7 +98,7 @@ class MomoTalkUI(UI):
if seen:
if y_add != 0:
seen = filter(lambda x: point_in_area(x, CHAT_AREA.area), seen)
[click_coords(coords[0], coords[1]) for coords in seen]
[self.click_coords(coords[0], coords[1]) for coords in seen]
self.swipe_page("down", self)
return True
return False