Add: 增加行走步长设置

- 修复跨天重启重置队伍的问题
- 修复碰磁BOSS战斗结束卡住的问题
This commit is contained in:
LmeSzinc 2020-04-23 01:58:35 +08:00
parent 9153ee1ee0
commit b4054b579e
11 changed files with 74 additions and 18 deletions

View File

@ -13,10 +13,13 @@ enable_fleet_control = yes
enable_map_fleet_lock = yes
fleet_index_1 = 1
fleet_formation_1 = formation_2
fleet_step_1 = 3
fleet_index_2 = 2
fleet_formation_2 = formation_2
fleet_step_2 = 2
fleet_index_3 = 1
fleet_formation_3 = formation_2
fleet_step_3 = 3
combat_auto_mode = combat_auto
fleet_index_4 = do_not_use
submarine_mode = do_not_use

View File

@ -117,6 +117,7 @@ class CampaignRun(CampaignUI, Reward, LoginHandler):
if datetime.now().date() != start_date:
start_date.replace(day=datetime.now().day)
self.app_restart()
self.campaign.fleet_checked_reset()
if self.handle_reward():
self.campaign.fleet_checked_reset()

View File

@ -301,11 +301,11 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem
# End
if expected_end is None:
if self.handle_in_stage() or self.handle_in_map_with_enemy_searching():
if self.handle_in_map_with_enemy_searching():
break
if isinstance(expected_end, str):
if expected_end == 'in_stage' and self.handle_in_stage():
raise CampaignEnd('Boss clear')
break
if expected_end == 'with_searching' and self.handle_in_map_with_enemy_searching():
break
if expected_end == 'no_searching' and self.handle_in_map():

View File

@ -92,21 +92,24 @@ def main(ini_name=''):
stop.add_argument('--如果船舱已满', default=default('--如果船舱已满'), choices=['', ''])
# 出击舰队
fleet = setting_parser.add_argument_group('出击舰队', '暂不支持阵型选择, 暂不支持备用道中队')
fleet = setting_parser.add_argument_group('出击舰队', '暂不支持备用道中队, 非活动图或周回模式会忽略步长设置')
fleet.add_argument('--启用舰队控制', default=default('--启用舰队控制'), choices=['', ''])
fleet.add_argument('--启用阵容锁定', default=default('--启用阵容锁定'), choices=['', ''])
f1 = fleet.add_argument_group('道中队')
f1.add_argument('--舰队编号1', default=default('--舰队编号1'), choices=['1', '2', '3', '4', '5', '6'])
f1.add_argument('--舰队阵型1', default=default('--舰队阵型1'), choices=['单纵阵', '复纵阵', '轮形阵'])
f1.add_argument('--舰队步长1', default=default('--舰队步长1'), choices=['1', '2', '3', '4', '5', '6'])
f2 = fleet.add_argument_group('BOSS队')
f2.add_argument('--舰队编号2', default=default('--舰队编号2'), choices=['不使用', '1', '2', '3', '4', '5', '6'])
f2.add_argument('--舰队阵型2', default=default('--舰队阵型2'), choices=['单纵阵', '复纵阵', '轮形阵'])
f2.add_argument('--舰队步长2', default=default('--舰队步长2'), choices=['1', '2', '3', '4', '5', '6'])
f3 = fleet.add_argument_group('备用道中队')
f3.add_argument('--舰队编号3', default=default('--舰队编号3'), choices=['不使用', '1', '2', '3', '4', '5', '6'])
f3.add_argument('--舰队阵型3', default=default('--舰队阵型3'), choices=['单纵阵', '复纵阵', '轮形阵'])
f3.add_argument('--舰队步长3', default=default('--舰队步长3'), choices=['1', '2', '3', '4', '5', '6'])
f4 = fleet.add_argument_group('自律模式')
f4.add_argument('--战斗自律模式', default=default('--战斗自律模式'), choices=['自律', '手操', '中路站桩'])

View File

@ -32,6 +32,10 @@ class AzurLaneConfig:
_FLEET_1_FORMATION = 2
FLEET_2_FORMATION = 2
FLEET_3_FORMATION = 2
# Fleet step 1-6
_FLEET_1_STEP = 3
FLEET_2_STEP = 2
FLEET_3_STEP = 3
# Fleet 1-2, if empty use 0.
SUBMARINE = 0
@ -53,6 +57,14 @@ class AzurLaneConfig:
def FLEET_1_FORMATION(self, value):
self._FLEET_1_FORMATION = value
@property
def FLEET_1_STEP(self):
return self.FLEET_3_STEP if self.USING_SPARE_FLEET else self._FLEET_1_STEP
@FLEET_1_STEP.setter
def FLEET_1_STEP(self, value):
self._FLEET_1_STEP = value
"""
module.assets
"""
@ -182,6 +194,7 @@ class AzurLaneConfig:
module.map.fleet
"""
MAP_HAS_AMBUSH = True
MAP_HAS_FLEET_STEP = False
MAP_MYSTERY_HAS_CARRIER = False
POOR_MAP_DATA = False
FLEET_BOSS = 2
@ -366,6 +379,7 @@ class AzurLaneConfig:
for n in ['1', '2', '3']:
self.__setattr__(f'FLEET_{n}', int(option[f'fleet_index_{n}']))
self.__setattr__(f'FLEET_{n}_FORMATION', int(option[f'fleet_formation_{n}'].split('_')[1]))
self.__setattr__(f'FLEET_{n}_STEP', int(option[f'fleet_step_{n}']))
self.COMBAT_AUTO_MODE = option['combat_auto_mode']
self.SUBMARINE = int(option['fleet_index_4']) if to_bool(option['fleet_index_4']) else 0
self.SUBMARINE_MODE = option['submarine_mode']

View File

@ -47,10 +47,13 @@ dic_chi_to_eng = {
'启用阵容锁定': 'enable_map_fleet_lock',
'舰队编号1': 'fleet_index_1',
'舰队阵型1': 'fleet_formation_1',
'舰队步长1': 'fleet_step_1',
'舰队编号2': 'fleet_index_2',
'舰队阵型2': 'fleet_formation_2',
'舰队步长2': 'fleet_step_2',
'舰队编号3': 'fleet_index_3',
'舰队阵型3': 'fleet_formation_3',
'舰队步长3': 'fleet_step_3',
'战斗自律模式': 'combat_auto_mode',
'舰队编号4': 'fleet_index_4',
'潜艇出击方案': 'submarine_mode',

View File

@ -3,6 +3,7 @@ from module.base.utils import red_overlay_transparency, get_color
from module.handler.assets import *
from module.handler.info_bar import InfoBarHandler
from module.logger import logger
from module.map.exception import CampaignEnd
class EnemySearchingHandler(InfoBarHandler):
@ -25,7 +26,7 @@ class EnemySearchingHandler(InfoBarHandler):
logger.info('In stage.')
# self.device.sleep(0.5)
self.ensure_no_info_bar(timeout=0.6)
return True
raise CampaignEnd('In map.')
else:
return False
@ -40,6 +41,8 @@ class EnemySearchingHandler(InfoBarHandler):
appeared = False
while 1:
timeout.start()
if self.handle_in_stage():
return True
if self.enemy_searching_appear():
appeared = True
else:

View File

@ -28,6 +28,8 @@ class FastForwardHandler(ModuleBase):
logger.info('No fast forward mode.')
return False
logger.info('Set fast forward.')
self.config.MAP_HAS_FLEET_STEP = False
if self.config.ENABLE_FAST_FORWARD:
self.config.MAP_HAS_AMBUSH = False
status = 'on'

View File

@ -53,6 +53,15 @@ class Fleet(Camera, MapOperation, AmbushHandler):
else:
return self.fleet_1
@property
def fleet_step(self):
if not self.config.MAP_HAS_FLEET_STEP:
return 0
if self.fleet_current_index == 2:
return self.config.FLEET_2_STEP
else:
return self.config.FLEET_1_STEP
def fleet_switch(self):
self.fleet_switch_click()
self.fleet_current_index = 1 if self.fleet_current_index == 2 else 2
@ -177,7 +186,7 @@ class Fleet(Camera, MapOperation, AmbushHandler):
# self.device.sleep(1000)
location = location_ensure(location)
if self.config.MAP_HAS_AMBUSH and optimize:
nodes = self.map.find_path(location)
nodes = self.map.find_path(location, step=self.fleet_step)
for node in nodes:
self._goto(node, expected=expected if node == nodes[-1] else '')
else:
@ -284,7 +293,8 @@ class Fleet(Camera, MapOperation, AmbushHandler):
if 'boss' in expected:
return 'in_stage'
return 'no_searching'
return None
def fleet_at(self, grid, fleet=None):
"""

View File

@ -258,7 +258,7 @@ class Map(Fleet):
logger.hr('Clear BOSS')
grids = grids.sort(cost=True, weight=True)
logger.info('Grid: %s' % str(grid))
self.clear_chosen_enemy(grid, expected='boss')
self.clear_chosen_enemy(grid)
logger.info('Boss guessing incorrect.')
def brute_clear_boss(self):

View File

@ -265,11 +265,12 @@ class CampaignMap:
return res
def _find_route_node(self, route):
def _find_route_node(self, route, step=0):
"""
Args:
route (list[tuple]): list of grids.
step (int): Fleet step in event map. Default to 0.
Returns:
list[tuple]: list of walking node.
@ -283,19 +284,35 @@ class CampaignMap:
turning = np.diff(diff, axis=0)[:, 0]
indexes = np.where(turning == -1)[0] + 1
for index in indexes:
grid = route[index]
if not self[grid].is_fleet:
res.append(grid)
if not self[route[index]].is_fleet:
res.append(index)
else:
if (index > 1) and (index + 1 not in indexes):
res.append(route[index - 1])
if (index > 1) and (index - 1 not in indexes):
res.append(index - 1)
if (index < len(route) - 2) and (index + 1 not in indexes):
res.append(route[index + 1])
res.append(route[-1])
res.append(index + 1)
res.append(len(route) - 1)
# res = [6, 8]
if step == 0:
return [route[index] for index in res]
return res
res.insert(0, 0)
inserted = []
for left, right in zip(res[:-1], res[1:]):
for index in list(range(left, right, step))[1:]:
if not self[route[index]].is_fleet:
inserted.append(index)
else:
if (index > 1) and (index - 1 not in res):
inserted.append(index - 1)
if (index < len(route) - 2) and (index + 1 not in res):
inserted.append(index + 1)
inserted.append(right)
res = inserted
# res = [3, 6, 8]
return [route[index] for index in res]
def find_path(self, location):
def find_path(self, location, step=0):
location = location_ensure(location)
path = self._find_path(location)
@ -304,7 +321,7 @@ class CampaignMap:
return [location]
logger.info('Path: %s' % '[' + ', ' .join([location2node(grid) for grid in path]) + ']')
path = self._find_route_node(path)
path = self._find_route_node(path, step=step)
logger.info('Path: %s' % '[' + ', ' .join([location2node(grid) for grid in path]) + ']')
return path