1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-09 18:39:04 +08:00
AzurLaneAutoScript/module/handler/strategy.py

262 lines
8.7 KiB
Python
Raw Normal View History

from module.combat.assets import GET_ITEMS_1
from module.handler.assets import *
2020-05-15 14:18:14 +08:00
from module.handler.info_handler import InfoHandler
from module.logger import logger
2022-04-15 03:37:54 +08:00
from module.template.assets import (TEMPLATE_FORMATION_1, TEMPLATE_FORMATION_2,
TEMPLATE_FORMATION_3)
from module.ui.switch import Switch
2023-10-19 22:42:53 +08:00
# 2023.10.19, icons on one row increased from 2 to 3
2024-12-10 03:28:20 +08:00
FORMATION = Switch('Formation', offset=(100, 200))
FORMATION.add_state('line_ahead', check_button=FORMATION_1)
FORMATION.add_state('double_line', check_button=FORMATION_2)
FORMATION.add_state('diamond', check_button=FORMATION_3)
2024-12-10 03:28:20 +08:00
SUBMARINE_HUNT = Switch('Submarine_hunt', offset=(200, 200))
SUBMARINE_HUNT.add_state('on', check_button=SUBMARINE_HUNT_ON)
SUBMARINE_HUNT.add_state('off', check_button=SUBMARINE_HUNT_OFF)
2020-03-29 01:22:46 +08:00
2024-12-10 03:28:20 +08:00
SUBMARINE_VIEW = Switch('Submarine_view', offset=(100, 200))
SUBMARINE_VIEW.add_state('on', check_button=SUBMARINE_VIEW_ON)
SUBMARINE_VIEW.add_state('off', check_button=SUBMARINE_VIEW_OFF)
2020-08-10 18:02:10 +08:00
MOB_MOVE_OFFSET = (120, 200)
2020-08-10 18:02:10 +08:00
2020-05-15 14:18:14 +08:00
class StrategyHandler(InfoHandler):
fleet_1_formation_fixed = False
fleet_2_formation_fixed = False
def strategy_open(self, skip_first_screenshot=True):
logger.info('Strategy open')
2020-10-31 22:49:22 +08:00
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
2020-10-31 22:49:22 +08:00
if self.appear(STRATEGY_OPENED, offset=200):
2020-10-31 22:49:22 +08:00
break
if self.appear(IN_MAP, interval=5) and not self.appear(STRATEGY_OPENED, offset=200):
self.device.click(STRATEGY_OPEN)
continue
# Handle missed mysteries
if self.appear_then_click(GET_ITEMS_1, offset=5):
continue
def strategy_close(self, skip_first_screenshot=True):
logger.info('Strategy close')
2020-10-31 22:49:22 +08:00
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if self.appear_then_click(STRATEGY_OPENED, offset=200, interval=5):
continue
2020-10-31 22:49:22 +08:00
if not self.appear(STRATEGY_OPENED, offset=200):
2020-10-31 22:49:22 +08:00
break
2024-12-10 03:28:20 +08:00
def strategy_set_execute(self, formation=None, sub_view=None, sub_hunt=None):
"""
Args:
2024-12-10 03:28:20 +08:00
formation (str): 'line_ahead', 'double_line', 'diamond', or None for don't change
sub_view (bool):
sub_hunt (bool):
Pages:
in: STRATEGY_OPENED
"""
2024-12-10 03:28:20 +08:00
logger.info(f'Strategy set: formation={formation}, submarine_view={sub_view}, submarine_hunt={sub_hunt}')
2024-12-10 03:28:20 +08:00
if formation is not None:
FORMATION.set(formation, main=self)
# Disable this until the icon bug of submarine zone is fixed
# And don't enable MAP_HAS_DYNAMIC_RED_BORDER when using submarine
2020-08-10 18:02:10 +08:00
# Submarine view check is back again, see SwitchWithHandler.
# Don't know when but the game bug was fixed, remove the use of SwitchWithHandler
if sub_view is not None:
2024-12-10 03:28:20 +08:00
if SUBMARINE_VIEW.appear(main=self):
SUBMARINE_VIEW.set('on' if sub_view else 'off', main=self)
else:
logger.warning('Setting up submarine_view but no icon appears')
if sub_hunt is not None:
2024-12-10 03:28:20 +08:00
if SUBMARINE_HUNT.appear(main=self):
SUBMARINE_HUNT.set('on' if sub_hunt else 'off', main=self)
else:
logger.warning('Setting up submarine_hunt but no icon appears')
def handle_strategy(self, index):
"""
Args:
index (int): Fleet index.
Returns:
bool: If changed.
"""
if self.__getattribute__(f'fleet_{index}_formation_fixed'):
return False
expected_formation = self.config.__getattribute__(f'Fleet_Fleet{index}Formation')
if self._strategy_get_from_map_buff() == expected_formation and not self.config.Submarine_Fleet:
logger.info('Skip strategy bar check.')
self.__setattr__(f'fleet_{index}_formation_fixed', True)
return False
self.strategy_open()
self.strategy_set_execute(
2024-12-10 03:28:20 +08:00
formation=expected_formation,
sub_view=False,
sub_hunt=bool(self.config.Submarine_Fleet) and self.config.Submarine_Mode in ['hunt_only', 'hunt_and_boss']
)
self.strategy_close()
self.__setattr__(f'fleet_{index}_formation_fixed', True)
return True
def _strategy_get_from_map_buff(self):
"""
Returns:
int: Formation index.
"""
image = self.image_crop(MAP_BUFF, copy=False)
if TEMPLATE_FORMATION_2.match(image):
buff = 'double_line'
elif TEMPLATE_FORMATION_1.match(image):
buff = 'line_ahead'
elif TEMPLATE_FORMATION_3.match(image):
buff = 'diamond'
else:
buff = 'unknown'
logger.attr('Map_buff', buff)
return buff
2022-01-08 17:00:12 +08:00
def is_in_strategy_submarine_move(self):
"""
Returns:
bool:
"""
return self.appear(SUBMARINE_MOVE_CONFIRM, offset=(20, 20))
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
def strategy_submarine_move_enter(self, skip_first_screenshot=True):
2022-01-08 17:00:12 +08:00
"""
Pages:
in: STRATEGY_OPENED, SUBMARINE_MOVE_ENTER
out: SUBMARINE_MOVE_CONFIRM
"""
logger.info('Submarine move enter')
while 1:
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if self.appear(SUBMARINE_MOVE_ENTER, offset=200, interval=5):
2022-01-08 17:00:12 +08:00
self.device.click(SUBMARINE_MOVE_ENTER)
if self.appear(SUBMARINE_MOVE_CONFIRM, offset=(20, 20)):
break
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
def strategy_submarine_move_confirm(self, skip_first_screenshot=True):
2022-01-08 17:00:12 +08:00
"""
Pages:
in: SUBMARINE_MOVE_CONFIRM
out: STRATEGY_OPENED, SUBMARINE_MOVE_ENTER
"""
logger.info('Submarine move confirm')
while 1:
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
2022-01-08 17:00:12 +08:00
if self.appear_then_click(SUBMARINE_MOVE_CONFIRM, offset=(20, 20), interval=5):
pass
if self.handle_popup_confirm('SUBMARINE_MOVE'):
pass
if self.appear(SUBMARINE_MOVE_ENTER, offset=200):
2022-01-08 17:00:12 +08:00
break
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
def strategy_submarine_move_cancel(self, skip_first_screenshot=True):
2022-01-08 17:00:12 +08:00
"""
Pages:
in: SUBMARINE_MOVE_CONFIRM
out: STRATEGY_OPENED, SUBMARINE_MOVE_ENTER
"""
logger.info('Submarine move cancel')
while 1:
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
2022-01-08 17:00:12 +08:00
if self.appear_then_click(SUBMARINE_MOVE_CANCEL, offset=(20, 20), interval=5):
pass
if self.handle_popup_confirm('SUBMARINE_MOVE'):
pass
if self.appear(SUBMARINE_MOVE_ENTER, offset=200):
2022-01-08 17:00:12 +08:00
break
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
def is_in_strategy_mob_move(self):
"""
Returns:
bool:
"""
return self.appear(MOB_MOVE_CANCEL, offset=(20, 20))
2024-05-20 23:30:47 +08:00
def strategy_has_mob_move(self):
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
"""
Pages:
in: STRATEGY_OPENED
out: STRATEGY_OPENED
"""
if self.match_template_color(MOB_MOVE_ENTER, offset=MOB_MOVE_OFFSET):
2024-05-20 23:30:47 +08:00
return True
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
else:
2024-05-20 23:30:47 +08:00
return False
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
def strategy_mob_move_enter(self, skip_first_screenshot=True):
"""
Pages:
2024-05-20 23:30:47 +08:00
in: STRATEGY_OPENED, MOB_MOVE_ENTER
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
out: MOB_MOVE_CANCEL
"""
logger.info('Mob move enter')
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if self.appear(MOB_MOVE_CANCEL, offset=(20, 20)):
break
2024-05-20 23:30:47 +08:00
if self.appear_then_click(MOB_MOVE_ENTER, offset=MOB_MOVE_OFFSET, interval=5):
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
continue
def strategy_mob_move_cancel(self, skip_first_screenshot=True):
"""
Pages:
in: MOB_MOVE_CANCEL
2024-05-20 23:30:47 +08:00
out: STRATEGY_OPENED, MOB_MOVE_ENTER
Add: 15图开荒/周回 (#3563) * Add: W15 maps extracted * Add: template for Special Carrier in W15 * Add: method mob_move * Fix: MapDetectionError in strategy mob move * Fix: adjacent grid judge condition * Fix: should focus on location before moving * Fix: should update view before further operation * Fix: wait for STRATEGY_OPENED after executing mob move * Fix: offset for assets in _mob_move() * Opt: judge if movable before moving camera * Add: W15 mechanism * Opt: Rename Special Carrier asset name * Fix: offset for MOB_MOVE_1/MOB_MOVE_2 * Fix: separate MOB_MOVE_1 and MOB_MOVE_2 * Fix: should use appear_then_click in strategy_mob_move_enter * Fix: function import in campaign_15_base.py * Fix: missing assets import * Fix: missing offset in strategy_mob_move_cancel() * Fix: should move only once in a campaign * Temp: modify special carrier filter string to 3E * Fix: missing self. before 'moved' variable * Revert "Fix: missing self. before 'moved' variable" This reverts commit 00f70e0ab55e422898cb90c5d5e54d4e7c989511. * Revert "Fix: should move only once in a campaign" This reverts commit b588f5bb07dfc4511f39fa0797fbe160f356d604. * Fix: force goto special carrier * Fix: missing return True in battle function * Fix: enlarge offset of MOB_MOVE_ICON * Fix: typo in campaing_15_3 * Fix: update view after moving mob * Fix: should use full_scan_movable since mob moved * Fix: missing map_data_init() in campaign_15_4.py * Fix: battle 4 should be done by mob fleet * Revert "Fix: battle 4 should be done by mob fleet" This reverts commit 0e2af1ec817b7bc89fe123f03a33ea9ad955973f. * Fix: should switch to fleet_1 after battle_3 * Add: battle function when using clear mode * Fix: missing import * Fix: colliding Config class * Fix: Config.when should contain all cases * Opt: pick ammo after third battle in clear mode of 15-4 * Del: old assets CarrierSpecial * Fix: remake of CarrierSpecial template * Add: UI mask for W15 * Fix: missing ASSETS import * Fix: change full_scan_movable() to predict() * Fix: predict should be done after each move * Opt: camera_data in W15 * Del: remove predict * Add: map info process after mob move * Add: support for multi bosses in _expected_end() for W15 * Opt: show map after moving * Del: remove redundant import in fleet.py * Opt: using clear_chosen_enemy() instead of goto() directly * Fix: should first take screenshot before strategy enter/confirm/cancel * Add: asset TEMPLATE_SIREN_BOSS * Opt: Handle first stages of BOSS as Siren in 15-3/15-4 * Fix: missing override map_data * Add: ignore is_boss prediction for siren boss in 15-3/15-4 * Fix: should not use decorator Config with battle_x functions * Opt: camera data in 15-4 * Opt: directly overwrite map info into original map_data * Fix: missing indent block in campaign_15_4.py * Fix: expect 15-3/15-4 first bosses as siren * Revert "Add: ignore is_boss prediction for siren boss in 15-3/15-4" This reverts commit 1104631f92e5df0672dce8c7acaa1eb122731746. * Revert "Add: asset TEMPLATE_SIREN_BOSS" This reverts commit a29d6b6b9bfb9d79963adb404ce2091cbfafb810. * Revert "Add: support for multi bosses in _expected_end() for W15" This reverts commit 8d357abe5bab79a643e23e8513cefa87d31cb3e8. * Del: redundent map config * Fix: recover boss grids * Del: redundant clear_siren() * Del: redundant clear_siren() in battle_6 * Add: template for mob move icon * Opt: enlarge reinforcement fleet mask area for W15 * Opt: method _mob_move * Upd: TEMPLATE_MOB_MOVE_ICON * Fix: should have cool time between clicks of grid * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit b3f2dcbc88dbe166470905f33d041b91c2192f57. * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: TEMPLATE_MOB_MOVE_ICON * Upd: predict_mob_move_icon * Fix: 15-2 camera spawn point * Fix: should update view using self.device.image * Revert "Upd: TEMPLATE_MOB_MOVE_ICON" This reverts commit 92a12596a8f271ec64e249ecb58779d9b64ecea6. * Del: redundant assets MOB_MOVE_ICON.png * Fix: using map_is_clear_mode to get real value of clear mode * Opt: check mob_movable before moving * Opt: Refactor _mob_move * Fix: camera_sight in W15 * Opt: move sight to further point in _mob_move
2024-04-19 01:29:17 +08:00
"""
logger.info('Mob move cancel')
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
2024-05-20 23:30:47 +08:00
if self.appear(MOB_MOVE_ENTER, offset=MOB_MOVE_OFFSET):
break
if self.appear_then_click(MOB_MOVE_CANCEL, offset=(20, 20), interval=5):
continue