Fix: interval_is_reached() and interval_reset() should have the same interval

This commit is contained in:
LmeSzinc 2023-10-18 21:43:26 +08:00
parent 6c9678cf87
commit c4f19cf41a
4 changed files with 13 additions and 12 deletions

View File

@ -95,18 +95,18 @@ class AssignmentDispatch(AssignmentUI):
# Search EMPTY_SLOT to load offset
if not self.appear(CHARACTER_LIST) and self.appear(EMPTY_SLOT):
if self.interval_is_reached(CHARACTER_LIST, interval=2):
self.interval_reset(CHARACTER_LIST, interval=2)
self.device.click(EMPTY_SLOT)
self.interval_reset(CHARACTER_LIST, interval=2)
continue
# Select
if self.interval_is_reached(CHARACTER_1_SELECTED, interval=2):
self.interval_reset(CHARACTER_1_SELECTED, interval=2)
if not self.image_color_count(CHARACTER_1_SELECTED, (240, 240, 240)):
self.device.click(CHARACTER_1)
self.interval_reset(CHARACTER_1_SELECTED, interval=2)
if self.interval_is_reached(CHARACTER_2_SELECTED, interval=2):
self.interval_reset(CHARACTER_2_SELECTED, interval=2)
if not self.image_color_count(CHARACTER_2_SELECTED, (240, 240, 240)):
self.device.click(CHARACTER_2)
self.interval_reset(CHARACTER_2_SELECTED, interval=2)
def _select_support(self):
skip_first_screenshot = True
@ -124,13 +124,13 @@ class AssignmentDispatch(AssignmentUI):
# Ensure support list
if not self.appear(CHARACTER_SUPPORT_LIST):
if self.interval_is_reached(CHARACTER_SUPPORT_LIST, interval=2):
self.interval_reset(CHARACTER_SUPPORT_LIST, interval=2)
self.device.click(EMPTY_SLOT_SUPPORT)
self.interval_reset(CHARACTER_SUPPORT_LIST, interval=2)
continue
# Select
if self.interval_is_reached(CHARACTER_SUPPORT_SELECTED, interval=2):
self.interval_reset(CHARACTER_SUPPORT_SELECTED, interval=2)
self.device.click(CHARACTER_SUPPORT)
self.interval_reset(CHARACTER_SUPPORT_SELECTED, interval=2)
def _select_duration(self, duration: int):
if duration not in {4, 8, 12, 20}:

View File

@ -110,10 +110,10 @@ class PopupHandler(ModuleBase):
If handled.
"""
if callable(appear_button):
if self.interval_is_reached(appear_button) and appear_button():
if self.interval_is_reached(appear_button, interval=interval) and appear_button():
logger.info(f'{appear_button.__name__} -> {CLOSE}')
self.device.click(CLOSE)
self.interval_reset(appear_button)
self.interval_reset(appear_button, interval=interval)
return True
else:
if self.appear(appear_button, interval=interval):
@ -133,10 +133,10 @@ class PopupHandler(ModuleBase):
If handled.
"""
if callable(appear_button):
if self.interval_is_reached(appear_button) and appear_button():
if self.interval_is_reached(appear_button, interval=interval) and appear_button():
logger.info(f'{appear_button.__name__} -> {BACK}')
self.device.click(BACK)
self.interval_reset(appear_button)
self.interval_reset(appear_button, interval=interval)
return True
else:
if self.appear(appear_button, interval=interval):

View File

@ -89,7 +89,7 @@ class RogueRewardHandler(RogueUI):
if self.interval_is_reached(CLAIM_ALL, interval=1):
if self.image_color_count(CLAIM_ALL, color=(255, 199, 89), threshold=221, count=500):
self.device.click(CLAIM_ALL)
self.interval_reset(CLAIM_ALL)
self.interval_reset(CLAIM_ALL, interval=1)
appear = True
continue

View File

@ -159,6 +159,7 @@ class RogueEvent(RogueUI):
self.device.click(BLESSING_CONFIRM)
return True
if self.appear_then_click(CHOOSE_STORY, interval=2):
self.device.click_record_clear()
return True
if self.appear_then_click(CHOOSE_OPTION_CONFIRM, interval=2):
self.interval_reset([
@ -189,7 +190,7 @@ class RogueEvent(RogueUI):
if count == 1:
if self.interval_is_reached(CHOOSE_OPTION, interval=2):
self.device.click(self.valid_options[0].prefix_icon)
self.interval_reset(CHOOSE_OPTION)
self.interval_reset(CHOOSE_OPTION, interval=2)
return True
if self.interval_is_reached(CHOOSE_OPTION, interval=2):
@ -200,7 +201,7 @@ class RogueEvent(RogueUI):
else:
SCROLL_OPTION.set_top(main=self)
self.device.click(option.prefix_icon)
self.interval_reset(CHOOSE_OPTION)
self.interval_reset(CHOOSE_OPTION, interval=2)
return True
return False