def should_sortie(self): """Method to check wether bot should combat or not. """ return (self.modules['combat'] or self.modules['event']) \ and script.next_combat != 0 \ and script.next_combat < datetime.now() \ and Utils.check_oil(self.oil_limit)
def print_cycle_stats(self): """Method to print the cycle stats" """ if self.print_stats_check: self.stats.print_stats( Utils.check_oil(self.config.combat['oil_limit'])) self.print_stats_check = False
def print_cycle_stats(self): """Method to print the cycle stats" """ if self.print_stats_check: self.stats.print_stats(Utils.check_oil(self.oil_limit)) self.print_stats_check = False
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
def should_sortie(self): """Method to check wether bot should combat or not. """ return script.next_combat != 0 and script.next_combat < datetime.now() and \ Utils.check_oil(self.config.combat['oil_limit'])