예제 #1
0
    def mission_logic_wrapper(self):
        while True:
            Utils.update_screen()

            if Utils.find("mission/alert_completed"):
                Logger.log_msg("Found mission completed alert.")
                Utils.touch_randomly(self.region["mission_menu"])
                continue
            if Utils.find("menu/drop_ssr"):
                Logger.log_msg("Received SSR ship as reward.")
                Utils.touch_randomly(self.region['dismiss_ship_drop'])
                continue
            if Utils.find("menu/drop_elite"):
                Logger.log_msg("Received ELITE ship as reward.")
                Utils.touch_randomly(self.region['dismiss_ship_drop'])
                continue
            while Utils.find("menu/missions"):
                Utils.update_screen()

                if Utils.find("mission/button_collect"):
                    Logger.log_msg("Collected all missions.")
                    Utils.touch_randomly(self.region["collect"])
                    Utils.script_sleep(3)
                    continue
                if Utils.find("mission/button_claim"):
                    Logger.log_msg("Claimed mission.")
                    Utils.touch_randomly(self.region["first_claim"])
                    continue
                if Utils.find("menu/item_found"):
                    Utils.touch_randomly(self.region["tap_to_continue"])
                    continue
                else:
                    Logger.log_msg("No more missions to claim/collect.")
                    Utils.menu_navigate("menu/button_battle")
                    return True
예제 #2
0
    def enhancement_logic_wrapper(self, forced=False):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of enhancing a ship.

        Args:
            forced (bool): Forces enhancement to start even if need_to_enhance returns False.
        
        Returns:
            enhancement_done (bool): whether at least one enhancement was completed.
        """
        if self.need_to_enhance or forced:
            self.last_enhance = self.stats.combat_done
            self.fill_count = 0
            self.called_from_menu = False
            self.enhancement_done = False
            Logger.log_msg("Opening dock to enhance ship.")

            while True:
                Utils.update_screen()
                if Utils.find("menu/button_sort"):
                    # Tap enhace button from dock is full alert
                    Utils.touch_randomly(self.region['combat_enhance_button'])
                    Utils.script_sleep(3)
                    continue
                if Utils.find("menu/button_battle"):
                    Utils.touch_randomly(self.region['dock_tab'])
                    self.called_from_menu = True
                    Utils.script_sleep(2)
                    continue
                if Utils.find("retirement/empty"):
                    Logger.log_msg("No ships left to enhance.")
                    Utils.touch_randomly(self.region['button_favorite'])
                    Utils.script_sleep(0.5)
                    if self.called_from_menu:
                        Utils.menu_navigate("menu/button_battle")
                    else:
                        Utils.touch_randomly(self.region['button_go_back'])
                    return self.enhancement_done
                if Utils.find("enhancement/button_favorite", 0.99):
                    Utils.script_sleep(1.0)
                    Utils.touch_randomly(self.region['button_favorite'])
                    Utils.script_sleep(0.5)
                    self.enhance_ship()
                    Utils.script_sleep(1)
                    if self.called_from_menu:
                        self.previous_call_place = "menu"
                        Utils.menu_navigate("menu/button_battle")
                    else:
                        self.previous_call_place = "combat"
                        Utils.touch_randomly(self.region['button_go_back'])
                    return self.enhancement_done
                if Utils.find("menu/dock"):
                    Utils.touch_randomly(self.region['button_favorite'])
                    Utils.script_sleep(1)
                    self.set_sort()
                    continue
                else:
                    Utils.touch_randomly(self.region['button_go_back'])
                    Utils.script_sleep(2)
예제 #3
0
파일: event.py 프로젝트: sandbagimon/ALAuto
    def event_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of completing an event
        """
        if self.config.events['name'] == 'Crosswave' and not self.finished:
            Logger.log_msg("Opening event menu.")

            while not Utils.find("menu/operation"):
                Utils.find_and_touch("event/crosswave/menu_button")
                Utils.wait_update_screen(1)

            Logger.log_msg("Event levels: " + str(self.levels))

            while ('EX' in self.levels):
                Utils.update_screen()
                if Utils.find("event/crosswave/ex_completed", 0.98):
                    Logger.log_info("No more EX combats to do.")
                    break

                Utils.touch_randomly(self.region['crosswave_ex'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg("Finished EX crosswave combat.")
            while ('H' in self.levels):
                Utils.update_screen()
                if Utils.find("event/crosswave/hard_completed"):
                    Logger.log_info("No more hard combats to do.")
                    break

                Utils.touch_randomly(self.region['crosswave_hard'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg("Finished hard crosswave combat.")
            while ('N' in self.levels):
                Utils.update_screen()
                if Utils.find("event/crosswave/normal_completed"):
                    Logger.log_info("No more normal combats to do.")
                    break

                Utils.touch_randomly(self.region['crosswave_normal'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg("Finished normal crosswave combat.")
            while ('E' in self.levels):
                Utils.update_screen()
                if Utils.find("event/crosswave/easy_completed"):
                    Logger.log_info("No more easy combats to do.")
                    break

                Utils.touch_randomly(self.region['crosswave_easy'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg("Finished easy crosswave combat.")

            Logger.log_msg("Finished all event combats, going back to menu.")

            Utils.menu_navigate("menu/button_battle")
            self.finished = True
            return
예제 #4
0
    def retirement_logic_wrapper(self, forced=False):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of filtering and retiring ships

        Args:
            forced (bool): Forces retirement to start even if need_to_retire returns False.

        Returns:
            retirement_done (bool): whether at least one retirement was completed.
        """
        if self.need_to_retire or forced:
            self.last_retire = self.stats.combat_done
            self.called_from_menu = False
            self.retirement_done = False
            Logger.log_msg("Opening build menu to retire ships.")

            while True:
                Utils.update_screen()

                if Utils.find("menu/button_sort"):
                    # Tap menu retire button
                    Utils.touch_randomly(self.region['combat_sort_button'])
                    Utils.script_sleep(1)
                    continue
                # In case function is called from menu
                if Utils.find("menu/button_battle"):
                    self.called_from_menu = True
                    Utils.touch_randomly(self.region['build_menu'])
                    Utils.script_sleep(1)
                    continue
                if Utils.find("menu/build"):
                    if Utils.find("event/build_limited"):
                        Utils.touch_randomly(self.region['retire_tab_2'])
                    else:
                        Utils.touch_randomly(self.region['retire_tab_1'])
                    Utils.script_sleep(1)
                    continue
                if Utils.find("retirement/selected_none"):
                    self.set_sort()
                    self.retire_ships()
                    if self.called_from_menu:
                        self.previous_call_place = "menu"
                        Utils.menu_navigate("menu/button_battle")
                    else:
                        self.previous_call_place = "combat"
                        Utils.touch_randomly(self.region['menu_nav_back'])
                    return self.retirement_done

            Utils.update_screen()
예제 #5
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.l.clear()
        self.blacklist.clear()

        while True:
            Utils.wait_update_screen()

            if Utils.find("menu/button_sort"):
                Utils.touch_randomly(Region(1326, 274, 35, 35))
                self.exit = 3
            if Utils.find("combat/alert_morale_low"):
                Utils.touch_randomly(Region(1326, 274, 35, 35))
                self.exit = 2
                break
            if Utils.find("commission/button_confirm"):
                Logger.log_msg("Found commission info message.")
                Utils.touch_randomly(self.region["combat_com_confirm"])
                continue
            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_select_fleet"):
                Logger.log_debug("Found fleet select go button.")
                Utils.touch_randomly(self.region["fleet_menu_go"])
                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:
                self.stats.increment_combat_done()
                break
            if self.exit > 1:
                self.stats.increment_combat_attempted()
                break
            if Utils.find("menu/button_normal_mode"):
                Logger.log_debug("Disabling hard mode.")
                Utils.touch_randomly(Region(88, 990, 80, 40))
                Utils.wait_update_screen(1)
            if Utils.find_and_touch('maps/map_{}'.format(self.chapter_map),
                                    0.8):
                Logger.log_msg("Found specified map.")
                continue
            else:
                self.reach_map()
                continue

        Utils.script_sleep(1)
        Utils.menu_navigate("menu/button_battle")

        return self.exit
예제 #6
0
파일: combat.py 프로젝트: Logi-Ca1/ALAuto
    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("menu/button_confirm"):
                Logger.log_msg("Found commission info message.")
                Utils.touch_randomly(self.region["combat_com_confirm"])
                continue
            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
                    ) 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("menu/button_normal_mode"
                          ) and self.chapter_map[0].isdigit():
                Logger.log_debug("Disabling hard mode.")
                Utils.touch_randomly(self.region['normal_mode_button'])
                Utils.wait_update_screen(1)
            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")

        return self.exit
예제 #7
0
    def event_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of completing an event
        """
        event = self.config.events['name']
        events = ['Crosswave', 'Royal_Maids']

        if event in events and not self.finished:
            Logger.log_msg("Opening event menu.")

            while not Utils.find("menu/operation"):
                Utils.find_and_touch(f"event/{event}/menu_button")
                Utils.wait_update_screen(1)

            Logger.log_msg("Event levels: " + str(self.levels))

            while ('EX' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/ex_completed", 0.98):
                    Logger.log_info("No more EX combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_ex'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished EX {event.replace('_', ' ')} combat.")
            while ('H' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/hard_completed"):
                    Logger.log_info("No more Hard combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_hard'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished Hard {event.replace('_', ' ')} combat.")
            while ('N' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/normal_completed"):
                    Logger.log_info("No more Normal combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_normal'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished Normal {event.replace('_', ' ')} combat.")
            while ('E' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/easy_completed"):
                    Logger.log_info("No more Easy combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_easy'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished Easy {event.replace('_', ' ')} combat.")

            Logger.log_msg("Finished all event combats, going back to menu.")

            Utils.menu_navigate("menu/button_battle")
            self.finished = True
            return
예제 #8
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 successfully retreated after the specified
                number of fights, 3 if morale is too low, 4 if dock is full and unable to
                free it and 5 if fleet was defeated.
        """
        self.exit = 0
        self.start_time = datetime.now()
        # enhancecement and retirement flags
        enhancement_failed = False
        retirement_failed = False

        # get to map
        map_region = self.reach_map()
        Utils.touch_randomly(map_region)

        while True:
            Utils.wait_update_screen()

            if self.exit == 1 or self.exit == 2:
                self.stats.increment_combat_done()
                time_passed = datetime.now() - self.start_time
                if self.stats.combat_done % self.config.combat['retire_cycle'] == 0 or ((self.config.commissions['enabled'] or \
                    self.config.dorm['enabled'] or self.config.academy['enabled']) and time_passed.total_seconds() > 3600) or \
                        not Utils.check_oil(self.config.combat['oil_limit']):
                    break
                else:
                    self.exit = 0
                    Logger.log_msg("Repeating map {}.".format(
                        self.chapter_map))
                    Utils.touch_randomly(map_region)
                    continue
            if self.exit > 2:
                self.stats.increment_combat_attempted()
                break
            if Utils.find("combat/button_go"):
                Logger.log_debug("Found map summary go button.")
                Utils.touch_randomly(self.region["map_summary_go"])
                Utils.wait_update_screen()
            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.wait_update_screen(2)
            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
                Utils.wait_update_screen()
            if Utils.find("menu/button_confirm"):
                Logger.log_msg("Found commission info message.")
                Utils.touch_randomly(self.region["combat_com_confirm"])
                continue
            if Utils.find("menu/button_sort"):
                if self.config.enhancement[
                        'enabled'] and not enhancement_failed:
                    if not self.enhancement_module.enhancement_logic_wrapper(
                            forced=True):
                        enhancement_failed = True
                    Utils.script_sleep(1)
                    Utils.touch_randomly(map_region)
                    continue
                elif self.config.retirement[
                        'enabled'] and not retirement_failed:
                    if not self.retirement_module.retirement_logic_wrapper(
                            forced=True):
                        retirement_failed = True
                    else:
                        # reset enhancement flag
                        enhancement_failed = False
                    Utils.script_sleep(1)
                    Utils.touch_randomly(map_region)
                    continue
                else:
                    Utils.touch_randomly(self.region['close_info_dialog'])
                    self.exit = 4
                    break
            if Utils.find("combat/alert_morale_low"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                self.exit = 3
                break

        Utils.script_sleep(1)
        Utils.menu_navigate("menu/button_battle")

        return self.exit