Пример #1
0
 def check_status(self, device):
     warning = Image(os.path.join(constant.INVENTORY_IMAGE_DIR, 'retire_warning'))
     cancel_button = Image(os.path.join(constant.INVENTORY_IMAGE_DIR, 'cancel_button'))
     if warning.exists(device):
         cancel_button.click(device)
         return False
     return True
Пример #2
0
 def run(self, device):
     cancel_button = Image(
         os.path.join(constant.BATTLE_COMMON_IMAGE_DIR, 'cancel_button'))
     for step in self.steps:
         if isinstance(step, Image):
             if step.option_action == constant.CLICK_SOMEWHERE_TO_WAIT:
                 step.click_somewhere_to_wait(device)
             elif step.option_action == constant.CLICK_OPTION_FIRST:
                 step.click_option_image_first(device)
             elif step.option_action == constant.WAIT_SECONDS:
                 step.click(device)
                 step.wait(step.option)
             elif step.option_action == constant.WAIT_IMAGE_GONE:
                 step.wait_image_gone(device)
             elif step.option_action == constant.WAIT_IMAGE:
                 step.wait_image(device)
             else:
                 step.click(device)
         else:
             if step.note == constant.SWIPE:
                 step.swipe(device)
             else:
                 step.click(device)
                 if 'location' in step.note and cancel_button.exists(
                         device):
                     cancel_button.click(device)
         time.sleep(1)
Пример #3
0
 def check_status(self, device):
     close_button = Image(
         os.path.join(constant.INVENTORY_IMAGE_DIR, 'close_button'))
     cancel_button = Image(
         os.path.join(constant.INVENTORY_IMAGE_DIR, 'cancel_button'))
     if close_button.exists(device):
         close_button.click(device)
         time.sleep(3)
         return True
     else:
         cancel_button.click(device)
         return False
Пример #4
0
 def power_up(self, device):
     girls_be_powered_up = filter(lambda x: x.endswith('.png'), os.listdir(self.girls_dir))
     girls_num = len(girls_be_powered_up)
     cancel_button = Image(image_path('cancel_button2'))
     for index, girl in enumerate(girls_be_powered_up):
         girl = girl.split('.')[0]
         girl_image = Image(os.path.join(self.girls_dir, girl))
         if girl_image.exists(device):
             girl_image.click(device)
             self.pick_up_and_power(device)
             if not self.check_status(device):
                 break
             if index < girls_num:
                 Point('select_girl_be_powered_up', 238, 226).click(device)
     self.already_power_up = True
     if cancel_button.exists(device):
         cancel_button.click(device)
     Image(image_path('return_to_base')).click(device)
Пример #5
0
                    step.swipe(device)
                else:
                    step.click(device)
                    if 'location' in step.note and cancel_button.exists(
                            device):
                        cancel_button.click(device)
            time.sleep(1)

    def show_steps(self):
        self.steps.show_steps()


class StepList(list):
    def show_steps(self):
        start_war_flag = 'start_war'
        for step in self:
            print(step)
            if start_war_flag in step.note:
                print("\nBattle")


if __name__ == '__main__':
    import atx
    device = atx.connect('4200c49cf2faa381')
    point = Point('location4', 534, 122)
    cancel_button = Image(
        os.path.join(constant.BATTLE_COMMON_IMAGE_DIR, 'cancel_button'))
    point.click(device)
    if 'location' in point.note and cancel_button.exists(device):
        cancel_button.click(device)