Exemple #1
0
    def commission_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of starting and completing commissions.
        """
        Logger.log_msg("Found commission completed alert.")
        Utils.touch_randomly(self.region["left_menu"])

        Utils.script_sleep(1)
        Utils.touch_randomly(self.region["collect_oil"])
        Utils.touch_randomly(self.region["collect_gold"])

        while True:
            Utils.wait_update_screen(1)
            Utils.avoid_stuck_routine()

            if Utils.find("commission/button_completed") and (
                    lambda x: x > 332 and x < 511)(
                        Utils.find("commission/button_completed").y):
                Logger.log_debug("Found commission complete button.")
                self.completed_handler()
            if Utils.find("commission/alert_available",
                          0.9) and (lambda x: x > 332 and x < 511)(Utils.find(
                              "commission/alert_available", 0.9).y):
                Logger.log_debug("Found commission available indicator.")
                Utils.touch_randomly(self.region["button_go"])
                Utils.wait_update_screen(1)

                while not Utils.find("menu/commission"):
                    Utils.touch_randomly(self.region["button_go"])
                    Utils.wait_update_screen(1)

                if self.urgent_handler():
                    self.daily_handler()
                Utils.touch_randomly(self.region["button_back"])
                continue
            if Utils.find("commission/button_go") and (
                    lambda x: x > 332 and x < 511)(
                        Utils.find("commission/button_go").y):
                Logger.log_msg("All commissions are running.")
                Utils.touch_randomly(self.region["dismiss_side_tab"])
                break

        Utils.wait_update_screen()
        return True
Exemple #2
0
    Logger.log_msg('Successfully connected to the service.')
    output = Adb.exec_out('wm size').decode('utf-8').strip()

    if not re.search('1920x1080|1080x1920', output):
        Logger.log_error("Resolution is not 1920x1080, please change it.")
        sys.exit()

    Utils.assets = config.assets['server']
else:
    Logger.log_error('Unable to connect to the service.')
    sys.exit()

try:
    while True:
        Utils.update_screen()
        Utils.avoid_stuck_routine()
        # temporal solution to event alerts
        # if not Utils.find("menu/button_battle"):
        #     Utils.touch_randomly(Region(54, 57, 67, 67))
        #     Utils.script_sleep(1)
        #     continue
        if Utils.find("menu/button_battle"):
            script.run_daily_cycle()
        if Utils.find("commission/alert_completed"):
            script.run_commission_cycle()
            script.print_cycle_stats()
        if Utils.find("mission/alert_completed"):
            script.run_mission_cycle()
        if Utils.find("headquarters/hq_alert"):
            script.run_hq_cycle()
        if script.should_sortie():
Exemple #3
0
    def combat_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of sortieing combat fleets and resolving combat.

        Returns:
            int: 1 if boss was defeated, 2 if morale is too low and 3 if dock is full.
        """
        self.exit = 0
        self.combats_done = 0
        self.l.clear()
        self.blacklist.clear()

        while True:
            Utils.wait_update_screen()

            if Utils.find("menu/button_sort"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                self.exit = 3
            if Utils.find("combat/alert_morale_low"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                self.exit = 2
                break

            # if Utils.find("commission/button_confirm"):
            #     Logger.log_msg("Found commission info message.")
            #     Utils.find_and_touch("commission/button_confirm")
            #     continue
            Utils.avoid_stuck_routine()


            if Utils.find("menu/button_battle"):
                Logger.log_debug("Found menu battle button.")
                Utils.touch_randomly(self.region["menu_button_battle"])
                Utils.wait_update_screen(1)
                continue
            # if Utils.find("combat/menu_fleet") and (lambda x:x > 414 and x < 584)(Utils.find("combat/menu_fleet").y):
            #     if not self.chapter_map[0].isdigit() and string.ascii_uppercase.index(self.chapter_map[2:3]) < 1 or \
            #         self.chapter_map[0].isdigit():
            if Utils.find("combat/menu_fleet") and (lambda x: x > 414 and x < 584)(Utils.find("combat/menu_fleet").y) and not self.config.combat['boss_fleet']:
                if not self.chapter_map[0].isdigit() and string.ascii_uppercase.index(self.chapter_map[2:3]) < 1 or self.chapter_map[0].isdigit():
                    Logger.log_msg("Removing second fleet from fleet selection.")
                    Utils.touch_randomly(self.region["clear_second_fleet"])
            if Utils.find("combat/menu_select_fleet"):
                Logger.log_debug("Found fleet select go button.")
                Utils.touch_randomly(self.region["fleet_menu_go"])
                Utils.script_sleep(1)
                continue
            if Utils.find("combat/button_go"):
                Logger.log_debug("Found map summary go button.")
                Utils.touch_randomly(self.region["map_summary_go"])
                continue
            if Utils.find("combat/button_retreat"):
                Logger.log_debug("Found retreat button, starting clear function.")
                if not self.clear_map():
                    self.stats.increment_combat_attempted()
                    break
            if self.exit == 1 or self.exit == 5:
                self.stats.increment_combat_done()
                break
            if self.exit > 1:
                self.stats.increment_combat_attempted()
                break
            if Utils.find("combat/hard_map_cleared") and self.chapter_map[0].isdigit():
                Logger.log_debug("No more attacks available, Disabling hard mode.")
                Utils.touch_randomly(self.region['normal_mode_button'])
                Utils.wait_update_screen(1)
                self.exit = 3
                break
            if Utils.find_and_touch('maps/map_{}'.format(self.chapter_map), 0.99):
                Logger.log_msg("Found specified map.")
                continue
            else:
                self.reach_map()
                continue

        Utils.script_sleep(1)
        Utils.menu_navigate("menu/button_battle")
        # self.script_pause()

        return self.exit and self.script_pause()