diff --git a/alas.py b/alas.py index d6ab4861f..c2722aa5b 100644 --- a/alas.py +++ b/alas.py @@ -37,6 +37,11 @@ class AzurLaneAutoScript: with open(f'{folder}/log.txt', 'w') as f: f.writelines(text) + def reward_when_finished(self): + from module.reward.reward import Reward + az = Reward(self.config) + az.reward_loop() + def setting(self): for key, value in self.config.config['Setting'].items(): print(f'{key} = {value}') @@ -49,9 +54,7 @@ class AzurLaneAutoScript: print(f'{key} = {value}') logger.hr('Reward Settings saved') - from module.reward.reward import Reward - az = Reward(self.config) - az.reward_loop() + self.reward_when_finished() def emulator(self): for key, value in self.config.config['Emulator'].items(): @@ -72,20 +75,18 @@ class AzurLaneAutoScript: from module.campaign.run import CampaignRun az = CampaignRun(self.config) az.run(self.config.CAMPAIGN_NAME) + self.reward_when_finished() def daily(self): """ Method to run daily missions. """ - flag = True - if self.config.ENABLE_DAILY_MISSION: from module.daily.daily import Daily az = Daily(self.config) if not az.record_executed_since(): az.run() az.record_save() - flag = True if self.config.ENABLE_HARD_CAMPAIGN: from module.hard.hard import CampaignHard @@ -93,7 +94,6 @@ class AzurLaneAutoScript: if not az.record_executed_since(): az.run() az.record_save() - flag = True if self.config.ENABLE_EXERCISE: from module.exercise.exercise import Exercise @@ -101,12 +101,8 @@ class AzurLaneAutoScript: if not az.record_executed_since(): az.run() az.record_save() - flag = True - if flag: - from module.reward.reward import Reward - az = Reward(self.config) - az.reward() + self.reward_when_finished() def event(self): """ @@ -115,11 +111,13 @@ class AzurLaneAutoScript: from module.campaign.run import CampaignRun az = CampaignRun(self.config) az.run(self.config.CAMPAIGN_EVENT, folder=self.config.EVENT_NAME) + self.reward_when_finished() def event_daily_ab(self): from module.event.campaign_ab import CampaignAB az = CampaignAB(self.config) az.run_event_daily() + self.reward_when_finished() def semi_auto(self): from module.daemon.daemon import AzurLaneDaemon @@ -130,16 +128,19 @@ class AzurLaneAutoScript: from module.campaign.run import CampaignRun az = CampaignRun(self.config) az.run('campaign_7_2_mystery_farming') + self.reward_when_finished() def c124_leveling(self): from module.campaign.run import CampaignRun az = CampaignRun(self.config) az.run('campaign_12_4_leveling') + self.reward_when_finished() def c122_leveling(self): from module.campaign.run import CampaignRun az = CampaignRun(self.config) az.run('campaign_12_2_leveling') + self.reward_when_finished() def retire(self): from module.retire.retirement import Retirement diff --git a/assets/cn/reward/COMMISSION_SCROLL.png b/assets/cn/reward/COMMISSION_SCROLL.png new file mode 100644 index 000000000..27d5d9294 Binary files /dev/null and b/assets/cn/reward/COMMISSION_SCROLL.png differ diff --git a/assets/cn/reward/COMMISSION_SCROLL_TOP.png b/assets/cn/reward/COMMISSION_SCROLL_TOP.png new file mode 100644 index 000000000..f31cb4b8a Binary files /dev/null and b/assets/cn/reward/COMMISSION_SCROLL_TOP.png differ diff --git a/assets/en/reward/COMMISSION_SCROLL.png b/assets/en/reward/COMMISSION_SCROLL.png new file mode 100644 index 000000000..27d5d9294 Binary files /dev/null and b/assets/en/reward/COMMISSION_SCROLL.png differ diff --git a/assets/en/reward/COMMISSION_SCROLL_TOP.png b/assets/en/reward/COMMISSION_SCROLL_TOP.png new file mode 100644 index 000000000..f31cb4b8a Binary files /dev/null and b/assets/en/reward/COMMISSION_SCROLL_TOP.png differ diff --git a/campaign/campaign_main/campaign_10_1.py b/campaign/campaign_main/campaign_10_1.py index ecad3a6f7..e5d13e440 100644 --- a/campaign/campaign_main/campaign_10_1.py +++ b/campaign/campaign_main/campaign_10_1.py @@ -3,35 +3,34 @@ from module.map.map_base import CampaignMap from module.map.map_grids import SelectedGrids, RoadGrids from module.logger import logger - MAP = CampaignMap('10-1') MAP.shape = 'G6' MAP.map_data = ''' - SP -- ++ -- ME ME -- - -- -- ++ ME ME ME ME - -- ME ME ME ++ ++ MB - -- ME ME ME ME ++ MB - -- -- ++ -- ME ME ME - SP -- ++ ++ -- -- ++ + SP -- ++ -- ME ME -- + -- -- ++ ME ME ME ME + -- ME ME ME ++ ++ MB + -- ME ME ME ME ++ MB + -- -- ++ -- ME ME ME + SP -- ++ ++ -- -- ++ ''' MAP.weight_data = ''' - 10 10 10 10 40 40 10 - 10 20 10 30 30 40 40 - 10 40 30 30 30 10 10 - 10 10 10 10 30 10 10 - 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 + 50 50 50 50 50 40 50 + 50 50 50 30 30 50 40 + 50 40 30 30 30 50 05 + 50 25 20 20 30 50 05 + 50 50 50 15 10 10 05 + 50 50 50 50 50 50 50 ''' # MAP.camera_data = ['D3'] MAP.spawn_data = [ - {'battle': 0, 'enemy': 4}, - {'battle': 1, 'enemy': 1}, - {'battle': 2, 'enemy': 1}, - {'battle': 3, 'enemy': 1}, - {'battle': 4, 'enemy': 1}, - {'battle': 5}, - {'battle': 6, 'boss': 1}, - ] + {'battle': 0, 'enemy': 4}, + {'battle': 1, 'enemy': 1}, + {'battle': 2, 'enemy': 1}, + {'battle': 3, 'enemy': 1}, + {'battle': 4, 'enemy': 1}, + {'battle': 5}, + {'battle': 6, 'boss': 1}, +] A1, B1, C1, D1, E1, F1, G1, \ A2, B2, C2, D2, E2, F2, G2, \ @@ -45,40 +44,42 @@ road_main = RoadGrids([B4, C4, D4, E5, F5, G5]) class Config: - INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 - EDGE_LINES_HOUGHLINES_THRESHOLD = 40 - COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 - INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 + EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (150, 255 - 24), 'width': (0.9, 10), 'prominence': 10, 'distance': 35, - } - EDGE_LINES_FIND_PEAKS_PARAMETERS = { + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { 'height': (255 - 24, 255), 'prominence': 10, 'distance': 50, 'width': (0, 10), 'wlen': 1000, - } + } class Campaign(CampaignBase): - MAP = MAP - - def battle_0(self): - if self.clear_roadblocks([road_main]): - return True - if self.clear_potential_roadblocks([road_main]): - return True + MAP = MAP - return self.battle_default() + def battle_0(self): + self.fleet_2_push_forward() - def battle_6(self): - boss = self.map.select(is_boss=True) - if boss: - if not self.check_accessibility(boss[0], fleet=2): - if self.clear_roadblocks([road_main]): - return True - - return self.fleet_2.clear_boss() \ No newline at end of file + if self.clear_roadblocks([road_main]): + return True + if self.clear_potential_roadblocks([road_main]): + return True + + return self.battle_default() + + def battle_6(self): + boss = self.map.select(is_boss=True) + if boss: + if not self.check_accessibility(boss[0], fleet=2): + if self.clear_roadblocks([road_main]): + return True + + return self.fleet_2.clear_boss() diff --git a/campaign/campaign_main/campaign_10_2.py b/campaign/campaign_main/campaign_10_2.py index d65808fc1..1606dd3d0 100644 --- a/campaign/campaign_main/campaign_10_2.py +++ b/campaign/campaign_main/campaign_10_2.py @@ -3,7 +3,6 @@ from module.map.map_base import CampaignMap from module.map.map_grids import SelectedGrids, RoadGrids from module.logger import logger - MAP = CampaignMap('10-2') MAP.shape = 'h6' MAP.map_data = ''' diff --git a/campaign/campaign_main/campaign_10_4.py b/campaign/campaign_main/campaign_10_4.py index 944d4eb4f..3c6f93a30 100644 --- a/campaign/campaign_main/campaign_10_4.py +++ b/campaign/campaign_main/campaign_10_4.py @@ -3,7 +3,6 @@ from module.map.map_base import CampaignMap from module.map.map_grids import SelectedGrids, RoadGrids from module.logger import logger - MAP = CampaignMap('10-4') MAP.shape = 'I6' MAP.map_data = ''' diff --git a/campaign/campaign_main/campaign_3_1.py b/campaign/campaign_main/campaign_3_1.py index b87a7025d..1f35beedf 100644 --- a/campaign/campaign_main/campaign_3_1.py +++ b/campaign/campaign_main/campaign_3_1.py @@ -34,11 +34,10 @@ A4, B4, C4, D4, E4, F4, G4, \ class Config: FLEET_BOSS = 1 - MAP_MYSTERY_HAS_CARRIER = True INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 - EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + EDGE_LINES_HOUGHLINES_THRESHOLD = 75 INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (120, 255 - 40), 'width': (1.5, 10), diff --git a/campaign/campaign_main/campaign_3_2.py b/campaign/campaign_main/campaign_3_2.py index e0e833019..35dcd4869 100644 --- a/campaign/campaign_main/campaign_3_2.py +++ b/campaign/campaign_main/campaign_3_2.py @@ -48,7 +48,6 @@ class Campaign(CampaignBase): return self.battle_default() def battle_3(self): - # print(H1.__dict__) self.clear_all_mystery() if not self.check_accessibility(H1, fleet='boss'): diff --git a/campaign/campaign_main/campaign_7_1.py b/campaign/campaign_main/campaign_7_1.py index 9f46e1556..97bf63c44 100644 --- a/campaign/campaign_main/campaign_7_1.py +++ b/campaign/campaign_main/campaign_7_1.py @@ -11,6 +11,7 @@ MAP.map_data = ''' SP -- ++ ++ -- ME ME MB ''' MAP.camera_data = ['C1', 'E1'] +MAP.camera_data_spawn_point = ['C1'] MAP.weight_data = ''' 40 30 21 20 17 15 50 50 40 40 50 50 16 13 50 50 diff --git a/campaign/campaign_main/campaign_9_2.py b/campaign/campaign_main/campaign_9_2.py index d537d91bb..b38d8cfe3 100644 --- a/campaign/campaign_main/campaign_9_2.py +++ b/campaign/campaign_main/campaign_9_2.py @@ -3,32 +3,31 @@ from module.map.map_base import CampaignMap from module.map.map_grids import SelectedGrids, RoadGrids from module.logger import logger - MAP = CampaignMap('9-2') MAP.shape = 'I5' MAP.map_data = ''' - ++ ++ ME -- MB ME -- ME -- - MM ++ ME ME MB ME ++ ME -- - ME -- ME ++ ++ ++ ++ ME ++ - -- ++ -- -- ++ SP -- ME -- - -- ME -- SP ++ SP -- -- -- + ++ ++ ME -- MB ME -- ME -- + MM ++ ME ME MB ME ++ ME -- + ME -- ME ++ ++ ++ ++ ME ++ + -- ++ -- -- ++ SP -- ME -- + -- ME -- SP ++ SP -- -- -- ''' -#MAP.weight_data = ''' -# 10 10 30 10 10 10 10 10 10 -# 10 10 20 30 10 30 10 10 10 -# 30 10 20 10 10 10 10 10 10 -# 10 10 10 10 10 10 10 10 10 -# 10 30 10 10 10 10 10 10 10 -#''' -#MAP.camera_data = ['D4'] +MAP.weight_data = ''' + 10 10 30 10 10 10 10 10 10 + 10 10 20 30 10 30 10 10 10 + 30 10 20 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 10 + 10 30 10 10 10 10 10 10 10 +''' +MAP.camera_data = ['D4'] MAP.spawn_data = [ - {'battle': 0, 'enemy': 3}, - {'battle': 1, 'enemy': 2}, - {'battle': 2, 'enemy': 2}, - {'battle': 3, 'enemy': 1}, - {'battle': 4, 'enemy': 1}, - {'battle': 5, 'boss': 1}, - ] + {'battle': 0, 'enemy': 3}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 2}, + {'battle': 3, 'enemy': 1}, + {'battle': 4, 'enemy': 1}, + {'battle': 5, 'boss': 1}, +] A1, B1, C1, D1, E1, F1, G1, H1, I1, \ A2, B2, C2, D2, E2, F2, G2, H2, I2, \ @@ -40,66 +39,66 @@ A5, B5, C5, D5, E5, F5, G5, H5, I5, \ road_main = RoadGrids([C3, C2, [C1, D2], F1, H1, H2, H3, H4]) - class Config: - SUBMARINE = 0 - INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 - EDGE_LINES_HOUGHLINES_THRESHOLD = 40 - COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 - INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + SUBMARINE = 0 + INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 + EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (150, 255 - 24), 'width': (0.9, 10), 'prominence': 10, 'distance': 35, - } - EDGE_LINES_FIND_PEAKS_PARAMETERS = { + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { 'height': (255 - 24, 255), 'prominence': 10, 'distance': 50, 'width': (0, 10), 'wlen': 1000, - } + } + class Campaign(CampaignBase): - MAP = MAP + MAP = MAP - def battle_0(self): - if self.fleet_at(D5, fleet=2): - self.map.weight_data = ''' - 10 10 30 10 10 20 30 40 10 - 10 10 10 10 10 30 10 50 10 - 30 10 10 10 10 10 10 60 10 - 10 10 10 10 10 10 10 70 10 - 10 30 10 10 10 10 10 10 10 - ''' - if self.fleet_at(F4, fleet=2): - self.map.weight_data = ''' - 10 10 30 10 10 10 10 10 10 - 10 10 20 30 10 30 10 10 10 - 30 10 20 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 - 10 30 10 10 10 10 10 10 10 - ''' - if self.fleet_at(F5, fleet=2): - self.map.weight_data = ''' - 10 10 30 10 10 10 10 10 10 - 10 10 20 30 10 30 10 10 10 - 30 10 20 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 - 10 30 10 10 10 10 10 10 10 - ''' - if self.clear_roadblocks([road_main]): - return True - if self.clear_potential_roadblocks([road_main]): - return True + def battle_0(self): + if self.fleet_at(D5, fleet=2): + self.map.weight_data = ''' + 10 10 30 10 10 20 30 40 10 + 10 10 10 10 10 30 10 50 10 + 30 10 10 10 10 10 10 60 10 + 10 10 10 10 10 10 10 70 10 + 10 30 10 10 10 10 10 10 10 + ''' + if self.fleet_at(F4, fleet=2): + self.map.weight_data = ''' + 10 10 30 10 10 10 10 10 10 + 10 10 20 30 10 30 10 10 10 + 30 10 20 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 10 + 10 30 10 10 10 10 10 10 10 + ''' + if self.fleet_at(F5, fleet=2): + self.map.weight_data = ''' + 10 10 30 10 10 10 10 10 10 + 10 10 20 30 10 30 10 10 10 + 30 10 20 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 10 + 10 30 10 10 10 10 10 10 10 + ''' + if self.clear_roadblocks([road_main]): + return True + if self.clear_potential_roadblocks([road_main]): + return True - return self.battle_default() + return self.battle_default() - def battle_5(self): - boss = self.map.select(is_boss=True) - if boss: - if not self.check_accessibility(boss[0], fleet=2): - if self.clear_roadblocks([road_main]): - return True - - return self.fleet_2.clear_boss() \ No newline at end of file + def battle_5(self): + boss = self.map.select(is_boss=True) + if boss: + if not self.check_accessibility(boss[0], fleet=2): + if self.clear_roadblocks([road_main]): + return True + + return self.fleet_2.clear_boss() diff --git a/campaign/campaign_main/campaign_9_3.py b/campaign/campaign_main/campaign_9_3.py index fdf120fed..d8521199c 100644 --- a/campaign/campaign_main/campaign_9_3.py +++ b/campaign/campaign_main/campaign_9_3.py @@ -3,34 +3,33 @@ from module.map.map_base import CampaignMap from module.map.map_grids import SelectedGrids, RoadGrids from module.logger import logger - MAP = CampaignMap('9-3') MAP.shape = 'H6' MAP.map_data = ''' - MB -- ME -- ME -- ++ MB - ME ++ ++ ++ MB ME ++ -- - ME __ -- SP ++ ME ME -- - -- -- ME ++ SP -- __ ME - ++ -- ME MB ++ ++ ++ -- - ++ ++ -- ME -- ME ME MB + MB -- ME -- ME -- ++ MB + ME ++ ++ ++ MB ME ++ -- + ME __ -- SP ++ ME ME -- + -- -- ME ++ SP -- __ ME + ++ -- ME MB ++ ++ ++ -- + ++ ++ -- ME -- ME ME MB ''' MAP.weight_data = ''' - 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 20 10 - 10 10 20 10 10 10 10 10 - 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 20 10 + 10 10 20 10 10 10 10 10 + 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 ''' -#MAP.camera_data = ['D4'] +# MAP.camera_data = ['D4'] MAP.spawn_data = [ - {'battle': 0, 'enemy': 3}, - {'battle': 1, 'enemy': 2}, - {'battle': 2, 'enemy': 2}, - {'battle': 3, 'enemy': 1}, - {'battle': 4, 'enemy': 1}, - {'battle': 5, 'boss': 1}, - ] + {'battle': 0, 'enemy': 3}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 2}, + {'battle': 3, 'enemy': 1}, + {'battle': 4, 'enemy': 1}, + {'battle': 5, 'boss': 1}, +] A1, B1, C1, D1, E1, F1, G1, H1, \ A2, B2, C2, D2, E2, F2, G2, H2, \ @@ -42,40 +41,42 @@ A6, B6, C6, D6, E6, F6, G6, H6, \ road_main = RoadGrids([A2, A3, C5, D6, F2, F3, F6, G6, H4]) + class Config: - INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 - EDGE_LINES_HOUGHLINES_THRESHOLD = 40 - COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 - INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 + EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (150, 255 - 24), 'width': (0.9, 10), 'prominence': 10, 'distance': 35, - } - EDGE_LINES_FIND_PEAKS_PARAMETERS = { + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { 'height': (255 - 24, 255), 'prominence': 10, 'distance': 50, 'width': (0, 10), 'wlen': 1000, - } + } + class Campaign(CampaignBase): - MAP = MAP + MAP = MAP - def battle_0(self): - if self.clear_roadblocks([road_main]): - return True - if self.clear_potential_roadblocks([road_main]): - return True + def battle_0(self): + if self.clear_roadblocks([road_main]): + return True + if self.clear_potential_roadblocks([road_main]): + return True - return self.battle_default() + return self.battle_default() - def battle_5(self): - boss = self.map.select(is_boss=True) - if boss: - if not self.check_accessibility(boss[0], fleet=2): - if self.clear_roadblocks([road_main]): - return True - - return self.fleet_2.clear_boss() \ No newline at end of file + def battle_5(self): + boss = self.map.select(is_boss=True) + if boss: + if not self.check_accessibility(boss[0], fleet=2): + if self.clear_roadblocks([road_main]): + return True + + return self.fleet_2.clear_boss() diff --git a/campaign/campaign_main/campaign_9_4.py b/campaign/campaign_main/campaign_9_4.py index d708b9b76..3ca32c481 100644 --- a/campaign/campaign_main/campaign_9_4.py +++ b/campaign/campaign_main/campaign_9_4.py @@ -7,31 +7,31 @@ MAP = CampaignMap('9-4') MAP.shape = 'I6' MAP.map_data = ''' - MB -- ME -- ++ ++ ++ -- MB - -- ++ __ ME -- ME ME ME -- - ME -- ME -- ME -- __ ++ -- - ME -- ++ ++ -- -- ME __ ME - SP -- MA ++ ME -- ++ ME -- - SP -- -- ME -- ME ++ -- MB + MB -- ME -- ++ ++ ++ -- MB + -- ++ __ ME -- ME ME ME -- + ME -- ME -- ME -- __ ++ -- + ME -- ++ ++ -- -- ME __ ME + SP -- MA ++ ME -- ++ ME -- + SP -- -- ME -- ME ++ -- MB ''' MAP.weight_data = ''' - 10 10 20 10 10 10 10 10 10 - 10 10 10 20 10 10 10 10 10 - 10 10 20 10 20 10 10 10 10 - 20 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 + 10 10 20 10 10 10 10 10 10 + 10 10 10 20 10 10 10 10 10 + 10 10 20 10 20 10 10 10 10 + 20 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 10 10 10 ''' MAP.spawn_data = [ - {'battle': 0, 'enemy': 3}, - {'battle': 1, 'enemy': 2}, - {'battle': 2, 'enemy': 2}, - {'battle': 3, 'enemy': 1}, - {'battle': 4, 'enemy': 2}, - {'battle': 5, 'boss': 1}, - ] + {'battle': 0, 'enemy': 3}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 2}, + {'battle': 3, 'enemy': 1}, + {'battle': 4, 'enemy': 2}, + {'battle': 5, 'boss': 1}, +] A1, B1, C1, D1, E1, F1, G1, H1, I1, \ A2, B2, C2, D2, E2, F2, G2, H2, I2, \ @@ -43,40 +43,42 @@ A6, B6, C6, D6, E6, F6, G6, H6, I6, \ road_main = RoadGrids([A3, D6, [E5, F6], G4, I4]) + class Config: - INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 - EDGE_LINES_HOUGHLINES_THRESHOLD = 40 - COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 - INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + INTERNAL_LINES_HOUGHLINES_THRESHOLD = 40 + EDGE_LINES_HOUGHLINES_THRESHOLD = 40 + COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5 + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { 'height': (150, 255 - 24), 'width': (0.9, 10), 'prominence': 10, 'distance': 35, - } - EDGE_LINES_FIND_PEAKS_PARAMETERS = { + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { 'height': (255 - 24, 255), 'prominence': 10, 'distance': 50, 'width': (0, 10), 'wlen': 1000, - } + } + class Campaign(CampaignBase): - MAP = MAP + MAP = MAP - def battle_0(self): - if self.clear_roadblocks([road_main]): - return True - if self.clear_potential_roadblocks([road_main]): - return True + def battle_0(self): + if self.clear_roadblocks([road_main]): + return True + if self.clear_potential_roadblocks([road_main]): + return True - return self.battle_default() + return self.battle_default() - def battle_5(self): - boss = self.map.select(is_boss=True) - if boss: - if not self.check_accessibility(boss[0], fleet=2): - if self.clear_roadblocks([road_main]): - return True - - return self.fleet_2.clear_boss() \ No newline at end of file + def battle_5(self): + boss = self.map.select(is_boss=True) + if boss: + if not self.check_accessibility(boss[0], fleet=2): + if self.clear_roadblocks([road_main]): + return True + + return self.fleet_2.clear_boss() diff --git a/module/config/config.py b/module/config/config.py index 6760073f8..ff4fa599b 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -382,6 +382,11 @@ class AzurLaneConfig: logger.warning(f'Mob fleet [{self.FLEET_1}] and boss fleet [{self.FLEET_2}] is the same') logger.warning('They should to be set to different fleets') exit(1) + if self.COMMAND.lower() == 'main' and self.CAMPAIGN_NAME.startswith('campaign_'): + if int(self.CAMPAIGN_NAME.split('_')[1]) >= 7 and self.FLEET_2 == 0: + logger.warning('You should use 2 fleets from chapter 7 to 13') + logger.warning(f'Current: mob fleet [{self.FLEET_1}], boss fleet [{self.FLEET_2}]') + exit(1) def save(self): self.config.write(codecs.open(self.CONFIG_FILE, "w+", "utf8")) diff --git a/module/map/camera.py b/module/map/camera.py index 4900257fe..e3aa810db 100644 --- a/module/map/camera.py +++ b/module/map/camera.py @@ -113,7 +113,7 @@ class Camera(InfoHandler): try: self.grids = Grids(self.device.image, config=self.config) - except PerspectiveError as e: + except Exception as e: if self.info_bar_count(): logger.info('Perspective error cause by info bar. Waiting.') self.handle_info_bar() @@ -258,10 +258,17 @@ class Camera(InfoHandler): self.map.reset_fleet() queue = self.map.camera_data + if battle_count == 0: + queue.add(self.map.camera_data_spawn_point) + while len(queue) > 0: if self.map.missing_is_none(battle_count, mystery_count, siren_count, carrier_count): - logger.info('All spawn found, Early stopped.') - break + if battle_count == 0 and queue.count != queue.delete(self.map.camera_data_spawn_point).count: + logger.info('Continue scanning spawn points.') + pass + else: + logger.info('All spawn found, Early stopped.') + break queue = queue.sort_by_camera_distance(self.camera) self.focus_to(queue[0]) self.predict(is_carrier_scan=is_carrier_scan) diff --git a/module/map/map_base.py b/module/map/map_base.py index 5b8829040..094b16bef 100644 --- a/module/map/map_base.py +++ b/module/map/map_base.py @@ -45,6 +45,7 @@ class CampaignMap: self._spawn_data = [] self._spawn_data_backup = [] self._camera_data = [] + self._camera_data_spawn_point = [] self.in_map_swipe_preset_data = None self.poor_map_data = False self.camera_sight = (-3, -1, 3, 2) @@ -89,6 +90,7 @@ class CampaignMap: # camera_data can be generate automatically, but it's better to set it manually. self.camera_data = [location2node(loca) for loca in camera_2d(self._shape, sight=self.camera_sight)] + self.camera_data_spawn_point = [] # weight_data set to 10. for grid in self: grid.weight = 10. @@ -208,6 +210,23 @@ class CampaignMap: """ self._camera_data = SelectedGrids([self[node2location(node)] for node in nodes]) + @property + def camera_data_spawn_point(self): + """Additional camera_data to detect fleets at spawn point. + + Returns: + SelectedGrids: + """ + return self._camera_data_spawn_point + + @camera_data_spawn_point.setter + def camera_data_spawn_point(self, nodes): + """ + Args: + nodes (list): Contains str. + """ + self._camera_data_spawn_point = SelectedGrids([self[node2location(node)] for node in nodes]) + @property def spawn_data(self): return self._spawn_data diff --git a/module/map/map_grids.py b/module/map/map_grids.py index 99253331a..a033d6b17 100644 --- a/module/map/map_grids.py +++ b/module/map/map_grids.py @@ -92,7 +92,7 @@ class SelectedGrids: Returns: SelectedGrids: """ - return SelectedGrids(self.grids + grids.grids) + return SelectedGrids(list(set(self.grids + grids.grids))) def delete(self, grids): """ diff --git a/module/reward/assets.py b/module/reward/assets.py index 1e6b9b4ad..da8da9b14 100644 --- a/module/reward/assets.py +++ b/module/reward/assets.py @@ -9,6 +9,8 @@ COMMISSION_ADVICE = Button(area={'cn': (871, 322, 999, 383), 'en': (871, 328, 10 COMMISSION_DAILY = Button(area={'cn': (35, 132, 67, 186), 'en': (30, 126, 75, 188)}, color={'cn': (208, 172, 118), 'en': (170, 132, 92)}, button={'cn': (35, 132, 67, 186), 'en': (30, 126, 75, 188)}, file={'cn': './assets/cn/reward/COMMISSION_DAILY.png', 'en': './assets/en/reward/COMMISSION_DAILY.png'}) COMMISSION_HAS_PENDING = Button(area={'cn': (357, 300, 359, 330), 'en': (357, 300, 359, 330)}, color={'cn': (86, 201, 173), 'en': (81, 205, 174)}, button={'cn': (357, 300, 359, 330), 'en': (357, 300, 359, 330)}, file={'cn': './assets/cn/reward/COMMISSION_HAS_PENDING.png', 'en': './assets/en/reward/COMMISSION_HAS_PENDING.png'}) COMMISSION_NOTICE_AT_CAMPAIGN = Button(area={'cn': (1054, 647, 1061, 654), 'en': (1054, 647, 1061, 654)}, color={'cn': (197, 89, 64), 'en': (197, 89, 64)}, button={'cn': (1054, 647, 1061, 654), 'en': (1054, 647, 1061, 654)}, file={'cn': './assets/cn/reward/COMMISSION_NOTICE_AT_CAMPAIGN.png', 'en': './assets/en/reward/COMMISSION_NOTICE_AT_CAMPAIGN.png'}) +COMMISSION_SCROLL = Button(area={'cn': (1255, 0, 1260, 720), 'en': (1255, 0, 1260, 720)}, color={'cn': (111, 104, 69), 'en': (111, 104, 69)}, button={'cn': (1255, 0, 1260, 720), 'en': (1255, 0, 1260, 720)}, file={'cn': './assets/cn/reward/COMMISSION_SCROLL.png', 'en': './assets/en/reward/COMMISSION_SCROLL.png'}) +COMMISSION_SCROLL_TOP = Button(area={'cn': (1254, 81, 1261, 88), 'en': (1254, 81, 1261, 88)}, color={'cn': (247, 209, 66), 'en': (247, 209, 66)}, button={'cn': (1254, 81, 1261, 88), 'en': (1254, 81, 1261, 88)}, file={'cn': './assets/cn/reward/COMMISSION_SCROLL_TOP.png', 'en': './assets/en/reward/COMMISSION_SCROLL_TOP.png'}) COMMISSION_START = Button(area={'cn': (1028, 322, 1156, 383), 'en': (1031, 333, 1147, 383)}, color={'cn': (229, 175, 113), 'en': (227, 169, 108)}, button={'cn': (1028, 322, 1156, 383), 'en': (1031, 333, 1147, 383)}, file={'cn': './assets/cn/reward/COMMISSION_START.png', 'en': './assets/en/reward/COMMISSION_START.png'}) COMMISSION_STOP_SCROLLING = Button(area={'cn': (115, 236, 179, 487), 'en': (115, 236, 179, 487)}, color={'cn': (50, 55, 74), 'en': (50, 55, 74)}, button={'cn': (115, 236, 179, 487), 'en': (115, 236, 179, 487)}, file={'cn': './assets/cn/reward/COMMISSION_STOP_SCROLLING.png', 'en': './assets/en/reward/COMMISSION_STOP_SCROLLING.png'}) COMMISSION_URGENT = Button(area={'cn': (35, 231, 68, 281), 'en': (28, 221, 76, 283)}, color={'cn': (215, 188, 124), 'en': (169, 138, 95)}, button={'cn': (35, 231, 68, 281), 'en': (28, 221, 76, 283)}, file={'cn': './assets/cn/reward/COMMISSION_URGENT.png', 'en': './assets/en/reward/COMMISSION_URGENT.png'}) diff --git a/module/reward/commission.py b/module/reward/commission.py index 50a494918..456d2760a 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -9,6 +9,7 @@ from module.base.decorator import Config from module.base.ocr import Ocr from module.base.timer import Timer from module.base.utils import area_offset, get_color, random_rectangle_vector +from module.base.utils import color_similar_1d, random_rectangle_point from module.handler.info_handler import InfoHandler from module.logger import logger from module.reward.assets import * @@ -413,6 +414,26 @@ class RewardCommission(UI, InfoHandler): self.device.sleep(0.3) self.device.screenshot() + def _commission_swipe_to_top(self, bar_padding_y=10): + if self.appear(COMMISSION_SCROLL_TOP): + # Already at top + return False + + mean = np.mean(self.device.image.crop(COMMISSION_SCROLL.area), axis=1) + bar = np.where(color_similar_1d(mean, color=(247, 211, 66)))[0] + if len(bar) < bar_padding_y * 2: + # No scroll found. + return False + + bar = (COMMISSION_SCROLL.area[0], np.min(bar) + bar_padding_y, + COMMISSION_SCROLL.area[2], np.max(bar) - bar_padding_y) + p1 = random_rectangle_point(bar) + p2 = random_rectangle_point(COMMISSION_SCROLL_TOP.area) + self.device.drag(p1, p2, shake=(15, 0), point_random=(0, 0, 0, 0)) + self.device.sleep(0.3) + self.device.screenshot() + return True + def _commission_scan_list(self): commission = CommissionGroup(self.config) commission.merge(self.device.image) @@ -432,10 +453,12 @@ class RewardCommission(UI, InfoHandler): def _commission_scan_all(self): logger.hr('Scan daily') self._commission_ensure_mode('daily') + self._commission_swipe_to_top() daily = self._commission_scan_list() logger.hr('Scan urgent') self._commission_ensure_mode('urgent') + self._commission_swipe_to_top() urgent = self._commission_scan_list() logger.hr('Showing commission') @@ -529,11 +552,13 @@ class RewardCommission(UI, InfoHandler): for comm in self.daily_choose: if not self._commission_ensure_mode('daily'): self._commission_mode_reset() + self._commission_swipe_to_top() self._commission_find_and_start(comm) if self.urgent_choose: for comm in self.urgent_choose: if not self._commission_ensure_mode('urgent'): self._commission_mode_reset() + self._commission_swipe_to_top() self._commission_find_and_start(comm) if not self.daily_choose and not self.urgent_choose: logger.info('No commission chose')