diff --git a/assets/cn/combat/obtain/MAY_OBTAIN.SEARCH.png b/assets/cn/combat/obtain/MAY_OBTAIN.SEARCH.png new file mode 100644 index 000000000..dee97cbe3 Binary files /dev/null and b/assets/cn/combat/obtain/MAY_OBTAIN.SEARCH.png differ diff --git a/assets/cn/combat/obtain/MAY_OBTAIN.png b/assets/cn/combat/obtain/MAY_OBTAIN.png new file mode 100644 index 000000000..92e9953ea Binary files /dev/null and b/assets/cn/combat/obtain/MAY_OBTAIN.png differ diff --git a/assets/en/combat/obtain/MAY_OBTAIN.SEARCH.png b/assets/en/combat/obtain/MAY_OBTAIN.SEARCH.png new file mode 100644 index 000000000..d06b424e6 Binary files /dev/null and b/assets/en/combat/obtain/MAY_OBTAIN.SEARCH.png differ diff --git a/assets/en/combat/obtain/MAY_OBTAIN.png b/assets/en/combat/obtain/MAY_OBTAIN.png new file mode 100644 index 000000000..4e366be79 Binary files /dev/null and b/assets/en/combat/obtain/MAY_OBTAIN.png differ diff --git a/tasks/combat/assets/assets_combat_obtain.py b/tasks/combat/assets/assets_combat_obtain.py index 98ff57429..3f0a01df7 100644 --- a/tasks/combat/assets/assets_combat_obtain.py +++ b/tasks/combat/assets/assets_combat_obtain.py @@ -33,6 +33,23 @@ ITEM_NAME = ButtonWrapper( button=(495, 187, 855, 211), ), ) +MAY_OBTAIN = ButtonWrapper( + name='MAY_OBTAIN', + cn=Button( + file='./assets/cn/combat/obtain/MAY_OBTAIN.png', + area=(813, 379, 893, 397), + search=(812, 373, 895, 468), + color=(63, 71, 87), + button=(813, 379, 893, 397), + ), + en=Button( + file='./assets/en/combat/obtain/MAY_OBTAIN.png', + area=(813, 379, 922, 397), + search=(813, 373, 923, 468), + color=(53, 61, 78), + button=(813, 379, 922, 397), + ), +) OBTAIN_1 = ButtonWrapper( name='OBTAIN_1', share=Button( diff --git a/tasks/combat/obtain.py b/tasks/combat/obtain.py index f7ca5eaa7..3ee5d5505 100644 --- a/tasks/combat/obtain.py +++ b/tasks/combat/obtain.py @@ -5,7 +5,7 @@ from module.exception import ScriptError from module.logger import logger from module.ocr.ocr import Digit from tasks.combat.assets.assets_combat_obtain import * -from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE, WAVE_MINUS, WAVE_PLUS +from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE from tasks.dungeon.keywords import DungeonList from tasks.planner.keywords import ITEM_CLASSES from tasks.planner.model import ObtainedAmmount, PlannerMixin @@ -87,10 +87,8 @@ class CombatObtain(PlannerMixin): else: self.device.screenshot() - if not self.appear(ITEM_CLOSE) and self.appear(COMBAT_PREPARE): - if self.image_color_count(WAVE_MINUS, color=(246, 246, 246), threshold=221, count=100) \ - or self.image_color_count(WAVE_PLUS, color=(246, 246, 246), threshold=221, count=100): - break + if not self.appear(ITEM_CLOSE) and self.appear(COMBAT_PREPARE) and self.appear(MAY_OBTAIN): + break if self.appear_then_click(ITEM_CLOSE, interval=2): continue @@ -187,6 +185,9 @@ class CombatObtain(PlannerMixin): index = 1 prev = None items = [] + + self._find_may_obtain() + for _ in range(5): entry = self._obtain_get_entry(dungeon, index=index, prev=prev) if entry is None: @@ -243,6 +244,17 @@ class CombatObtain(PlannerMixin): self.obtain_frequent_check = True return False + def _find_may_obtain(self, skip_first_screenshot=True): + logger.info('Find may obtain') + while 1: + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() + if MAY_OBTAIN.match_template(self.device.image): + OBTAIN_1.load_offset(MAY_OBTAIN) + return True + if __name__ == '__main__': self = CombatObtain('src')