Ejemplo n.º 1
0
def launch():
    if ui_util.get_new_capture() is not None:
        common_util.execute_shell("open /Applications/命运-冠位指定.app")
        print("game has launched")
        return
    count = 0
    while ui_util.get_new_capture() is None:
        print("try launch {}".format(count + 1))
        common_util.execute_shell("open /Applications/命运-冠位指定.app")
        count = count + 1
        if count > 5:
            print("error!!! cant launch game!!!")
            raise Exception()
        time.sleep(4)
    common_util.wait_for(resources.launch_first_step_click_screen, step=5, max_count=10)
    if not ui_util.match_and_click(resources.launch_first_step_click_screen):
        print("error!!! cant enter game")
        raise Exception()
    common_util.wait_for(resources.launch_second_step_game_slogen, step=5, max_count=10)
    count = 0
    while ui_util.match_and_click(resources.launch_second_step_game_slogen):
        count = count + 1
        if count > 10:
            print("error!!! login error")
            raise Exception()
        time.sleep(5)
    common_util.wait_for(resources.launch_game_post)
    ui_util.match_and_click(resources.launch_game_post_close_button)
    print("launch finish!!!")
Ejemplo n.º 2
0
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!!!")
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 def run(self, capture_path):
     common_util.write_log("select card")
     _wait_for(resources.battle_attack_button)
     ui_util.match_and_click(resources.battle_attack_button,
                             delete_after_match=True)
     time.sleep(random.randrange(2, stop=4))
     selected_card_count = 0
     while selected_card_count < 3:
         for card in self.card_list:
             if ui_util.match_and_click(card, delete_after_match=True):
                 selected_card_count = selected_card_count + 1
                 common_util.write_log(
                     "select card {}".format(selected_card_count))
                 time.sleep(random.randrange(2, stop=3))
                 break
Ejemplo n.º 5
0
 def execute(self):
     for card in [
             resources.action_buster, resources.action_arts,
             resources.action_quick
     ]:
         if ui_util.match_and_click(card):
             break
Ejemplo n.º 6
0
 def execute(self):
     ui_util.match_and_click(resources.battle_friend_select_normal_item)
Ejemplo n.º 7
0
 def execute(self):
     common_util.write_log("SimpleMatchAndClick execute on {} , {}".format(
         self.template, type(self)))
     ui_util.match_and_click(self.template, delete_after_match=True)
Ejemplo n.º 8
0
 def execute(self):
     ui_util.match_and_click(resources.close_button)
     _wait_for(resources.battle_attack_button, step=1)
Ejemplo n.º 9
0
 def execute(self):
     ui_util.match_and_click(resources.item_sliver_apple)
     _wait_for(resources.apple_eat_dialog_confirm_button, step=1)
     ui_util.match_and_click(resources.apple_eat_dialog_confirm_button)
     time.sleep(2)