Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

fixed boss missclasification #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions modules/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def combat_logic_wrapper(self):
self.exit = 0
Logger.log_msg("Repeating map {}.".format(self.chapter_map))
Utils.touch_randomly(map_region)
continue
continue
if self.exit > 2:
self.stats.increment_combat_attempted()
break
Expand Down Expand Up @@ -181,7 +181,7 @@ def combat_logic_wrapper(self):
if Utils.find("menu/button_confirm"):
Logger.log_msg("Found commission info message.")
Utils.touch_randomly(self.region["combat_com_confirm"])

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

Expand All @@ -193,7 +193,7 @@ def reach_map(self):
If the map isn't found, it navigates the map selection menu to get to the world where the specified map is located.
Only works with standard maps up to worlds 13 and some event maps.
Also checks if hard mode is enabled, and if it's legit to keep it so (event maps C and D).
If nothing is found even after menu navigation, it stops the bot workflow until the user moves to the right
If nothing is found even after menu navigation, it stops the bot workflow until the user moves to the right
screen or the map asset is substituted with the right one.

Returns:
Expand All @@ -206,7 +206,7 @@ def reach_map(self):
Utils.touch_randomly(self.region["menu_button_battle"])
Utils.wait_update_screen(2)

# correct map mode
# correct map mode
if not self.chapter_map[0].isdigit():
letter = self.chapter_map[2]
event_maps = ['A', 'B', 'S', 'C', 'D']
Expand All @@ -223,7 +223,7 @@ def reach_map(self):
Logger.log_debug("Disabling hard mode.")
Utils.touch_randomly(self.region['normal_mode_button'])
Utils.wait_update_screen(1)

map_region = Utils.find('maps/map_{}'.format(self.chapter_map), 0.99)
if map_region != None:
Logger.log_msg("Found specified map.")
Expand Down Expand Up @@ -256,7 +256,7 @@ def reach_map(self):
Utils.touch_randomly(self.region['map_nav_left'])
Logger.log_debug("Swiping to the left")
Utils.script_sleep()

Utils.wait_update_screen()
map_region = Utils.find('maps/map_{}'.format(self.chapter_map), 0.99)
if map_region == None:
Expand Down Expand Up @@ -342,7 +342,7 @@ def battle_handler(self, boss=False):
Logger.log_msg("Received new RARE ship as drop.")
Utils.touch_randomly(self.region['dismiss_ship_drop'])
Utils.script_sleep(2)
continue
continue
elif Utils.find("menu/drop_ssr"):
Logger.log_msg("Received SSR ship as drop.")
Utils.touch_randomly(self.region['dismiss_ship_drop'])
Expand Down Expand Up @@ -488,7 +488,7 @@ def movement_handler(self, target_info):

def unable_handler(self, coords, boss=False):
"""
Method called when the path to the target (boss fleet or mystery node) is obstructed by mobs:
Method called when the path to the target (boss fleet or mystery node) is obstructed by mobs:
it procedes to switch targets to the mobs which are blocking the path.

Args:
Expand Down Expand Up @@ -643,7 +643,7 @@ def clear_map(self):
translation_module = 175 if boss_region.y > 300 else 75
horizontal_translation = translation_sign * translation_module
angular_coefficient = -1 * ((540 - boss_region.y)/(960 - boss_region.x))
Utils.swipe(boss_region.x + horizontal_translation, boss_region.y + int(horizontal_translation * angular_coefficient),
Utils.swipe(boss_region.x + horizontal_translation, boss_region.y + int(horizontal_translation * angular_coefficient),
960 + horizontal_translation, 540 + int(horizontal_translation * angular_coefficient), 300)
Utils.wait_update_screen()

Expand Down Expand Up @@ -701,6 +701,24 @@ def clear_boss(self, boss_info):
#handle boss' coordinates
if not self.unable_handler(boss_info[0:2], boss=True):
return
swipes = {
0: lambda: Utils.swipe(960, 240, 960, 940, 300),
1: lambda: Utils.swipe(1560, 540, 260, 540, 300),
2: lambda: Utils.swipe(960, 940, 960, 240, 300),
3: lambda: Utils.swipe(260, 540, 1560, 540, 300)
}

Utils.touch_randomly(self.region['button_switch_fleet'])
Utils.wait_update_screen(2)
boss_region = Utils.find_in_scaling_range("enemy/fleet_boss", similarity=0.9)
s = 0
while not boss_region:
if s > 3: s = 0
swipes.get(s)()
Utils.wait_update_screen(0.5)
boss_region = Utils.find_in_scaling_range("enemy/fleet_boss", similarity=0.9)
s += 1
boss_info = [boss_region.x + 50, boss_region.y + 25, "boss"]
continue
else:
self.movement_handler(boss_info)
Expand Down Expand Up @@ -810,7 +828,7 @@ def get_enemies(self, blacklist=[], boss=False):
l7 = [x for x in l7 if (not self.filter_blacklist(x, blacklist))]
Logger.log_debug("L7 " +str(l7))
self.enemies_list.extend(l7)

sim -= 0.005

if filter_coordinates:
Expand All @@ -822,7 +840,7 @@ def get_mystery_nodes(self, blacklist=[], boss=False):
"""
if len(blacklist) > 2:
self.mystery_nodes_list.clear()

if len(self.mystery_nodes_list) == 0 and not Utils.find('combat/question_mark', 0.9):
# if list is empty and a question mark is NOT found
return self.mystery_nodes_list
Expand All @@ -842,10 +860,10 @@ def get_mystery_nodes(self, blacklist=[], boss=False):

self.mystery_nodes_list = l1
sim -= 0.005

if filter_coordinates:
self.mystery_nodes_list = Utils.filter_similar_coords(self.mystery_nodes_list)

return self.mystery_nodes_list

def filter_blacklist(self, coord, blacklist):
Expand Down Expand Up @@ -888,7 +906,7 @@ def get_fleet_location(self):
coords = [0, 0]

self.fleet_location = coords

return self.fleet_location

def get_closest_target(self, blacklist=[], location=[], mystery_node=False, boss=False):
Expand All @@ -907,7 +925,7 @@ def get_closest_target(self, blacklist=[], location=[], mystery_node=False, boss
Returns:
array: An array containing the x and y coordinates of the closest
enemy to the specified location
"""
"""
fleet_location = self.get_fleet_location()

if location == []:
Expand All @@ -926,7 +944,7 @@ def get_closest_target(self, blacklist=[], location=[], mystery_node=False, boss
else:
# target only enemy mobs
targets = self.get_enemies(blacklist, boss)

closest = targets[Utils.find_closest(targets, location)[1]]

Logger.log_info('Current location is: {}'.format(fleet_location))
Expand Down