1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-05-07 20:53:38 +08:00

Add: Single Battle Oil Consumption Upper Limit for WarArchives (#4)

This commit is contained in:
2025-12-24 19:16:44 +08:00
parent 5310187a46
commit 4ff5cc640a
11 changed files with 194 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ from module.campaign.campaign_status import CampaignStatus
from module.combat.assets import *
from module.combat.combat import Combat
from module.exception import CampaignEnd
from module.exercise.assets import QUIT_RECONFIRM
from module.handler.assets import AUTO_SEARCH_MAP_OPTION_ON, GET_MISSION
from module.logger import logger
from module.map.assets import WITHDRAW
@@ -10,8 +11,10 @@ from module.map.map_operation import MapOperation
class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
_prev_oil = 0
_auto_search_in_stage_timer = Timer(3, count=6)
_auto_search_status_confirm = False
_interrupt = False
_withdraw = False
auto_search_oil_limit_triggered = False
auto_search_coin_limit_triggered = False
@@ -201,6 +204,81 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
if self.is_in_auto_search_menu() or self._handle_auto_search_menu_missing():
raise CampaignEnd
def interrupt_auto_search(self, emotion_reduce, fleet_index, skip_first_screenshot=True):
"""
Raises:
TaskEnd: If auto search interrupted
Pages:
in: Any, usually to be is_combat_executing
out: page_campaign or page_event or page_sp
"""
logger.info('Interrupting auto search')
is_loading = False
pause_interval = Timer(0.5, count=1)
in_map_timer = Timer(1, count=6)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
if self.is_in_map():
if in_map_timer.reached():
logger.info('Auto search interrupted')
break
if self.handle_combat_automation_confirm():
in_map_timer.reset()
continue
if self.handle_story_skip():
in_map_timer.reset()
continue
if self.handle_vote_popup():
in_map_timer.reset()
continue
if pause_interval.reached():
pause = self.is_combat_executing()
if pause:
self.device.click(pause)
is_loading = False
pause_interval.reset()
in_map_timer.reset()
continue
if self.handle_combat_quit():
pause_interval.reset()
in_map_timer.reset()
continue
if self.appear_then_click(QUIT_RECONFIRM, offset=True, interval=5):
pause_interval.reset()
in_map_timer.reset()
continue
# Only print once when detected
if not is_loading:
if self.is_combat_loading():
is_loading = True
in_map_timer.clear()
continue
elif self.is_combat_executing():
is_loading = False
in_map_timer.clear()
continue
if emotion_reduce:
self.emotion.reduce(fleet_index)
try:
self._interrupt = False
self.withdraw()
except CampaignEnd:
logger.warning("Disable current task due to abnormal oil consumption. "
"Please check your oil settings")
self.config.Scheduler_Enable = False
self.config.task_stop()
def auto_search_combat_execute(self, emotion_reduce, fleet_index, battle=None, expected_end=None):
"""
Args:
@@ -300,7 +378,6 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
if expected_end():
self.device.screenshot_interval_set()
break
def auto_search_combat_status(self):
"""
@@ -315,7 +392,6 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
get_urgent_commission = False
for _ in self.loop():
# End
if self.is_auto_search_running():
self._auto_search_status_confirm = False

View File

@@ -4145,6 +4145,12 @@
"display": "hide"
}
},
"InterceptiveCheck": {
"OilThreshold": {
"type": "input",
"value": 0
}
},
"StopCondition": {
"OilLimit": {
"type": "input",

View File

@@ -161,6 +161,8 @@ Campaign:
UseAutoSearch: true
Use2xBook: false
AmbushEvade: true
InterceptiveCheck:
OilThreshold: 0
StopCondition:
OilLimit: 1000
RunCount: 0

View File

@@ -114,6 +114,7 @@ Event:
WarArchives:
- Scheduler
- Campaign
- InterceptiveCheck
- StopCondition
- Fleet
- Submarine

View File

@@ -84,6 +84,9 @@ class GeneratedConfig:
Campaign_Use2xBook = False
Campaign_AmbushEvade = True
# Group `InterceptiveCheck`
InterceptiveCheck_OilThreshold = 0
# Group `StopCondition`
StopCondition_OilLimit = 1000
StopCondition_RunCount = 0

View File

@@ -862,6 +862,16 @@
"help": ""
}
},
"InterceptiveCheck": {
"_info": {
"name": "Dynamic Verification",
"help": "Judge whether the current task settings meet the requirements through in-game information to avoid problems caused by forgetting to adjust the task settings.\nAfter any of the following conditions is triggered, the current battle will be exited and the task will be closed."
},
"OilThreshold": {
"name": "Single Battle Oil Consumption Upper Limit",
"help": "If the oil consumption of a single battle is greater than or equal to X, the setting is deemed incorrect.\n0 means no limit on oil consumption."
}
},
"StopCondition": {
"_info": {
"name": "Stop Condition Settings",

View File

@@ -862,6 +862,16 @@
"help": "Campaign.AmbushEvade.help"
}
},
"InterceptiveCheck": {
"_info": {
"name": "InterceptiveCheck._info.name",
"help": "InterceptiveCheck._info.help"
},
"OilThreshold": {
"name": "InterceptiveCheck.OilThreshold.name",
"help": "InterceptiveCheck.OilThreshold.help"
}
},
"StopCondition": {
"_info": {
"name": "StopCondition._info.name",

View File

@@ -862,6 +862,16 @@
"help": ""
}
},
"InterceptiveCheck": {
"_info": {
"name": "动态校验",
"help": "通过局内信息判断当前任务设置是否符合需求,避免出现由未调整任务设置导致的问题\n触发以下任意条件后退出当前作战并关闭任务"
},
"OilThreshold": {
"name": "单战油耗上限",
"help": "局内单场战斗油耗大于等于 X 时认为设置有误\n0表示无限制"
}
},
"StopCondition": {
"_info": {
"name": "停止条件",

View File

@@ -862,6 +862,16 @@
"help": ""
}
},
"InterceptiveCheck": {
"_info": {
"name": "動態校驗",
"help": "透過局內資訊判斷當前任務設定是否符合需求,避免出現因忘記調整任務設定而導致的問題\n觸發以下任一條件後將退出當前作戰並關閉任務"
},
"OilThreshold": {
"name": "單戰油耗上限",
"help": "局內單場戰鬥油耗大於等於 X 時認為設定有誤\n0表示不限制油耗"
}
},
"StopCondition": {
"_info": {
"name": "停止條件",