Fix: Remove debug code and add click interval (#43)

This commit is contained in:
LmeSzinc 2023-07-15 01:23:35 +08:00
parent 211314aaa1
commit dc4240b198

View File

@ -44,22 +44,6 @@ class ConsumableUsageUI(ItemUI):
else: else:
return False return False
# def _switch_tag_to_consumables(self, skip_first_screenshot=True):
# while 1:
# if skip_first_screenshot:
# skip_first_screenshot = False
# else:
# self.device.screenshot()
#
# # Scroll bar delay appears, need an interval here
# if self.appear(ITEM_CONSUMABLE_CHECK, interval=1):
# logger.info('Item consumables page appear')
# break
# # Switch to consumables subpage
# if self.appear_then_click(ITEM_GOTO_CONSUMABLE):
# logger.info('Switch to consumables subpage')
# continue
def _search_and_select_consumable(self, skip_first_screenshot=True) -> bool: def _search_and_select_consumable(self, skip_first_screenshot=True) -> bool:
logger.info('Search consumable') logger.info('Search consumable')
# If the default subpage is the consumables page, it is necessary to screenshot and check subpage again, # If the default subpage is the consumables page, it is necessary to screenshot and check subpage again,
@ -86,10 +70,8 @@ class ConsumableUsageUI(ItemUI):
return True return True
if scroll.at_bottom(main=self) and not self.appear(SIMPLE_PROTECTIVE_GEAR, similarity=0.7): if scroll.at_bottom(main=self) and not self.appear(SIMPLE_PROTECTIVE_GEAR, similarity=0.7):
logger.info('Can not find the consumable which to be used, just skip') logger.info('Can not find the consumable which to be used, just skip')
from PIL import Image
Image.fromarray(self.device.image).save("./screenshots/image3.png")
return False return False
if self.appear_then_click(SIMPLE_PROTECTIVE_GEAR, similarity=0.7): if self.appear_then_click(SIMPLE_PROTECTIVE_GEAR, similarity=0.7, interval=2):
logger.info('Select the consumable which to be used') logger.info('Select the consumable which to be used')
continue continue
# Scroll bar flipping # Scroll bar flipping
@ -108,7 +90,7 @@ class ConsumableUsageUI(ItemUI):
if self.appear(SIMPLE_PROTECTIVE_GEAR_CHECK): if self.appear(SIMPLE_PROTECTIVE_GEAR_CHECK):
logger.info('The consumable to be used have been selected') logger.info('The consumable to be used have been selected')
return True return True
if self.appear_then_click(SIMPLE_PROTECTIVE_GEAR, similarity=0.7): if self.appear_then_click(SIMPLE_PROTECTIVE_GEAR, similarity=0.7, interval=2):
logger.info('Select the consumable which to be used') logger.info('Select the consumable which to be used')
continue continue
else: else:
@ -131,7 +113,7 @@ class ConsumableUsageUI(ItemUI):
if self.appear(CONFIRM_POPUP): if self.appear(CONFIRM_POPUP):
logger.info('Item consumable usage popup appear') logger.info('Item consumable usage popup appear')
break break
if self.appear_then_click(USE_CONSUMABLE): if self.appear_then_click(USE_CONSUMABLE, interval=2):
logger.info('Click the "use" button') logger.info('Click the "use" button')
continue continue