1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-22 07:03:43 +08:00

Merge pull request #1996 from LmeSzinc/bug_fix

Bug fix
This commit is contained in:
LmeSzinc
2022-12-12 23:06:05 +08:00
committed by GitHub
6 changed files with 30 additions and 18 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -12,7 +12,7 @@ EQUIPPING_ON = Button(area={'cn': (26, 485, 60, 510), 'en': (32, 563, 54, 583),
EQUIP_1 = Button(area={'cn': (1191, 266, 1247, 319), 'en': (1200, 273, 1241, 314), 'jp': (1191, 265, 1248, 320), 'tw': (1190, 265, 1249, 319)}, color={'cn': (98, 142, 207), 'en': (77, 130, 192), 'jp': (97, 142, 206), 'tw': (102, 147, 211)}, button={'cn': (1191, 266, 1247, 319), 'en': (1200, 273, 1241, 314), 'jp': (1191, 265, 1248, 320), 'tw': (1190, 265, 1249, 319)}, file={'cn': './assets/cn/equipment/EQUIP_1.png', 'en': './assets/en/equipment/EQUIP_1.png', 'jp': './assets/jp/equipment/EQUIP_1.png', 'tw': './assets/tw/equipment/EQUIP_1.png'}) EQUIP_1 = Button(area={'cn': (1191, 266, 1247, 319), 'en': (1200, 273, 1241, 314), 'jp': (1191, 265, 1248, 320), 'tw': (1190, 265, 1249, 319)}, color={'cn': (98, 142, 207), 'en': (77, 130, 192), 'jp': (97, 142, 206), 'tw': (102, 147, 211)}, button={'cn': (1191, 266, 1247, 319), 'en': (1200, 273, 1241, 314), 'jp': (1191, 265, 1248, 320), 'tw': (1190, 265, 1249, 319)}, file={'cn': './assets/cn/equipment/EQUIP_1.png', 'en': './assets/en/equipment/EQUIP_1.png', 'jp': './assets/jp/equipment/EQUIP_1.png', 'tw': './assets/tw/equipment/EQUIP_1.png'})
EQUIP_2 = Button(area={'cn': (1191, 366, 1247, 419), 'en': (1200, 374, 1241, 415), 'jp': (1191, 365, 1248, 420), 'tw': (1190, 365, 1249, 419)}, color={'cn': (95, 139, 202), 'en': (77, 130, 192), 'jp': (94, 138, 201), 'tw': (100, 144, 208)}, button={'cn': (1191, 366, 1247, 419), 'en': (1200, 374, 1241, 415), 'jp': (1191, 365, 1248, 420), 'tw': (1190, 365, 1249, 419)}, file={'cn': './assets/cn/equipment/EQUIP_2.png', 'en': './assets/en/equipment/EQUIP_2.png', 'jp': './assets/jp/equipment/EQUIP_2.png', 'tw': './assets/tw/equipment/EQUIP_2.png'}) EQUIP_2 = Button(area={'cn': (1191, 366, 1247, 419), 'en': (1200, 374, 1241, 415), 'jp': (1191, 365, 1248, 420), 'tw': (1190, 365, 1249, 419)}, color={'cn': (95, 139, 202), 'en': (77, 130, 192), 'jp': (94, 138, 201), 'tw': (100, 144, 208)}, button={'cn': (1191, 366, 1247, 419), 'en': (1200, 374, 1241, 415), 'jp': (1191, 365, 1248, 420), 'tw': (1190, 365, 1249, 419)}, file={'cn': './assets/cn/equipment/EQUIP_2.png', 'en': './assets/en/equipment/EQUIP_2.png', 'jp': './assets/jp/equipment/EQUIP_2.png', 'tw': './assets/tw/equipment/EQUIP_2.png'})
EQUIP_3 = Button(area={'cn': (1191, 466, 1247, 519), 'en': (1200, 475, 1241, 516), 'jp': (1190, 467, 1249, 520), 'tw': (1190, 466, 1249, 520)}, color={'cn': (94, 137, 201), 'en': (80, 132, 192), 'jp': (89, 134, 197), 'tw': (97, 142, 205)}, button={'cn': (1191, 466, 1247, 519), 'en': (1200, 475, 1241, 516), 'jp': (1190, 467, 1249, 520), 'tw': (1190, 466, 1249, 520)}, file={'cn': './assets/cn/equipment/EQUIP_3.png', 'en': './assets/en/equipment/EQUIP_3.png', 'jp': './assets/jp/equipment/EQUIP_3.png', 'tw': './assets/tw/equipment/EQUIP_3.png'}) EQUIP_3 = Button(area={'cn': (1191, 466, 1247, 519), 'en': (1200, 475, 1241, 516), 'jp': (1190, 467, 1249, 520), 'tw': (1190, 466, 1249, 520)}, color={'cn': (94, 137, 201), 'en': (80, 132, 192), 'jp': (89, 134, 197), 'tw': (97, 142, 205)}, button={'cn': (1191, 466, 1247, 519), 'en': (1200, 475, 1241, 516), 'jp': (1190, 467, 1249, 520), 'tw': (1190, 466, 1249, 520)}, file={'cn': './assets/cn/equipment/EQUIP_3.png', 'en': './assets/en/equipment/EQUIP_3.png', 'jp': './assets/jp/equipment/EQUIP_3.png', 'tw': './assets/tw/equipment/EQUIP_3.png'})
EQUIP_CONFIRM = Button(area={'cn': (792, 623, 959, 677), 'en': (795, 623, 960, 677), 'jp': (792, 623, 960, 674), 'tw': (792, 623, 960, 677)}, color={'cn': (222, 154, 59), 'en': (226, 160, 69), 'jp': (222, 152, 55), 'tw': (223, 153, 57)}, button={'cn': (792, 623, 959, 677), 'en': (795, 623, 960, 677), 'jp': (792, 623, 960, 674), 'tw': (792, 623, 960, 677)}, file={'cn': './assets/cn/equipment/EQUIP_CONFIRM.png', 'en': './assets/en/equipment/EQUIP_CONFIRM.png', 'jp': './assets/jp/equipment/EQUIP_CONFIRM.png', 'tw': './assets/tw/equipment/EQUIP_CONFIRM.png'}) EQUIP_CONFIRM = Button(area={'cn': (792, 623, 959, 677), 'en': (809, 633, 940, 658), 'jp': (792, 623, 960, 674), 'tw': (792, 623, 960, 677)}, color={'cn': (222, 154, 59), 'en': (236, 192, 133), 'jp': (222, 152, 55), 'tw': (223, 153, 57)}, button={'cn': (792, 623, 959, 677), 'en': (793, 620, 961, 673), 'jp': (792, 623, 960, 674), 'tw': (792, 623, 960, 677)}, file={'cn': './assets/cn/equipment/EQUIP_CONFIRM.png', 'en': './assets/en/equipment/EQUIP_CONFIRM.png', 'jp': './assets/jp/equipment/EQUIP_CONFIRM.png', 'tw': './assets/tw/equipment/EQUIP_CONFIRM.png'})
EQUIP_OFF = Button(area={'cn': (907, 565, 1037, 610), 'en': (911, 564, 1034, 607), 'jp': (908, 564, 1039, 612), 'tw': (907, 565, 1037, 611)}, color={'cn': (112, 153, 216), 'en': (91, 142, 212), 'jp': (110, 151, 213), 'tw': (106, 150, 214)}, button={'cn': (907, 565, 1037, 610), 'en': (911, 564, 1034, 607), 'jp': (908, 564, 1039, 612), 'tw': (907, 565, 1037, 611)}, file={'cn': './assets/cn/equipment/EQUIP_OFF.png', 'en': './assets/en/equipment/EQUIP_OFF.png', 'jp': './assets/jp/equipment/EQUIP_OFF.png', 'tw': './assets/tw/equipment/EQUIP_OFF.png'}) EQUIP_OFF = Button(area={'cn': (907, 565, 1037, 610), 'en': (911, 564, 1034, 607), 'jp': (908, 564, 1039, 612), 'tw': (907, 565, 1037, 611)}, color={'cn': (112, 153, 216), 'en': (91, 142, 212), 'jp': (110, 151, 213), 'tw': (106, 150, 214)}, button={'cn': (907, 565, 1037, 610), 'en': (911, 564, 1034, 607), 'jp': (908, 564, 1039, 612), 'tw': (907, 565, 1037, 611)}, file={'cn': './assets/cn/equipment/EQUIP_OFF.png', 'en': './assets/en/equipment/EQUIP_OFF.png', 'jp': './assets/jp/equipment/EQUIP_OFF.png', 'tw': './assets/tw/equipment/EQUIP_OFF.png'})
EQUIP_SAVE = Button(area={'cn': (355, 312, 452, 433), 'en': (355, 312, 452, 433), 'jp': (407, 312, 476, 404), 'tw': (355, 312, 452, 433)}, color={'cn': (170, 156, 122), 'en': (170, 156, 122), 'jp': (119, 94, 128), 'tw': (170, 156, 122)}, button={'cn': (355, 312, 452, 433), 'en': (355, 312, 452, 433), 'jp': (407, 312, 476, 404), 'tw': (355, 312, 452, 433)}, file={'cn': './assets/cn/equipment/EQUIP_SAVE.png', 'en': './assets/en/equipment/EQUIP_SAVE.png', 'jp': './assets/jp/equipment/EQUIP_SAVE.png', 'tw': './assets/tw/equipment/EQUIP_SAVE.png'}) EQUIP_SAVE = Button(area={'cn': (355, 312, 452, 433), 'en': (355, 312, 452, 433), 'jp': (407, 312, 476, 404), 'tw': (355, 312, 452, 433)}, color={'cn': (170, 156, 122), 'en': (170, 156, 122), 'jp': (119, 94, 128), 'tw': (170, 156, 122)}, button={'cn': (355, 312, 452, 433), 'en': (355, 312, 452, 433), 'jp': (407, 312, 476, 404), 'tw': (355, 312, 452, 433)}, file={'cn': './assets/cn/equipment/EQUIP_SAVE.png', 'en': './assets/en/equipment/EQUIP_SAVE.png', 'jp': './assets/jp/equipment/EQUIP_SAVE.png', 'tw': './assets/tw/equipment/EQUIP_SAVE.png'})
EQUIP_SCROLL = Button(area={'cn': (1254, 86, 1266, 588), 'en': (1254, 86, 1266, 588), 'jp': (1254, 86, 1266, 588), 'tw': (1254, 86, 1266, 588)}, color={'cn': (141, 130, 77), 'en': (141, 130, 77), 'jp': (141, 130, 77), 'tw': (141, 130, 77)}, button={'cn': (1254, 86, 1266, 588), 'en': (1254, 86, 1266, 588), 'jp': (1254, 86, 1266, 588), 'tw': (1254, 86, 1266, 588)}, file={'cn': './assets/cn/equipment/EQUIP_SCROLL.png', 'en': './assets/en/equipment/EQUIP_SCROLL.png', 'jp': './assets/jp/equipment/EQUIP_SCROLL.png', 'tw': './assets/tw/equipment/EQUIP_SCROLL.png'}) EQUIP_SCROLL = Button(area={'cn': (1254, 86, 1266, 588), 'en': (1254, 86, 1266, 588), 'jp': (1254, 86, 1266, 588), 'tw': (1254, 86, 1266, 588)}, color={'cn': (141, 130, 77), 'en': (141, 130, 77), 'jp': (141, 130, 77), 'tw': (141, 130, 77)}, button={'cn': (1254, 86, 1266, 588), 'en': (1254, 86, 1266, 588), 'jp': (1254, 86, 1266, 588), 'tw': (1254, 86, 1266, 588)}, file={'cn': './assets/cn/equipment/EQUIP_SCROLL.png', 'en': './assets/en/equipment/EQUIP_SCROLL.png', 'jp': './assets/jp/equipment/EQUIP_SCROLL.png', 'tw': './assets/tw/equipment/EQUIP_SCROLL.png'})

View File

@@ -376,10 +376,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
logger.info('Just less than 1 day to OpSi reset, ' logger.info('Just less than 1 day to OpSi reset, '
'set ActionPointPreserve to 0 temporarily') 'set ActionPointPreserve to 0 temporarily')
return 0 return 0
elif self.config.cross_get( elif self.is_cl1_enabled and remain <= 2:
keys='OpsiHazard1Leveling.Scheduler.Enable',
default=False
) and remain <= 2:
logger.info('Just less than 3 days to OpSi reset, ' logger.info('Just less than 3 days to OpSi reset, '
'set ActionPointPreserve to 500 temporarily for hazard 1 leveling') 'set ActionPointPreserve to 500 temporarily for hazard 1 leveling')
return 500 return 500
@@ -403,6 +400,10 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
def is_in_task_explore(self): def is_in_task_explore(self):
return self.config.task.command == 'OpsiExplore' return self.config.task.command == 'OpsiExplore'
@property
def is_cl1_enabled(self):
return self.config.cross_get('OpsiHazard1Leveling.Scheduler.Enable', default=False)
_auto_search_battle_count = 0 _auto_search_battle_count = 0
_auto_search_round_timer = 0 _auto_search_round_timer = 0
@@ -505,9 +506,7 @@ class OSMap(OSFleet, Map, GlobeCamera, StrategicSearchHandler):
if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5): if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5):
continue continue
if self.appear(AUTO_SEARCH_OS_MAP_OPTION_OFF, offset=(5, 120), interval=3) \ if self.appear_then_click(GOTO_MAIN, offset=(20, 20), interval=3):
and AUTO_SEARCH_OS_MAP_OPTION_OFF.match_appear_on(self.device.image):
self.device.click(GOTO_MAIN)
continue continue
if self.ui_additional(): if self.ui_additional():
continue continue

View File

@@ -295,7 +295,11 @@ class OperationSiren(OSMap):
logger.attr('OS_ACTION_POINT_PRESERVE', self.config.OS_ACTION_POINT_PRESERVE) logger.attr('OS_ACTION_POINT_PRESERVE', self.config.OS_ACTION_POINT_PRESERVE)
if not ap_checked: if not ap_checked:
# Check action points first to avoid using remaining AP when it not enough for tomorrow's daily # Check action points first to avoid using remaining AP when it not enough for tomorrow's daily
self.set_action_point(cost=0) # When not running CL1, use oil
keep_current_ap = True
if not self.is_cl1_enabled and self.config.OpsiGeneral_BuyActionPointLimit > 0:
keep_current_ap = False
self.set_action_point(cost=0, keep_current_ap=keep_current_ap)
ap_checked = True ap_checked = True
# (1252, 1012) is the coordinate of zone 134 (the center zone) in os_globe_map.png # (1252, 1012) is the coordinate of zone 134 (the center zone) in os_globe_map.png
@@ -366,7 +370,11 @@ class OperationSiren(OSMap):
self.get_current_zone() self.get_current_zone()
# Preset action point to 100 # Preset action point to 100
self.set_action_point(cost=100) # When running CL1 oil is for running CL1, not CL5
keep_current_ap = True
if self.config.OpsiGeneral_BuyActionPointLimit > 0:
keep_current_ap = False
self.set_action_point(cost=100, keep_current_ap=keep_current_ap)
if self.config.OpsiHazard1Leveling_TargetZone != 0: if self.config.OpsiHazard1Leveling_TargetZone != 0:
zone = self.config.OpsiHazard1Leveling_TargetZone zone = self.config.OpsiHazard1Leveling_TargetZone
else: else:
@@ -527,7 +535,7 @@ class OperationSiren(OSMap):
logger.info('Just less than 1 day to OpSi reset, delay 2.5 hours') logger.info('Just less than 1 day to OpSi reset, delay 2.5 hours')
self.config.task_delay(minute=150, server_update=True) self.config.task_delay(minute=150, server_update=True)
self.config.task_stop() self.config.task_stop()
elif self.config.cross_get('OpsiHazard1Leveling.Scheduler.Enable', default=False) or not result: elif self.is_cl1_enabled or not result:
self.config.task_delay(server_update=True) self.config.task_delay(server_update=True)
self.config.task_stop() self.config.task_stop()

View File

@@ -234,12 +234,14 @@ class ActionPointHandler(UI):
""" """
self.ui_click(ACTION_POINT_CANCEL, check_button=OS_CHECK, skip_first_screenshot=skip_first_screenshot) self.ui_click(ACTION_POINT_CANCEL, check_button=OS_CHECK, skip_first_screenshot=skip_first_screenshot)
def handle_action_point(self, zone, pinned, cost=None): def handle_action_point(self, zone, pinned, cost=None, keep_current_ap=True):
""" """
Args: Args:
zone (Zone): Zone to enter. zone (Zone): Zone to enter.
pinned (str): Zone type. Available types: DANGEROUS, SAFE, OBSCURE, ABYSSAL, STRONGHOLD. pinned (str): Zone type. Available types: DANGEROUS, SAFE, OBSCURE, ABYSSAL, STRONGHOLD.
cost (int): Custom action point cost value. cost (int): Custom action point cost value.
keep_current_ap (bool): Check action points first to avoid using remaining AP
when it not enough for tomorrow's daily
Returns: Returns:
bool: If handled. bool: If handled.
@@ -258,10 +260,11 @@ class ActionPointHandler(UI):
if cost is None: if cost is None:
cost = self.action_point_get_cost(zone, pinned) cost = self.action_point_get_cost(zone, pinned)
buy_checked = False buy_checked = False
if self._action_point_total <= self.config.OS_ACTION_POINT_PRESERVE: if keep_current_ap:
logger.info(f'Reach the limit of action points, preserve={self.config.OS_ACTION_POINT_PRESERVE}') if self._action_point_total <= self.config.OS_ACTION_POINT_PRESERVE:
self.action_point_quit() logger.info(f'Reach the limit of action points, preserve={self.config.OS_ACTION_POINT_PRESERVE}')
raise ActionPointLimit self.action_point_quit()
raise ActionPointLimit
for _ in range(12): for _ in range(12):
# Having enough action points # Having enough action points
@@ -304,18 +307,20 @@ class ActionPointHandler(UI):
logger.warning('Failed to get action points after 12 trial') logger.warning('Failed to get action points after 12 trial')
return False return False
def set_action_point(self, zone=None, pinned=None, cost=None): def set_action_point(self, zone=None, pinned=None, cost=None, keep_current_ap=True):
""" """
Args: Args:
zone (Zone): Zone to enter. zone (Zone): Zone to enter.
pinned (str): Zone type. Available types: DANGEROUS, SAFE, OBSCURE, ABYSSAL, STRONGHOLD. pinned (str): Zone type. Available types: DANGEROUS, SAFE, OBSCURE, ABYSSAL, STRONGHOLD.
cost (int): Custom action point cost value. cost (int): Custom action point cost value.
keep_current_ap (bool): Check action points first to avoid using remaining AP
when it not enough for tomorrow's daily
Returns: Returns:
bool: If handled. bool: If handled.
""" """
self.ui_click(ACTION_POINT_REMAIN_OS, ACTION_POINT_USE, OS_CHECK) self.ui_click(ACTION_POINT_REMAIN_OS, ACTION_POINT_USE, OS_CHECK)
if not self.handle_action_point(zone, pinned, cost): if not self.handle_action_point(zone, pinned, cost, keep_current_ap):
return False return False
while 1: while 1: