Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from Walofz/original
Browse files Browse the repository at this point in the history
Original Merge
  • Loading branch information
Walofz authored Jan 22, 2020
2 parents e91c532 + a2a6406 commit 9e7c782
Show file tree
Hide file tree
Showing 23 changed files with 128 additions and 93 deletions.
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,4 @@ venv.bak/
start.bat
config-local.ini



.idea/ALAuto.iml
.idea/inspectionProfiles/profiles_settings.xml
.idea/misc.xml
.idea/modules.xml
.idea/rSettings.xml
.idea/vcs.xml
.idea/
7 changes: 4 additions & 3 deletions ALAuto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import re
import traceback
import argparse
from modules.combat import CombatModule
Expand Down Expand Up @@ -196,9 +197,9 @@ def print_cycle_stats(self):

if adb.init():
Logger.log_msg('Successfully connected to the service.')
res = ['1920x1080', '1080x1920']
output = Adb.exec_out('wm size').decode('utf-8').strip()

if Adb.exec_out('wm size').decode('utf-8').strip()[15:] not in res:
if not re.search('1920x1080|1080x1920', output):
Logger.log_error("Resolution is not 1920x1080, please change it.")
sys.exit()

Expand All @@ -219,7 +220,7 @@ def print_cycle_stats(self):
continue
if Utils.find("menu/announcement"):
Logger.log_msg("Found Announcement Window")
Utils.touch_randomly(Region(1790, 100, 60, 60))
Utils.touch_randomly(Region(1790, 100, 10, 10))
Utils.script_sleep(1)
continue
if Utils.find("menu/item_found"):
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Check the [Wiki](https://github.com/Egoistically/ALAuto/wiki/Config.ini-and-Modu
* If you'd like to help us during events to release an update faster you can check [this guide](https://github.com/Egoistically/ALAuto/wiki/Creating-new-assets-for-bot).

This was made for my own usage, it is far from good and I'm very aware of it. I am posting this because it might be useful to someone, that's all.
If you'd like to contribute in any way make sure to open a [pull request](https://github.com/Egoistically/ALAuto/pulls) or an [issue](https://github.com/Egoistically/ALAuto/issues). You can also contact me on Discord ego#9459.
If you'd like to contribute in any way make sure to open a [pull request](https://github.com/Egoistically/ALAuto/pulls) or an [issue](https://github.com/Egoistically/ALAuto/issues). If you'd like to contact us you can do so through our [Discord](https://discord.gg/vCFxDen).
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-hacker
Binary file added assets/EN/event/Royal_Maids/easy_completed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/event/Royal_Maids/ex_completed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/event/Royal_Maids/hard_completed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/event/Royal_Maids/menu_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/event/Royal_Maids/normal_completed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/maps/map_13-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/maps/map_13-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/EN/maps/map_13-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/EN/menu/button_sort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Server: EN
[Combat]
Enabled: False
Map: 3-4
BossFleet: False
OilLimit: 1000
RetireCycle: 2
RetreatAfter: 0
Expand All @@ -28,5 +29,5 @@ Retirement: False

[Events]
Enabled: False
Event: Crosswave
Event: Royal_Maids
Levels: EX,H,N,E
109 changes: 64 additions & 45 deletions modules/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, config, stats):
'event_button': Region(1770, 250, 75, 75),
'lock_ship_button': Region(1086, 739, 200, 55),
'clear_second_fleet': Region(1690, 473, 40, 40),
'button_switch_fleet': Region(1430, 985, 240, 60),
'menu_nav_back': Region(54, 57, 67, 67)
}

Expand Down Expand Up @@ -84,12 +85,11 @@ def combat_logic_wrapper(self):
Utils.touch_randomly(self.region["menu_button_battle"])
Utils.wait_update_screen(1)
continue
if Utils.find("combat/menu_fleet") and (lambda x: 414 < 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"])
continue
if Utils.find("combat/menu_select_fleet"):
Logger.log_debug("Found fleet select go button.")
Utils.touch_randomly(self.region["fleet_menu_go"])
Expand Down Expand Up @@ -390,20 +390,19 @@ def clear_map(self):
Logger.log_warning("Fleet lock is not supported, disabling it.")
Utils.wait_update_screen()

# swipe map to fit everything on screen
def swipe(cmap):
if cmap == 'E-C3' or cmap == 'E-A3':
Utils.swipe(960, 800, 960, 400, 100)
elif cmap == '12-2':
Utils.swipe(1000, 570, 1300, 540, 100)
elif cmap == '12-3':
Utils.swipe(1250, 530, 1300, 540, 100)
elif cmap == '11-3':
Utils.swipe(1020, 570, 1300, 540, 100)
else:
Utils.swipe(960, 540, 1300, 540, 100)

swipe(self.chapter_map)
#swipe map to fit everything on screen
swipes = {
'E-C3': lambda: Utils.swipe(960, 800, 960, 400, 100),
'E-A3': lambda: Utils.swipe(960, 800, 960, 400, 100),
'12-2': lambda: Utils.swipe(1000, 570, 1300, 540, 100),
'12-3': lambda: Utils.swipe(1250, 530, 1300, 540, 100),
'12-4': lambda: Utils.swipe(960, 300, 960, 540, 100),
'13-1': lambda: Utils.swipe(1020, 500, 1300, 540, 100),
'13-2': lambda: Utils.swipe(1125, 550, 1300, 540, 100),
'13-3': lambda: Utils.swipe(1150, 510, 1300, 540, 100),
'13-4': lambda: Utils.swipe(1200, 450, 1300, 540, 100)
}
swipes.get(self.chapter_map, lambda: Utils.swipe(960, 540, 1300, 540, 100))()

target_info = self.get_closest_target(self.blacklist)

Expand All @@ -421,6 +420,30 @@ def swipe(cmap):
return True
if Utils.find("enemy/fleet_boss", 0.9, self.chapter_map):
Logger.log_msg("Boss fleet was found.")

if self.config.combat['boss_fleet']:
s = 0
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("enemy/fleet_boss", 0.9, self.chapter_map)

while not boss_region:
if s > 3: s = 0
swipes.get(s)()

Utils.wait_update_screen(0.5)
boss_region = Utils.find("enemy/fleet_boss", 0.85, self.chapter_map)
s += 1
Utils.swipe(boss_region.x, boss_region.y, 960, 540, 300)
Utils.wait_update_screen()

boss_region = Utils.find("enemy/fleet_boss", 0.9, self.chapter_map)
# extrapolates boss_info(x,y,enemy_type) from the boss_region found
boss_info = [boss_region.x + 50, boss_region.y + 25, "boss"]
Expand Down Expand Up @@ -474,43 +497,38 @@ def clear_boss(self, boss_info):
Utils.script_sleep(3)
return

def get_enemies(self, blacklist=[]):
def get_enemies(self, blacklist=[], boss=False):
sim = 0.99
if blacklist != []:
i = 0
if blacklist:
Logger.log_info('Blacklist: ' + str(blacklist))
self.l = [x for x in self.l if (x not in blacklist)]

while self.l == []:
while not self.l:
if (boss and len(blacklist) > 4) or (not boss and len(blacklist) > 1) or sim < 0.95:
if i > 3: i = 0
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)
}
swipes.get(i)()
sim += 0.005
i += 1
Utils.update_screen()

l1 = filter(lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, map(lambda x: [x[0] - 3, x[1] - 45],
Utils.find_all('enemy/fleet_level',
sim - 0.15,
self.chapter_map)))
l1 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] - 3, x[1] - 45], Utils.find_all('enemy/fleet_level', sim - 0.15, self.chapter_map)))
l1 = [x for x in l1 if (not self.filter_blacklist(x, blacklist))]
l2 = filter(lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, map(lambda x: [x[0] + 75, x[1] + 110],
Utils.find_all('enemy/fleet_1_down', sim,
self.chapter_map)))
l2 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_1_down', sim, self.chapter_map)))
l2 = [x for x in l2 if (not self.filter_blacklist(x, blacklist))]
l3 = filter(lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, map(lambda x: [x[0] + 75, x[1] + 110],
Utils.find_all('enemy/fleet_2_down',
sim - 0.02,
self.chapter_map)))
l3 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_2_down', sim - 0.02, self.chapter_map)))
l3 = [x for x in l3 if (not self.filter_blacklist(x, blacklist))]
l4 = filter(lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, map(lambda x: [x[0] + 75, x[1] + 130],
Utils.find_all('enemy/fleet_3_up',
sim - 0.06,
self.chapter_map)))
l4 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 130], Utils.find_all('enemy/fleet_3_up', sim - 0.06, self.chapter_map)))
l4 = [x for x in l4 if (not self.filter_blacklist(x, blacklist))]
l5 = filter(lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, map(lambda x: [x[0] + 75, x[1] + 110],
Utils.find_all('enemy/fleet_3_down',
sim - 0.06,
self.chapter_map)))
l5 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_3_down', sim - 0.06, self.chapter_map)))
l5 = [x for x in l5 if (not self.filter_blacklist(x, blacklist))]
l6 = filter(lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, map(lambda x: [x[0] + 75, x[1] + 110],
Utils.find_all('enemy/fleet_2_up',
sim - 0.06,
self.chapter_map)))
l6 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_2_up', sim - 0.06, self.chapter_map)))
l6 = [x for x in l6 if (not self.filter_blacklist(x, blacklist))]

self.l = l1 + l2 + l3 + l4 + l5 + l6
Expand Down Expand Up @@ -578,13 +596,14 @@ def get_closest_target(self, blacklist=[], location=[], mystery_node=False):
enemy to the specified location
"""
while True:
boss = True if location else False
fleet_location = self.get_fleet_location()
mystery_nodes = []

if not location:
location = fleet_location

enemies = self.get_enemies(blacklist)
enemies = self.get_enemies(blacklist, boss)

if mystery_node:
sim = 0.9
Expand Down
9 changes: 6 additions & 3 deletions modules/commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def commission_logic_wrapper(self):
Utils.find("commission/alert_available", 0.9).y):
Logger.log_debug("Found commission available indicator.")
Utils.touch_randomly(self.region["button_go"])
Utils.script_sleep(1)
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()
Expand All @@ -74,10 +78,9 @@ def commission_logic_wrapper(self):
Utils.find("commission/button_go").y):
Logger.log_msg("All commissions are running.")
Utils.touch_randomly(self.region["dismiss_side_tab"])
Utils.wait_update_screen(3)
break

Utils.wait_update_screen(1)
Utils.wait_update_screen()
return True

def completed_handler(self):
Expand Down
Loading

0 comments on commit 9e7c782

Please sign in to comment.