mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-23 09:01:45 +00:00
bea05d396e
- 开荒模式移动至出击设置 - 增加开荒模式自动启用, 无脑开就完事了 - 将透视识别参数放到了config里, 这样就可以用地图config覆盖了 - 适配小地图模式, 参数抄A1就行了 - 修复了章节名OCR的识别位置 - 修复了开荒会把BOSS当作精英打问题 - 增加战斗中的剧情跳过 - 注释掉了截图和点击的retry - 增加了捕捉目标点超出移动范围
104 lines
3.2 KiB
Python
104 lines
3.2 KiB
Python
from module.base.button import Button
|
|
from module.logger import logger
|
|
from module.map.exception import CampaignEnd
|
|
from module.map.exception import ScriptError
|
|
from module.map.map import Map
|
|
from module.map.map_base import CampaignMap
|
|
from module.base.decorator import Config
|
|
|
|
|
|
class CampaignBase(Map):
|
|
FUNCTION_NAME_BASE = 'battle_'
|
|
ENTRANCE = Button(area=(), color=(), button=(), name='default_button')
|
|
MAP: CampaignMap
|
|
|
|
def battle_default(self):
|
|
if self.clear_enemy():
|
|
return True
|
|
|
|
logger.warning('No battle executed.')
|
|
return False
|
|
|
|
def battle_boss(self):
|
|
if self.brute_clear_boss():
|
|
return True
|
|
|
|
logger.warning('No battle executed.')
|
|
return False
|
|
|
|
@Config.when(POOR_MAP_DATA=True, MAP_CLEAR_ALL_THIS_TIME=False)
|
|
def execute_a_battle(self):
|
|
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
|
|
logger.info('Running with poor map data.')
|
|
self.clear_all_mystery()
|
|
|
|
if self.battle_count >= 3:
|
|
self.pick_up_ammo()
|
|
|
|
if self.map.select(is_boss=True):
|
|
if self.brute_clear_boss():
|
|
return True
|
|
else:
|
|
if self.clear_siren():
|
|
return True
|
|
return self.clear_enemy()
|
|
|
|
logger.warning('No battle executed.')
|
|
return False
|
|
|
|
@Config.when(MAP_CLEAR_ALL_THIS_TIME=True)
|
|
def execute_a_battle(self):
|
|
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
|
|
logger.info('Using function: clear_all')
|
|
self.clear_all_mystery()
|
|
|
|
if self.battle_count >= 3:
|
|
self.pick_up_ammo()
|
|
|
|
remain = self.map.select(is_enemy=True, is_boss=False)
|
|
logger.info('Enemy remain: {}')
|
|
if remain.count > 0:
|
|
if self.clear_siren():
|
|
return True
|
|
return self.battle_default()
|
|
else:
|
|
return self.battle_boss()
|
|
|
|
@Config.when(MAP_CLEAR_ALL_THIS_TIME=False, POOR_MAP_DATA=False)
|
|
def execute_a_battle(self):
|
|
func = self.FUNCTION_NAME_BASE + 'default'
|
|
for extra_battle in range(10):
|
|
if hasattr(self, self.FUNCTION_NAME_BASE + str(self.battle_count - extra_battle)):
|
|
func = self.FUNCTION_NAME_BASE + str(self.battle_count - extra_battle)
|
|
break
|
|
|
|
logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2)
|
|
logger.info(f'Using function: {func}')
|
|
func = self.__getattribute__(func)
|
|
|
|
result = func()
|
|
if not result:
|
|
logger.warning('No combat executed.')
|
|
raise ScriptError('No combat executed.')
|
|
|
|
return result
|
|
|
|
def run(self):
|
|
logger.hr(self.ENTRANCE, level=2)
|
|
self.handle_spare_fleet()
|
|
self.ENTRANCE.area = self.ENTRANCE.button
|
|
self.enter_map(self.ENTRANCE, mode=self.config.CAMPAIGN_MODE)
|
|
self.handle_map_fleet_lock()
|
|
self.handle_fleet_reverse()
|
|
self.map_init(self.MAP)
|
|
|
|
for _ in range(20):
|
|
try:
|
|
self.execute_a_battle()
|
|
except CampaignEnd:
|
|
logger.hr('Campaign end')
|
|
return True
|
|
|
|
logger.warning('Battle function exhausted.')
|
|
raise ScriptError('Battle function exhausted.')
|