diff --git a/assets/handler/MAP_GREEN.png b/assets/handler/MAP_GREEN.png new file mode 100644 index 000000000..895153034 Binary files /dev/null and b/assets/handler/MAP_GREEN.png differ diff --git a/assets/handler/MAP_STAR_1.png b/assets/handler/MAP_STAR_1.png new file mode 100644 index 000000000..5510e61e6 Binary files /dev/null and b/assets/handler/MAP_STAR_1.png differ diff --git a/assets/handler/MAP_STAR_2.png b/assets/handler/MAP_STAR_2.png new file mode 100644 index 000000000..12d0e3c25 Binary files /dev/null and b/assets/handler/MAP_STAR_2.png differ diff --git a/assets/handler/MAP_STAR_3.png b/assets/handler/MAP_STAR_3.png new file mode 100644 index 000000000..cf6168a83 Binary files /dev/null and b/assets/handler/MAP_STAR_3.png differ diff --git a/campaign/campaign_main/campaign_2_1.py b/campaign/campaign_main/campaign_2_1.py new file mode 100644 index 000000000..04950bd7f --- /dev/null +++ b/campaign/campaign_main/campaign_2_1.py @@ -0,0 +1,65 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger + + +MAP = CampaignMap() +MAP.shape = 'F4' +MAP.map_data = ''' + -- SP ME -- ME -- + SP -- ++ ++ ME MM + ++ -- ME -- ME ME + ++ ++ ++ MB -- ++ +''' +MAP.weight_data = ''' + 40 40 40 40 40 40 + 30 30 30 30 30 30 + 20 20 20 20 20 30 + 10 10 10 10 10 10 +''' +MAP.spawn_data = [ + {'battle': 0, 'enemy': 2, 'mystery': 1}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 2, 'boss': 1}, +] + +A1, B1, C1, D1, E1, F1, \ +A2, B2, C2, D2, E2, F2, \ +A3, B3, C3, D3, E3, F3, \ +A4, B4, C4, D4, E4, F4, \ + = MAP.flatten() + + +class Config: + FLEET_2 = 0 + SUBMARINE = 0 + INTERNAL_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (120, 255 - 40), + 'width': (1.5, 10), + 'prominence': 10, + 'distance': 35, + } + EDGE_LINES_FIND_PEAKS_PARAMETERS = { + 'height': (255 - 40, 255), + 'prominence': 10, + 'distance': 50, + 'wlen': 1000 + } + + +class Campaign(CampaignBase): + MAP = MAP + + def battle_0(self): + self.clear_all_mystery() + + return self.battle_default() + + def battle_2(self): + self.clear_all_mystery() + + if not self.check_accessibility(D4): + return self.battle_default() + + return self.clear_boss() diff --git a/campaign/campaign_main/campaign_2_2.py b/campaign/campaign_main/campaign_2_2.py new file mode 100644 index 000000000..40b4a502d --- /dev/null +++ b/campaign/campaign_main/campaign_2_2.py @@ -0,0 +1,54 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.campaign_main.campaign_2_1 import Config + + +MAP = CampaignMap() +MAP.shape = 'G5' +MAP.camera_data = ['D3'] +MAP.map_data = ''' + ++ ++ ++ MB ++ ++ ++ + ++ ++ ++ ME MA ++ ++ + -- ME -- ME -- -- ME + SP -- ME -- -- ME ME + -- ME -- -- SP ME MM +''' +MAP.weight_data = ''' + 10 10 10 10 10 10 10 + 10 10 10 10 10 10 10 + 50 50 50 50 50 50 50 + 30 30 30 30 30 30 30 + 30 30 30 30 30 30 30 +''' +MAP.spawn_data = [ + {'battle': 0, 'enemy': 2, 'mystery': 1}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 1}, + {'battle': 3, 'enemy': 2, 'boss':1}, +] + +A1, B1, C1, D1, E1, F1, G1, \ +A2, B2, C2, D2, E2, F2, G2, \ +A3, B3, C3, D3, E3, F3, G3, \ +A4, B4, C4, D4, E4, F4, G4, \ +A5, B5, C5, D5, E5, F5, G5, \ + = MAP.flatten() + + +class Campaign(CampaignBase): + MAP = MAP + + def battle_0(self): + self.clear_all_mystery() + + return self.battle_default() + + def battle_3(self): + self.clear_all_mystery() + + if not self.check_accessibility(D1): + return self.battle_default() + + return self.clear_boss() diff --git a/campaign/campaign_main/campaign_2_3.py b/campaign/campaign_main/campaign_2_3.py new file mode 100644 index 000000000..e5458632f --- /dev/null +++ b/campaign/campaign_main/campaign_2_3.py @@ -0,0 +1,54 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.campaign_main.campaign_2_1 import Config + + +MAP = CampaignMap() +MAP.shape = 'F5' +MAP.camera_data = ['D3'] +MAP.map_data = ''' + SP -- ME -- MB ++ + -- ME -- ME ++ ++ + -- -- ME -- -- ++ + SP -- -- ME ME -- + ++ ++ ++ -- ME MM +''' +MAP.weight_data = ''' + 10 10 10 10 10 10 + 50 50 10 10 10 10 + 20 20 20 20 20 20 + 20 20 20 20 30 30 + 30 30 30 30 30 30 +''' +MAP.spawn_data = [ + {'battle': 0, 'enemy': 2, 'mystery': 1}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 1}, + {'battle': 3, 'enemy': 2, 'boss':1}, +] + +A1, B1, C1, D1, E1, F1, \ +A2, B2, C2, D2, E2, F2, \ +A3, B3, C3, D3, E3, F3, \ +A4, B4, C4, D4, E4, F4, \ +A5, B5, C5, D5, E5, F5, \ + = MAP.flatten() + + +class Campaign(CampaignBase): + MAP = MAP + + def battle_0(self): + self.clear_all_mystery() + + return self.battle_default() + + def battle_3(self): + self.clear_all_mystery() + + if not self.check_accessibility(E1): + return self.battle_default() + + return self.clear_boss() diff --git a/campaign/campaign_main/campaign_2_4.py b/campaign/campaign_main/campaign_2_4.py new file mode 100644 index 000000000..f6f1fff85 --- /dev/null +++ b/campaign/campaign_main/campaign_2_4.py @@ -0,0 +1,47 @@ +from module.campaign.campaign_base import CampaignBase +from module.map.map_base import CampaignMap +from module.map.map_grids import SelectedGrids, RoadGrids +from module.logger import logger +from campaign.campaign_main.campaign_2_1 import Config + + +MAP = CampaignMap() +MAP.shape = 'G4' +MAP.camera_data = ['D2'] +MAP.map_data = ''' + -- ++ ++ ++ ME ME MB + SP -- ME -- -- ME -- + -- -- ME -- ME ++ ++ + -- ME -- SP -- MA ++ +''' +MAP.weight_data = ''' + 20 20 20 20 10 10 10 + 20 20 20 20 10 10 10 + 20 20 20 20 30 20 20 + 20 20 20 20 20 20 20 +''' +MAP.spawn_data = [ + {'battle': 0, 'enemy': 2}, + {'battle': 1, 'enemy': 2}, + {'battle': 2, 'enemy': 1}, + {'battle': 3, 'enemy': 2, 'boss':1}, +] + +A1, B1, C1, D1, E1, F1, G1, \ +A2, B2, C2, D2, E2, F2, G2, \ +A3, B3, C3, D3, E3, F3, G3, \ +A4, B4, C4, D4, E4, F4, G4, \ + = MAP.flatten() + + +class Campaign(CampaignBase): + MAP = MAP + + def battle_0(self): + return self.battle_default() + + def battle_3(self): + if not self.check_accessibility(G1): + return self.battle_default() + + return self.clear_boss() diff --git a/module/campaign/campaign_base.py b/module/campaign/campaign_base.py index 48a75076b..f1b7ee65a 100644 --- a/module/campaign/campaign_base.py +++ b/module/campaign/campaign_base.py @@ -25,6 +25,7 @@ class CampaignBase(Map): break logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2) + logger.info(f'Using function: {func}') func = self.__getattribute__(func) result = func() diff --git a/module/combat/combat.py b/module/combat/combat.py index 190688f81..d83bbfedb 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -123,7 +123,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem continue # Combat start - if self.appear_then_click(BATTLE_PREPARATION): + if self.appear_then_click(BATTLE_PREPARATION, interval=2): continue if self.handle_combat_automation_confirm(): @@ -259,6 +259,8 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem continue if self.handle_battle_status(save_get_items=save_get_items): continue + if self.handle_popup_confirm(): + continue if self.handle_get_ship(): continue if self.appear_then_click(EXP_INFO_S): @@ -294,7 +296,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem """ balance_hp = balance_hp if balance_hp is not None else self.config.ENABLE_HP_BALANCE emotion_reduce = emotion_reduce if emotion_reduce is not None else self.config.ENABLE_EMOTION_REDUCE - auto = func is None + auto = self.config.COMBAT_AUTO_MODE == 'combat_auto' call_submarine_at_boss = call_submarine_at_boss if call_submarine_at_boss is not None else self.config.SUBMARINE_CALL_AT_BOSS save_get_items = save_get_items if save_get_items is not None else self.config.ENABLE_SAVE_GET_ITEMS diff --git a/module/handler/assets.py b/module/handler/assets.py index db07995d0..e806e3655 100644 --- a/module/handler/assets.py +++ b/module/handler/assets.py @@ -28,6 +28,10 @@ MAP_AMBUSH = Button(area=(261, 433, 1280, 449), color=(161, 41, 43), button=(261 MAP_AMBUSH_EVADE = Button(area=(325, 393, 1280, 395), color=(255, 255, 255), button=(979, 444, 1152, 502), file='./assets/handler/MAP_AMBUSH_EVADE.png') MAP_BUFF = Button(area=(145, 115, 437, 159), color=(103, 118, 118), button=(145, 115, 437, 159), file='./assets/handler/MAP_BUFF.png') MAP_ENEMY_SEARCHING = Button(area=(531, 320, 864, 382), color=(200, 99, 91), button=(531, 320, 864, 382), file='./assets/handler/MAP_ENEMY_SEARCHING.png') +MAP_GREEN = Button(area=(195, 260, 349, 292), color=(125, 190, 84), button=(195, 260, 349, 292), file='./assets/handler/MAP_GREEN.png') +MAP_STAR_1 = Button(area=(245, 377, 254, 384), color=(251, 233, 143), button=(245, 377, 254, 384), file='./assets/handler/MAP_STAR_1.png') +MAP_STAR_2 = Button(area=(532, 377, 540, 384), color=(251, 233, 144), button=(532, 377, 540, 384), file='./assets/handler/MAP_STAR_2.png') +MAP_STAR_3 = Button(area=(818, 377, 827, 384), color=(251, 233, 143), button=(818, 377, 827, 384), file='./assets/handler/MAP_STAR_3.png') MYSTERY_ITEM = Button(area=(589, 294, 691, 427), color=(144, 127, 83), button=(589, 294, 691, 427), file='./assets/handler/MYSTERY_ITEM.png') POPUP_CANCEL = Button(area=(404, 493, 576, 550), color=(166, 169, 172), button=(404, 493, 576, 550), file='./assets/handler/POPUP_CANCEL.png') POPUP_CONFIRM = Button(area=(704, 493, 876, 550), color=(94, 144, 204), button=(704, 493, 876, 550), file='./assets/handler/POPUP_CONFIRM.png') diff --git a/module/handler/fast_forward.py b/module/handler/fast_forward.py index 4a52fff0f..c4b7c0806 100644 --- a/module/handler/fast_forward.py +++ b/module/handler/fast_forward.py @@ -13,6 +13,13 @@ fleet_lock.add_status('off', check_button=FLEET_UNLOCKED) class FastForwardHandler(ModuleBase): def handle_fast_forward(self): + if not self.appear(MAP_STAR_1) or not self.appear(MAP_STAR_2) or not self.appear(MAP_STAR_3): + logger.info('Campaign is not 3-star cleared.') + return False + if not self.appear(MAP_GREEN): + logger.info('Campaign is not green sea.') + return False + if not fast_forward.appear(main=self): self.config.ENABLE_FAST_FORWARD = False self.config.MAP_HAS_AMBUSH = True diff --git a/module/map/camera.py b/module/map/camera.py index 2f76665fe..ad8aaa00a 100644 --- a/module/map/camera.py +++ b/module/map/camera.py @@ -90,11 +90,11 @@ class Camera(InfoBarHandler): known_exception = self.info_bar_count() if len(self.grids.horizontal) > self.map.shape[1] + 2 or len(self.grids.vertical) > self.map.shape[0] + 2: if not known_exception: - logger.warn('Perspective Error. Too many lines') + logger.info('Perspective Error. Too many lines') self.grids.correct = False if len(self.grids.horizontal) <= 3 or len(self.grids.vertical) <= 3: if not known_exception: - logger.warn('Perspective Error. Too few lines') + logger.info('Perspective Error. Too few lines') self.grids.correct = False if not self.grids.correct: @@ -163,7 +163,7 @@ class Camera(InfoBarHandler): except PerspectiveError as e: msg = str(e).split(':')[1].strip() - logger.warning(f'Camera outside map: {msg}') + logger.info(f'Camera outside map: {msg}') dic = {'to the left': (2, 0), 'to the right': (-2, 0), 'to the lower': (0, 2), 'to the upper': (0, -2)} self._map_swipe(dic[msg]) continue diff --git a/module/map/fleet.py b/module/map/fleet.py index 89075c954..4a0dd8b06 100644 --- a/module/map/fleet.py +++ b/module/map/fleet.py @@ -245,6 +245,10 @@ class Fleet(Camera, AmbushHandler, MysteryHandler, MapOperation): else: return 'no_searching' + if 'boss' in expected: + return 'in_stage' + return 'no_searching' + def fleet_at(self, grid, fleet=None): """ Args: diff --git a/module/map/map_operation.py b/module/map/map_operation.py index 8b0e50256..3db4572b7 100644 --- a/module/map/map_operation.py +++ b/module/map/map_operation.py @@ -55,6 +55,8 @@ class MapOperation(UrgentCommissionHandler, EnemySearchingHandler, FleetPreparat # Map preparation if map_timer.reached() and self.appear(MAP_PREPARATION): + self.device.sleep(0.3) # Wait for map information. + self.device.screenshot() self.handle_fast_forward() self.device.click(MAP_PREPARATION) map_timer.reset() diff --git a/module/map/perspective.py b/module/map/perspective.py index 08dedfc9e..67504be22 100644 --- a/module/map/perspective.py +++ b/module/map/perspective.py @@ -111,7 +111,7 @@ class Perspective: '\\' if self.right_edge else ' ', len(self.vertical), len(vertical), len(edge_v)) ) if len(horizontal) - len(self.horizontal) >= 3 or len(vertical) - len(self.vertical) >= 3: - logger.warning('Too many deleted lines') + logger.info('Too many deleted lines') # self.save_error_image() def load_image(self, image): @@ -308,7 +308,7 @@ class Perspective: diff = abs(coincident_point[1] - 129) if diff > 3: self.correct = False - logger.warning('%s coincident point unexpected: %s' % ( + logger.info('%s coincident point unexpected: %s' % ( 'Horizontal' if is_horizontal else 'Vertical', str(coincident_point))) if diff > 6: diff --git a/module/reward/commission.py b/module/reward/commission.py index 6473fa61f..71f486e8d 100644 --- a/module/reward/commission.py +++ b/module/reward/commission.py @@ -373,10 +373,13 @@ class RewardCommission(UI, InfoBarHandler, PopupHandler): comm_timer.reset() if self.handle_popup_confirm(): + comm_timer.reset() pass if self.appear_then_click(COMMISSION_START, interval=3): + comm_timer.reset() pass if self.appear_then_click(COMMISSION_ADVICE, interval=3): + comm_timer.reset() pass if self.handle_info_bar():