Fix: mob move optimization

This commit is contained in:
Air111 2024-05-20 23:30:47 +08:00 committed by LmeSzinc
parent df88ee7c06
commit 1e793295e8
16 changed files with 14 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -80,7 +80,7 @@ class Campaign(CampaignBase):
def battle_0(self):
if not self.map_is_clear_mode and self.map_has_mob_move:
self.mob_move(I6, I7)
self.mob_move(I7, H7)
self.mob_move(I7, I8)
if G7.is_accessible:
self.clear_chosen_enemy(G7)
return True

View File

@ -58,8 +58,7 @@ class CampaignBase(CampaignBase_):
sub_view=sub_view,
sub_hunt=sub_hunt,
)
self.map_has_mob_move = (self.strategy_get_mob_move_remain() > 0)
logger.attr("Map has mob move", self.map_has_mob_move)
logger.attr("Map has mob move", self.strategy_has_mob_move())
def _map_swipe(self, vector, box=(239, 159, 1175, 628)):
# Left border to 239, avoid swiping on support fleet
@ -184,6 +183,7 @@ class CampaignBase(CampaignBase_):
self.map[target].is_boss = self.map[location].is_boss
self.map[location].is_boss = False
self.map[target].is_enemy = True
self.map[target].may_enemy = True
self.map[location].is_enemy = False
def mob_move(self, location, target):
@ -205,8 +205,7 @@ class CampaignBase(CampaignBase_):
return False
self.strategy_open()
remain = self.strategy_get_mob_move_remain()
if remain == 0:
if not self.strategy_has_mob_move():
logger.warning(f'No remain mob move trials, will abandon moving')
self.strategy_close()
return False

View File

@ -67,9 +67,8 @@ MAP_WALK_OUT_OF_STEP = Button(area={'cn': (654, 312, 704, 335), 'en': (454, 314,
MAP_WALK_SPEEDUP = Button(area={'cn': (1025, 406, 1055, 436), 'en': (1025, 406, 1055, 436), 'jp': (1025, 406, 1055, 436), 'tw': (1025, 406, 1055, 436)}, color={'cn': (62, 97, 72), 'en': (62, 97, 72), 'jp': (62, 97, 72), 'tw': (62, 97, 72)}, button={'cn': (1025, 406, 1055, 436), 'en': (1025, 406, 1055, 436), 'jp': (1025, 406, 1055, 436), 'tw': (1025, 406, 1055, 436)}, file={'cn': './assets/cn/handler/MAP_WALK_SPEEDUP.png', 'en': './assets/en/handler/MAP_WALK_SPEEDUP.png', 'jp': './assets/jp/handler/MAP_WALK_SPEEDUP.png', 'tw': './assets/tw/handler/MAP_WALK_SPEEDUP.png'})
MISSION_POPUP_ACK = Button(area={'cn': (432, 493, 543, 533), 'en': (413, 489, 566, 532), 'jp': (410, 482, 574, 539), 'tw': (413, 489, 566, 532)}, color={'cn': (181, 182, 184), 'en': (169, 170, 172), 'jp': (162, 164, 167), 'tw': (169, 170, 172)}, button={'cn': (432, 493, 543, 533), 'en': (413, 489, 566, 532), 'jp': (410, 482, 574, 539), 'tw': (413, 489, 566, 532)}, file={'cn': './assets/cn/handler/MISSION_POPUP_ACK.png', 'en': './assets/en/handler/MISSION_POPUP_ACK.png', 'jp': './assets/jp/handler/MISSION_POPUP_ACK.png', 'tw': './assets/tw/handler/MISSION_POPUP_ACK.png'})
MISSION_POPUP_GO = Button(area={'cn': (719, 493, 861, 534), 'en': (716, 488, 869, 533), 'jp': (711, 482, 874, 539), 'tw': (716, 488, 869, 533)}, color={'cn': (125, 164, 214), 'en': (89, 138, 201), 'jp': (93, 142, 204), 'tw': (89, 138, 201)}, button={'cn': (719, 493, 861, 534), 'en': (716, 488, 869, 533), 'jp': (711, 482, 874, 539), 'tw': (716, 488, 869, 533)}, file={'cn': './assets/cn/handler/MISSION_POPUP_GO.png', 'en': './assets/en/handler/MISSION_POPUP_GO.png', 'jp': './assets/jp/handler/MISSION_POPUP_GO.png', 'tw': './assets/tw/handler/MISSION_POPUP_GO.png'})
MOB_MOVE_1 = Button(area={'cn': (1102, 504, 1176, 578), 'en': (1102, 504, 1176, 578), 'jp': (1102, 504, 1176, 578), 'tw': (1102, 504, 1176, 578)}, color={'cn': (118, 120, 127), 'en': (118, 120, 127), 'jp': (118, 120, 127), 'tw': (118, 120, 127)}, button={'cn': (1102, 504, 1176, 578), 'en': (1102, 504, 1176, 578), 'jp': (1102, 504, 1176, 578), 'tw': (1102, 504, 1176, 578)}, file={'cn': './assets/cn/handler/MOB_MOVE_1.png', 'en': './assets/en/handler/MOB_MOVE_1.png', 'jp': './assets/jp/handler/MOB_MOVE_1.png', 'tw': './assets/tw/handler/MOB_MOVE_1.png'})
MOB_MOVE_2 = Button(area={'cn': (1102, 504, 1176, 578), 'en': (1102, 504, 1176, 578), 'jp': (1102, 504, 1176, 578), 'tw': (1102, 504, 1176, 578)}, color={'cn': (119, 121, 128), 'en': (119, 121, 128), 'jp': (119, 121, 128), 'tw': (119, 121, 128)}, button={'cn': (1102, 504, 1176, 578), 'en': (1102, 504, 1176, 578), 'jp': (1102, 504, 1176, 578), 'tw': (1102, 504, 1176, 578)}, file={'cn': './assets/cn/handler/MOB_MOVE_2.png', 'en': './assets/en/handler/MOB_MOVE_2.png', 'jp': './assets/jp/handler/MOB_MOVE_2.png', 'tw': './assets/tw/handler/MOB_MOVE_2.png'})
MOB_MOVE_CANCEL = Button(area={'cn': (1162, 646, 1220, 674), 'en': (1162, 646, 1220, 674), 'jp': (1162, 644, 1222, 675), 'tw': (1162, 646, 1220, 674)}, color={'cn': (224, 176, 173), 'en': (224, 176, 173), 'jp': (207, 140, 136), 'tw': (224, 176, 173)}, button={'cn': (1162, 646, 1220, 674), 'en': (1162, 646, 1220, 674), 'jp': (1162, 644, 1222, 675), 'tw': (1162, 646, 1220, 674)}, file={'cn': './assets/cn/handler/MOB_MOVE_CANCEL.png', 'en': './assets/cn/handler/MOB_MOVE_CANCEL.png', 'jp': './assets/jp/handler/MOB_MOVE_CANCEL.png', 'tw': './assets/cn/handler/MOB_MOVE_CANCEL.png'})
MOB_MOVE_ENTER = Button(area={'cn': (1102, 504, 1157, 578), 'en': (1102, 504, 1157, 578), 'jp': (1102, 504, 1157, 578), 'tw': (1102, 504, 1157, 578)}, color={'cn': (122, 124, 131), 'en': (122, 124, 131), 'jp': (122, 124, 131), 'tw': (122, 124, 131)}, button={'cn': (1102, 504, 1157, 578), 'en': (1102, 504, 1157, 578), 'jp': (1102, 504, 1157, 578), 'tw': (1102, 504, 1157, 578)}, file={'cn': './assets/cn/handler/MOB_MOVE_ENTER.png', 'en': './assets/en/handler/MOB_MOVE_ENTER.png', 'jp': './assets/jp/handler/MOB_MOVE_ENTER.png', 'tw': './assets/tw/handler/MOB_MOVE_ENTER.png'})
MONTHLY_PASS_NOTICE = Button(area={'cn': (554, 505, 726, 561), 'en': (716, 488, 869, 533), 'jp': (554, 505, 726, 561), 'tw': (554, 505, 726, 561)}, color={'cn': (109, 153, 208), 'en': (89, 138, 201), 'jp': (109, 153, 208), 'tw': (109, 153, 208)}, button={'cn': (872, 152, 939, 196), 'en': (863, 173, 929, 217), 'jp': (872, 152, 939, 196), 'tw': (872, 152, 939, 196)}, file={'cn': './assets/cn/handler/MONTHLY_PASS_NOTICE.png', 'en': './assets/en/handler/MONTHLY_PASS_NOTICE.png', 'jp': './assets/cn/handler/MONTHLY_PASS_NOTICE.png', 'tw': './assets/cn/handler/MONTHLY_PASS_NOTICE.png'})
MYSTERY_ITEM = Button(area={'cn': (589, 294, 691, 427), 'en': (589, 294, 691, 427), 'jp': (589, 294, 691, 427), 'tw': (589, 294, 691, 427)}, color={'cn': (144, 127, 83), 'en': (144, 127, 83), 'jp': (144, 127, 83), 'tw': (144, 127, 83)}, button={'cn': (588, 478, 698, 496), 'en': (588, 478, 698, 496), 'jp': (588, 478, 698, 496), 'tw': (588, 478, 698, 496)}, file={'cn': './assets/cn/handler/MYSTERY_ITEM.png', 'en': './assets/en/handler/MYSTERY_ITEM.png', 'jp': './assets/jp/handler/MYSTERY_ITEM.png', 'tw': './assets/tw/handler/MYSTERY_ITEM.png'})
POPUP_CANCEL = Button(area={'cn': (453, 506, 525, 536), 'en': (407, 485, 574, 535), 'jp': (455, 515, 521, 546), 'tw': (454, 495, 525, 526)}, color={'cn': (196, 198, 199), 'en': (168, 169, 171), 'jp': (181, 183, 184), 'tw': (195, 196, 197)}, button={'cn': (453, 506, 525, 536), 'en': (407, 485, 574, 535), 'jp': (455, 515, 521, 546), 'tw': (454, 495, 525, 526)}, file={'cn': './assets/cn/handler/POPUP_CANCEL.png', 'en': './assets/en/handler/POPUP_CANCEL.gif', 'jp': './assets/jp/handler/POPUP_CANCEL.png', 'tw': './assets/tw/handler/POPUP_CANCEL.png'})

View File

@ -211,23 +211,22 @@ class StrategyHandler(InfoHandler):
"""
return self.appear(MOB_MOVE_CANCEL, offset=(20, 20))
def strategy_get_mob_move_remain(self):
def strategy_has_mob_move(self):
"""
Pages:
in: STRATEGY_OPENED
out: STRATEGY_OPENED
"""
if self.appear(MOB_MOVE_2, offset=MOB_MOVE_OFFSET):
return 2
elif self.appear(MOB_MOVE_1, offset=MOB_MOVE_OFFSET):
return 1
if (self.appear(MOB_MOVE_ENTER, offset=MOB_MOVE_OFFSET)
and MOB_MOVE_ENTER.match_appear_on(self.device.image)):
return True
else:
return 0
return False
def strategy_mob_move_enter(self, skip_first_screenshot=True):
"""
Pages:
in: STRATEGY_OPENED, MOB_MOVE_1 or MOB_MOVE_2
in: STRATEGY_OPENED, MOB_MOVE_ENTER
out: MOB_MOVE_CANCEL
"""
logger.info('Mob move enter')
@ -240,16 +239,14 @@ class StrategyHandler(InfoHandler):
if self.appear(MOB_MOVE_CANCEL, offset=(20, 20)):
break
if self.appear_then_click(MOB_MOVE_1, offset=MOB_MOVE_OFFSET, interval=5):
continue
if self.appear_then_click(MOB_MOVE_2, offset=MOB_MOVE_OFFSET, interval=5):
if self.appear_then_click(MOB_MOVE_ENTER, offset=MOB_MOVE_OFFSET, interval=5):
continue
def strategy_mob_move_cancel(self, skip_first_screenshot=True):
"""
Pages:
in: MOB_MOVE_CANCEL
out: STRATEGY_OPENED, MOB_MOVE_1 or MOB_MOVE_2
out: STRATEGY_OPENED, MOB_MOVE_ENTER
"""
logger.info('Mob move cancel')
while 1:
@ -258,8 +255,7 @@ class StrategyHandler(InfoHandler):
else:
self.device.screenshot()
if self.appear(MOB_MOVE_1, offset=MOB_MOVE_OFFSET) \
or self.appear(MOB_MOVE_2, offset=MOB_MOVE_OFFSET):
if self.appear(MOB_MOVE_ENTER, offset=MOB_MOVE_OFFSET):
break
if self.appear_then_click(MOB_MOVE_CANCEL, offset=(20, 20), interval=5):