def match(self, capture_path): if not cv_util.has_match(resources.battle_attack_button, capture_path): return False for t in self.match_templates: if cv_util.has_match(t, capture_path, match_threshold=0.94): common_util.write_log("battle {} match {}".format( self.name, capture_path)) return True return False
def get_new_capture_and_match(template, threshold=0.9, remove_after_match=False): global impl capture = get_new_capture() result = cv_util.has_match(template, capture, match_threshold=threshold) if remove_after_match: common_util.delete_file(capture) return result
def go_to_exp(): if cv_util.has_match(resources.daily_task_title, ui_util.get_new_capture()): return common_util.wait_for(resources.launch_chaldea_gate) ui_util.match_and_click(resources.launch_chaldea_gate) common_util.wait_for(resources.launch_daily_task) ui_util.match_and_click(resources.launch_daily_task) common_util.wait_for(resources.launch_exp_ap_40_unpass, extra_resources=[resources.launch_exp_ap_40_passed]) for t in [resources.launch_exp_ap_40_passed, resources.launch_exp_ap_40_unpass]: if ui_util.match_and_click(t): break print("go to exp finished!!!")
def execute(self): _wait_for(resources.battle_attack_button) # if self.use_skill: # skill_list = [resources.skill_single_np_up, resources.skill_single_defense_up, # resources.skill_single_attack_up] # skill_used_state = ServantClickedStatusDialogState() # for skill in skill_list: # if skill_used_state.match(ui_util.get_new_capture()): # skill_used_state.execute() # _wait_for(resources.battle_attack_button) # ui_util.match_and_click(skill, match_threshold=0.9) # if skill_used_state.match(ui_util.get_new_capture()): # skill_used_state.execute() # _wait_for(resources.battle_attack_button) max_val, tl_loc, br_loc = cv_util.match_template( resources.np_progress_full, ui_util.get_new_capture()) print("match baoju", max_val, tl_loc, br_loc, config.window_size) baoju_position = -1 if max_val > 0.9: center_x = (br_loc[0] + tl_loc[0]) / 2 window_w = config.window_size[0] if window_w is not None and window_w > 0: p = center_x / window_w print(property) if p < 1 / 4: baoju_position = 0 elif p < 2 / 4: baoju_position = 1 elif p < 3 / 4: baoju_position = 2 print("baoju rsult ", baoju_position) ui_util.match_and_click(resources.battle_attack_button) time.sleep(3) _wait_for(resources.battle_speed_set_button) while cv_util.has_match(resources.battle_speed_set_button, ui_util.get_new_capture()): if baoju_position != -1: position_set = [(250, 250), (400, 250), (550, 250)] ui_util.click( position_set[baoju_position][0] + random.randrange(-10, 10), position_set[baoju_position][1] + random.randrange(-10, 10)) baoju_position = -1 time.sleep(3) for card in [ resources.action_buster, resources.action_arts, resources.action_quick ]: if ui_util.match_and_click(card): time.sleep(3) break
def match(self, capture_path): return cv_util.has_match(resources.battle_friend_select_title, capture_path)
def match(self, capture_path): return cv_util.has_match(self.template, capture_path)
def match(self, capture_path): return cv_util.has_match(resources.need_release_space_buttons, capture_path)
def match(self, capture_path): return cv_util.has_match(resources.servant_selected_ststus_title, capture_path)
def match(self, capture_path): return cv_util.has_match(resources.skill_used_click_dialog_title, capture_path)
def match(self, capture_path): return cv_util.has_match(resources.battle_speed_set_button, capture_path)
def match(self, capture_path): return cv_util.has_match(resources.item_sliver_apple, capture_path)