StarRailCopilot/module/campaign/campaign_base.py
LmeSzinc 70936f4f39 Add: 适配第二章
- 修复了不开启周回模式时, 会在出击界面开启自动的问题
- 修复了多打一战后, 打完BOSS不判定当前出击结束的问题
- 增加掉落新船时锁定的功能
- 增加了地图不支持周回模式时, 跳过周回检查的功能
  周回模式的选项可以无脑开了
- 修改透视识别报warning为info
  因为低级图地图小降低了检测的阈值, 导致需要纠正错误有点多
- 减少了战斗准备页面的多余点击
- 减少了挂委托时的多余点击
2020-04-14 17:32:26 +08:00

52 lines
1.6 KiB
Python

from module.base.button import Button
from module.logger import logger
from module.map.exception import CampaignEnd
from module.map.map import Map
from module.map.map_base import CampaignMap
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 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.')
exit(1)
return result
def run(self):
logger.hr(self.ENTRANCE, level=2)
self.handle_spare_fleet()
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(15):
try:
self.execute_a_battle()
except CampaignEnd:
logger.hr('Campaign end')
break