mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 18:20:42 +00:00
Add: 适配了第六章
- 修复了两队进图, 只检测到一队时报错的问题 - 修复了碰磁boss刷新点报错的问题 - 修复了踩到弹药时, 下一次走路会超时的问题 - 调整了一些log
This commit is contained in:
parent
a674198365
commit
0663ee3d63
76
campaign/campaign_main/campaign_6_1.py
Normal file
76
campaign/campaign_main/campaign_6_1.py
Normal file
@ -0,0 +1,76 @@
|
||||
from module.campaign.campaign_base import CampaignBase
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.map.map_grids import SelectedGrids, RoadGrids
|
||||
from module.logger import logger
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'H5'
|
||||
MAP.map_data = '''
|
||||
ME MB SP ME -- -- ME MM
|
||||
-- ME -- ME -- ME SP ME
|
||||
SP -- ME MM ME -- MM --
|
||||
++ ++ ME -- -- ME ME ME
|
||||
++ ++ MM ME MB ++ -- MB
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 10 10 50 50 50 20 20
|
||||
50 50 10 10 50 50 20 20
|
||||
50 50 50 10 10 10 10 30
|
||||
50 50 20 10 10 50 10 10
|
||||
50 50 20 20 10 50 10 10
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 3},
|
||||
{'battle': 1, 'enemy': 1},
|
||||
{'battle': 2, 'enemy': 2, 'mystery': 1},
|
||||
{'battle': 3, 'enemy': 2},
|
||||
{'battle': 4, 'enemy': 1, 'mystery': 1, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, G1, H1, \
|
||||
A2, B2, C2, D2, E2, F2, G2, H2, \
|
||||
A3, B3, C3, D3, E3, F3, G3, H3, \
|
||||
A4, B4, C4, D4, E4, F4, G4, H4, \
|
||||
A5, B5, C5, D5, E5, F5, G5, H5, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
step_on = SelectedGrids([E3, C3, G4, D2])
|
||||
road_boss = RoadGrids([C1, C2, [C3, D2], D4, E4, [E3, F4], F3, G3, H3, [G4, H4]])
|
||||
road_mystery = RoadGrids([[C4, D5], D4, G2, [G1, H2]])
|
||||
|
||||
|
||||
class Config:
|
||||
SUBMARINE = 0
|
||||
MAP_MYSTERY_HAS_CARRIER = True
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
|
||||
def battle_0(self):
|
||||
if self.fleet_2_step_on(step_on, roadblocks=[road_boss]):
|
||||
return True
|
||||
|
||||
if self.clear_roadblocks([road_boss]):
|
||||
return True
|
||||
if self.clear_roadblocks([road_mystery]):
|
||||
return True
|
||||
self.clear_all_mystery()
|
||||
if self.clear_potential_roadblocks([road_boss]):
|
||||
return True
|
||||
if self.clear_potential_roadblocks([road_mystery]):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_4(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.clear_roadblocks([road_boss])
|
||||
|
||||
return self.fleet_2.clear_boss()
|
70
campaign/campaign_main/campaign_6_2.py
Normal file
70
campaign/campaign_main/campaign_6_2.py
Normal file
@ -0,0 +1,70 @@
|
||||
from module.campaign.campaign_base import CampaignBase
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.map.map_grids import SelectedGrids, RoadGrids
|
||||
from module.logger import logger
|
||||
from campaign.campaign_main.campaign_6_1 import Config
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'H6'
|
||||
MAP.camera_data = ['D4', 'E4', 'E2']
|
||||
MAP.map_data = '''
|
||||
-- -- ME -- ME ++ ++ ++
|
||||
SP -- -- ME ME ME SP --
|
||||
-- ME -- ++ ++ -- ME --
|
||||
-- MM ME MA ++ ME MM ME
|
||||
ME ++ ++ -- MB -- ++ MB
|
||||
-- MB -- ++ ++ ME MB ME
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 50 50 50 50 50 50 50
|
||||
50 50 40 40 40 40 50 50
|
||||
50 50 40 40 40 40 40 40
|
||||
10 10 10 10 10 10 10 10
|
||||
10 10 10 10 10 10 10 10
|
||||
10 10 10 10 10 10 10 20
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 3},
|
||||
{'battle': 1, 'enemy': 2},
|
||||
{'battle': 2, 'enemy': 1, 'mystery': 1},
|
||||
{'battle': 3, 'enemy': 2},
|
||||
{'battle': 4, 'enemy': 1, 'mystery': 1, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, G1, H1, \
|
||||
A2, B2, C2, D2, E2, F2, G2, H2, \
|
||||
A3, B3, C3, D3, E3, F3, G3, H3, \
|
||||
A4, B4, C4, D4, E4, F4, G4, H4, \
|
||||
A5, B5, C5, D5, E5, F5, G5, H5, \
|
||||
A6, B6, C6, D6, E6, F6, G6, H6, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
step_on = SelectedGrids([C4, F4, A5, H4, F6])
|
||||
road_boss = RoadGrids([B6, A6, A5, A4, B4, C4, D4, D5, E5, F5, F6, F4, G4, H4])
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
|
||||
def battle_0(self):
|
||||
if self.fleet_2_step_on(step_on, roadblocks=[road_boss]):
|
||||
return True
|
||||
|
||||
if self.clear_roadblocks([road_boss]):
|
||||
return True
|
||||
|
||||
self.clear_all_mystery()
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_4(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.clear_roadblocks([road_boss])
|
||||
|
||||
return self.fleet_2.clear_boss()
|
77
campaign/campaign_main/campaign_6_3.py
Normal file
77
campaign/campaign_main/campaign_6_3.py
Normal file
@ -0,0 +1,77 @@
|
||||
from module.campaign.campaign_base import CampaignBase
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.map.map_grids import SelectedGrids, RoadGrids
|
||||
from module.logger import logger
|
||||
from campaign.campaign_main.campaign_6_1 import Config
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'H5'
|
||||
# WIKI的图有错: https://wiki.biligame.com/blhx/6-3
|
||||
# G3是出生点, 假图害人
|
||||
MAP.map_data = '''
|
||||
MB -- ME SP -- ME ME MM
|
||||
ME -- -- ++ ++ -- ME --
|
||||
-- -- ME MB ++ ME SP MB
|
||||
SP -- ME -- ME -- ME ME
|
||||
++ ME -- ME SP ME -- MM
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
10 10 50 50 50 50 50 10
|
||||
50 10 10 10 10 50 50 10
|
||||
50 50 10 10 10 20 10 10
|
||||
50 50 10 10 10 10 10 30
|
||||
50 50 20 20 20 20 10 10
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 4},
|
||||
{'battle': 1, 'enemy': 2},
|
||||
{'battle': 2, 'enemy': 1, 'mystery': 1},
|
||||
{'battle': 3, 'enemy': 2},
|
||||
{'battle': 4, 'enemy': 1, 'mystery': 1, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, G1, H1, \
|
||||
A2, B2, C2, D2, E2, F2, G2, H2, \
|
||||
A3, B3, C3, D3, E3, F3, G3, H3, \
|
||||
A4, B4, C4, D4, E4, F4, G4, H4, \
|
||||
A5, B5, C5, D5, E5, F5, G5, H5, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
step_on = SelectedGrids([E4, G2, C3, C4, F3])
|
||||
road_boss = RoadGrids([
|
||||
A1, [B1, A2], B2, [C2, B3], [B3, C3], [B4, C3], [C3, C4], [C4, D3], D4, # A1 - D4
|
||||
[G3, H4], [G3, G4], G3, [F3, G4], F4, [E4, F5], [E4, E5], [E4, D5] # H3 - D4
|
||||
])
|
||||
road_mystery = RoadGrids([[F5, G4], [H4, G5], H2])
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
|
||||
def battle_0(self):
|
||||
if self.fleet_2_step_on(step_on, roadblocks=[road_boss]):
|
||||
return True
|
||||
|
||||
if self.clear_roadblocks([road_boss]):
|
||||
return True
|
||||
if self.clear_roadblocks([road_mystery]):
|
||||
return True
|
||||
self.clear_all_mystery()
|
||||
if self.clear_potential_roadblocks([road_boss]):
|
||||
return True
|
||||
if self.clear_potential_roadblocks([road_mystery]):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_4(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.clear_roadblocks([road_boss])
|
||||
|
||||
return self.fleet_2.clear_boss()
|
76
campaign/campaign_main/campaign_6_4.py
Normal file
76
campaign/campaign_main/campaign_6_4.py
Normal file
@ -0,0 +1,76 @@
|
||||
from module.campaign.campaign_base import CampaignBase
|
||||
from module.map.map_base import CampaignMap
|
||||
from module.map.map_grids import SelectedGrids, RoadGrids
|
||||
from module.logger import logger
|
||||
from campaign.campaign_main.campaign_6_1 import Config
|
||||
|
||||
|
||||
MAP = CampaignMap()
|
||||
MAP.shape = 'H6'
|
||||
MAP.map_data = '''
|
||||
-- ME MB MB -- ME ++ ++
|
||||
MB SP ME -- ME MM MA ++
|
||||
-- ++ ME -- -- ME SP ME
|
||||
ME __ -- ME ME __ ME MB
|
||||
-- ME -- MB ++ ME -- ME
|
||||
MB ME -- SP -- ME -- --
|
||||
'''
|
||||
MAP.weight_data = '''
|
||||
50 40 40 40 50 50 50 50
|
||||
40 40 20 20 20 20 50 50
|
||||
10 50 10 10 10 10 10 20
|
||||
10 10 10 10 30 30 30 40
|
||||
10 20 20 40 40 50 50 50
|
||||
30 40 30 50 50 50 50 50
|
||||
'''
|
||||
MAP.spawn_data = [
|
||||
{'battle': 0, 'enemy': 4},
|
||||
{'battle': 1, 'enemy': 2},
|
||||
{'battle': 2, 'enemy': 2},
|
||||
{'battle': 3, 'enemy': 1, 'mystery': 1},
|
||||
{'battle': 4, 'enemy': 1},
|
||||
{'battle': 5, 'boss': 1},
|
||||
]
|
||||
|
||||
A1, B1, C1, D1, E1, F1, G1, H1, \
|
||||
A2, B2, C2, D2, E2, F2, G2, H2, \
|
||||
A3, B3, C3, D3, E3, F3, G3, H3, \
|
||||
A4, B4, C4, D4, E4, F4, G4, H4, \
|
||||
A5, B5, C5, D5, E5, F5, G5, H5, \
|
||||
A6, B6, C6, D6, E6, F6, G6, H6, \
|
||||
= MAP.flatten()
|
||||
|
||||
|
||||
step_on = SelectedGrids([C2, C3, D4, F3, G4])
|
||||
road_boss = RoadGrids([
|
||||
[A5, B6], [A4, B5, B6], C4, C5, [C3, D4], D3, # A6 - D3
|
||||
[C5, D3], # D5 - D3
|
||||
[B1, B2], [B1, C2], [C1, C2], [C2, D1], [C2, D2], # A2 - D3
|
||||
[H3, G2], [G3, G4], [F3, G4], [F3, F4], [F2, F3, E4], [E2, F3, E4], E3 # H4 - D3
|
||||
])
|
||||
|
||||
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
|
||||
def battle_0(self):
|
||||
if self.fleet_2_step_on(step_on, roadblocks=[road_boss]):
|
||||
return True
|
||||
|
||||
if self.clear_roadblocks([road_boss]):
|
||||
return True
|
||||
self.clear_all_mystery()
|
||||
if self.clear_potential_roadblocks([road_boss]):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_5(self):
|
||||
self.clear_all_mystery()
|
||||
|
||||
boss = self.map.select(is_boss=True)
|
||||
if boss:
|
||||
if not self.check_accessibility(boss[0]):
|
||||
return self.clear_roadblocks([road_boss])
|
||||
|
||||
return self.fleet_2.clear_boss()
|
@ -258,7 +258,7 @@ def main(ini_name=''):
|
||||
# ==========主线图==========
|
||||
main_parser = subs.add_parser('主线图')
|
||||
# 选择关卡
|
||||
stage = main_parser.add_argument_group('选择关卡', '主线图出击, 目前仅支持前三章和7-2')
|
||||
stage = main_parser.add_argument_group('选择关卡', '主线图出击, 目前仅支持前六章和7-2')
|
||||
stage.add_argument('--主线地图出击', default=default('--主线地图出击'), help='例如 7-2')
|
||||
|
||||
# ==========活动图==========
|
||||
|
@ -72,9 +72,9 @@ class AmbushHandler(Combat):
|
||||
image = ambush_letter_preprocess(np.array(self.device.image.crop((641, 311, 692, 336))))
|
||||
|
||||
if TEMPLATE_AMBUSH_EVADE_SUCCESS.match(image):
|
||||
logger.info('Ambush evade success')
|
||||
logger.attr('Ambush_evade', 'success')
|
||||
elif TEMPLATE_AMBUSH_EVADE_FAILED.match(image):
|
||||
logger.info('Ambush evade failed')
|
||||
logger.attr('Ambush_evade', 'failed')
|
||||
self.combat(expected_end='no_searching')
|
||||
else:
|
||||
logger.warning('Unrecognised info when ambush evade.')
|
||||
|
@ -79,7 +79,7 @@ class StrategyHandler(InfoBarHandler):
|
||||
self.strategy_set_execute(
|
||||
formation_index=expected_formation,
|
||||
sub_view=False,
|
||||
sub_hunt=self.config.SUBMARINE and self.config.SUBMARINE_MODE == 'hunt_only'
|
||||
sub_hunt=bool(self.config.SUBMARINE) and self.config.SUBMARINE_MODE == 'hunt_only'
|
||||
)
|
||||
self.__setattr__(f'fleet_{index}_formation_fixed', True)
|
||||
return True
|
||||
|
@ -87,22 +87,18 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
self.device.screenshot()
|
||||
grid.image = self.device.image
|
||||
|
||||
# Ambush
|
||||
if self.handle_ambush():
|
||||
ambushed_retry.start()
|
||||
# 这个虽然到了之后还会原地再点一次, 但还是先用着, 问题不大
|
||||
# arrived = False
|
||||
# 这个可能会误以为已经到达
|
||||
# arrived = grid.predict_fleet()
|
||||
# 把break去掉就搞定了
|
||||
# break
|
||||
|
||||
# Mystery
|
||||
mystery = self.handle_mystery(button=grid)
|
||||
if mystery:
|
||||
# arrived = True
|
||||
self.mystery_count += 1
|
||||
result = 'mystery'
|
||||
result_mystery = mystery
|
||||
# break
|
||||
|
||||
# Combat
|
||||
if self.combat_appear():
|
||||
self.combat(expected_end=self._expected_combat_end(expected), fleet_index=self.fleet_current_index)
|
||||
self.hp_get()
|
||||
@ -120,11 +116,12 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
self.handle_boss_appear_refocus()
|
||||
grid = self.convert_map_to_grid(location)
|
||||
walk_timeout.reset()
|
||||
# break
|
||||
|
||||
# Cat attack animation
|
||||
if self.handle_map_cat_attack():
|
||||
continue
|
||||
|
||||
# Arrive
|
||||
if self.is_in_map() and grid.predict_fleet():
|
||||
arrive_timer.start()
|
||||
arrive_unexpected_timer.start()
|
||||
@ -148,6 +145,9 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
|
||||
# End
|
||||
if arrived:
|
||||
# Ammo grid needs to click again, otherwise the next click doesn't work.
|
||||
if self.map[location].may_ammo:
|
||||
self.device.click(grid)
|
||||
break
|
||||
|
||||
self.map[self.fleet_current].is_fleet = False
|
||||
@ -186,12 +186,30 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
fleets.append(text)
|
||||
logger.info(' '.join(fleets))
|
||||
|
||||
def find_all_fleets(self):
|
||||
logger.hr('Find all fleets')
|
||||
queue = self.map.select(is_spawn_point=True)
|
||||
while queue:
|
||||
queue = queue.sort_by_camera_distance(self.camera)
|
||||
self.in_sight(queue[0], sight=(-1, 0, 1, 2))
|
||||
grid = self.convert_map_to_grid(queue[0])
|
||||
if grid.predict_current_fleet():
|
||||
self.fleet_1 = queue[0].location
|
||||
elif grid.predict_fleet():
|
||||
self.fleet_2 = queue[0].location
|
||||
queue = queue[1:]
|
||||
|
||||
def find_current_fleet(self):
|
||||
logger.hr('Find current fleet')
|
||||
fleets = self.map.select(is_fleet=True, is_spawn_point=True)
|
||||
logger.info('Fleets: %s' % str(fleets))
|
||||
count = fleets.count
|
||||
if count == 1:
|
||||
self.fleet_1 = fleets[0].location
|
||||
if not self.config.FLEET_2:
|
||||
self.fleet_1 = fleets[0].location
|
||||
else:
|
||||
logger.info('Fleet_2 not detected.')
|
||||
self.find_all_fleets()
|
||||
elif count == 2:
|
||||
fleets = fleets.sort_by_camera_distance(self.camera)
|
||||
self.in_sight(fleets[0], sight=(-1, 0, 1, 2))
|
||||
@ -209,19 +227,10 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
self.fleet_2 = fleets[1].location
|
||||
else:
|
||||
if count == 0:
|
||||
logger.warning('No fleets detected. Checking fleet spawn points.')
|
||||
logger.warning('No fleets detected.')
|
||||
if count > 2:
|
||||
logger.warning('Too many fleets: %s. Re-checking all spawn points.' % str(fleets))
|
||||
queue = self.map.select(is_spawn_point=True)
|
||||
while queue:
|
||||
queue = queue.sort_by_camera_distance(self.camera)
|
||||
self.in_sight(queue[0], sight=(-1, 0, 1, 2))
|
||||
grid = self.convert_map_to_grid(queue[0])
|
||||
if grid.predict_current_fleet():
|
||||
self.fleet_1 = grid.location
|
||||
elif grid.predict_fleet():
|
||||
self.fleet_2 = grid.location
|
||||
queue = queue[1:]
|
||||
logger.warning('Too many fleets: %s.' % str(fleets))
|
||||
self.find_all_fleets()
|
||||
|
||||
self.fleet_current_index = 1
|
||||
self.show_fleet()
|
||||
@ -229,6 +238,9 @@ class Fleet(Camera, MapOperation, AmbushHandler):
|
||||
|
||||
def map_init(self, map_):
|
||||
logger.hr('Map init')
|
||||
self.fleet_1_location = ()
|
||||
self.fleet_2_location = ()
|
||||
self.fleet_current_index = 1
|
||||
self.battle_count = 0
|
||||
self.mystery_count = 0
|
||||
self.carrier_count = 0
|
||||
|
@ -49,7 +49,6 @@ class Map(Fleet):
|
||||
if self.ammo_count > 0:
|
||||
logger.info('Pick up ammo: %s' % grid)
|
||||
self.goto(grid, expected='')
|
||||
self.goto(grid, expected='')
|
||||
self.ensure_no_info_bar()
|
||||
|
||||
# self.ammo_count -= 5 - self.battle_count
|
||||
@ -301,18 +300,17 @@ class Map(Fleet):
|
||||
if self.fleet_at(grid=grid, fleet=2):
|
||||
return False
|
||||
|
||||
logger.info('Fleet 2 step on')
|
||||
for grid in grids:
|
||||
if grid.is_enemy:
|
||||
if grid.is_enemy or grid.is_cleared:
|
||||
continue
|
||||
if self.check_accessibility(grid=grid, fleet=2):
|
||||
logger.info('Fleet_2 step on %s' % grid)
|
||||
self.fleet_2.goto(grid)
|
||||
self.fleet_1.switch_to()
|
||||
return False
|
||||
else:
|
||||
logger.info('Fleet_2 step on %s got roadblocks.' % grid)
|
||||
self.fleet_1.clear_roadblocks(roadblocks)
|
||||
self.fleet_1.clear_all_mystery()
|
||||
return True
|
||||
|
||||
return False
|
||||
logger.info('Fleet_2 step on %s got roadblocks.')
|
||||
self.fleet_1.clear_roadblocks(roadblocks)
|
||||
self.fleet_1.clear_all_mystery()
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user