mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-09 05:47:30 +08:00
Refactor: SOS module
- Fix: Expected reduce when no fleet 2
This commit is contained in:
parent
36ff135cbd
commit
33d503465f
4
alas.py
4
alas.py
@ -25,6 +25,7 @@ from module.meowfficer.meowfficer import RewardMeowfficer
|
||||
from module.research.research import RewardResearch
|
||||
from module.reward.reward import Reward
|
||||
from module.shop.shop_reward import RewardShop
|
||||
from module.sos.sos import CampaignSos
|
||||
from module.tactical.tactical_class import RewardTacticalClass
|
||||
|
||||
|
||||
@ -139,6 +140,9 @@ class AzurLaneAutoScript:
|
||||
def exercise(self):
|
||||
Exercise(config=self.config, device=self.device).run()
|
||||
|
||||
def sos(self):
|
||||
CampaignSos(config=self.config, device=self.device).run()
|
||||
|
||||
def main(self):
|
||||
CampaignRun(config=self.config, device=self.device).run(
|
||||
name=self.config.Campaign_Name,
|
||||
|
@ -383,3 +383,61 @@ Exercise:
|
||||
OpponentRefresh:
|
||||
Count: 0
|
||||
Record: 2020-01-01 00:00:00
|
||||
Sos:
|
||||
Scheduler:
|
||||
Enable: false
|
||||
NextRun: 2020-01-01 00:00:00
|
||||
Command: Sos
|
||||
SuccessInterval: 0
|
||||
FailureInterval: 120
|
||||
ServerUpdate: 00:00
|
||||
Sos:
|
||||
Chapter: 3
|
||||
Campaign:
|
||||
UseClearMode: true
|
||||
UseFleetLock: true
|
||||
UseAutoSearch: false
|
||||
Use2xBook: false
|
||||
AmbushEvade: true
|
||||
StopCondition:
|
||||
RunCount: 0
|
||||
OilLimit: 1000
|
||||
MapAchievement: non_stop
|
||||
GetNewShip: false
|
||||
ReachLevel120: false
|
||||
Fleet:
|
||||
Fleet1: 1
|
||||
Fleet1Formation: double_line
|
||||
Fleet1Mode: combat_auto
|
||||
Fleet1Step: 3
|
||||
Fleet2: 2
|
||||
Fleet2Formation: double_line
|
||||
Fleet2Mode: combat_auto
|
||||
Fleet2Step: 2
|
||||
FleetOrder: fleet1_mob_fleet2_boss
|
||||
AutoSearchFleetOrder: fleet1_mob_fleet2_boss
|
||||
Submarine:
|
||||
Fleet: 0
|
||||
Mode: do_not_use
|
||||
Emotion:
|
||||
CalculateEmotion: true
|
||||
IgnoreLowEmotionWarn: false
|
||||
Fleet1Value: 119
|
||||
Fleet1Record: 2020-01-01 00:00:00
|
||||
Fleet1Control: prevent_yellow_face
|
||||
Fleet1Recover: not_in_dormitory
|
||||
Fleet1Oath: false
|
||||
Fleet2Value: 119
|
||||
Fleet2Record: 2020-01-01 00:00:00
|
||||
Fleet2Control: prevent_yellow_face
|
||||
Fleet2Recover: not_in_dormitory
|
||||
Fleet2Oath: false
|
||||
HpControl:
|
||||
UseHpBalance: false
|
||||
UseEmergencyRepair: false
|
||||
UseLowHpRetreat: false
|
||||
HpBalanceThreshold: 0.2
|
||||
HpBalanceWeight: 1000, 1000, 1000
|
||||
RepairUseSingleThreshold: 0.3
|
||||
RepairUseMultiThreshold: 0.6
|
||||
LowHpRetreatThreshold: 0.3
|
||||
|
@ -152,7 +152,7 @@ class CampaignRun(UI):
|
||||
self.run_limit = self.config.StopCondition_RunCount
|
||||
while 1:
|
||||
# End
|
||||
if total and self.run_count == total:
|
||||
if total and self.run_count >= total:
|
||||
break
|
||||
|
||||
# Log
|
||||
|
@ -552,3 +552,99 @@ Exercise:
|
||||
OpponentRefresh:
|
||||
Count: 0
|
||||
Record: 2020-01-01 00:00:00
|
||||
Sos:
|
||||
_info:
|
||||
Menu: Daily
|
||||
Scheduler:
|
||||
Enable: false
|
||||
NextRun: 2020-01-01 00:00:00
|
||||
Command: Sos
|
||||
SuccessInterval: 0
|
||||
FailureInterval: 120
|
||||
ServerUpdate: 00:00
|
||||
Sos:
|
||||
Chapter:
|
||||
value: 3
|
||||
option: [3, 4, 5, 6, 7, 8, 9, 10]
|
||||
Campaign:
|
||||
UseClearMode: true
|
||||
UseFleetLock: true
|
||||
UseAutoSearch: false
|
||||
Use2xBook: false
|
||||
AmbushEvade: true
|
||||
StopCondition:
|
||||
RunCount: 0
|
||||
OilLimit: 1000
|
||||
MapAchievement:
|
||||
value: non_stop
|
||||
option: ['non_stop', '100_percent_clear', 'map_3_stars', 'threat_safe', 'threat_safe_without_3_stars']
|
||||
GetNewShip: false
|
||||
ReachLevel120: false
|
||||
Fleet:
|
||||
Fleet1:
|
||||
value: 1
|
||||
option: [1, 2, 3, 4, 5, 6]
|
||||
Fleet1Formation:
|
||||
value: double_line
|
||||
option: ['line_ahead', 'double_line', 'diamond']
|
||||
Fleet1Mode:
|
||||
value: combat_auto
|
||||
option: ['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left']
|
||||
Fleet1Step:
|
||||
value: 3
|
||||
option: [2, 3, 4, 5]
|
||||
Fleet2:
|
||||
value: 2
|
||||
option: [0, 1, 2, 3, 4, 5, 6]
|
||||
Fleet2Formation:
|
||||
value: double_line
|
||||
option: ['line_ahead', 'double_line', 'diamond']
|
||||
Fleet2Mode:
|
||||
value: combat_auto
|
||||
option: ['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left']
|
||||
Fleet2Step:
|
||||
value: 2
|
||||
option: [2, 3, 4, 5]
|
||||
FleetOrder:
|
||||
value: fleet1_mob_fleet2_boss
|
||||
option: ['fleet1_mob_fleet2_boss', 'fleet1_all_fleet2_standby']
|
||||
AutoSearchFleetOrder:
|
||||
value: fleet1_mob_fleet2_boss
|
||||
option: ['fleet1_mob_fleet2_boss', 'fleet1_boss_fleet2_mob', 'fleet1_all_fleet2_standby', 'fleet1_standby_fleet2_all']
|
||||
Submarine:
|
||||
Fleet:
|
||||
value: 0
|
||||
option: [0, 1, 2]
|
||||
Mode:
|
||||
value: do_not_use
|
||||
option: ['do_not_use','hunt_only', 'every_combat']
|
||||
Emotion:
|
||||
CalculateEmotion: true
|
||||
IgnoreLowEmotionWarn: false
|
||||
Fleet1Value: 119
|
||||
Fleet1Record: 2020-01-01 00:00:00
|
||||
Fleet1Control:
|
||||
value: prevent_yellow_face
|
||||
option: ['keep_exp_bonus', 'prevent_green_face', 'prevent_yellow_face', 'prevent_red_face']
|
||||
Fleet1Recover:
|
||||
value: not_in_dormitory
|
||||
option: ['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2']
|
||||
Fleet1Oath: false
|
||||
Fleet2Value: 119
|
||||
Fleet2Record: 2020-01-01 00:00:00
|
||||
Fleet2Control:
|
||||
value: prevent_yellow_face
|
||||
option: ['keep_exp_bonus', 'prevent_green_face', 'prevent_yellow_face', 'prevent_red_face']
|
||||
Fleet2Recover:
|
||||
value: not_in_dormitory
|
||||
option: ['not_in_dormitory', 'dormitory_floor_1', 'dormitory_floor_2']
|
||||
Fleet2Oath: false
|
||||
HpControl:
|
||||
UseHpBalance: false
|
||||
UseEmergencyRepair: false
|
||||
UseLowHpRetreat: false
|
||||
HpBalanceThreshold: 0.2
|
||||
HpBalanceWeight: 1000, 1000, 1000
|
||||
RepairUseSingleThreshold: 0.3
|
||||
RepairUseMultiThreshold: 0.6
|
||||
LowHpRetreatThreshold: 0.3
|
||||
|
@ -334,10 +334,13 @@ class AzurLaneConfig(ManualConfig, GeneratedConfig):
|
||||
def FLEET_BOSS(self):
|
||||
if self._fleet_boss:
|
||||
return self._fleet_boss
|
||||
if self.Fleet_Fleet2:
|
||||
if self.Fleet_FleetOrder == 'fleet1_mob_fleet2_boss':
|
||||
return 2
|
||||
else:
|
||||
return 1
|
||||
else:
|
||||
return 1
|
||||
|
||||
@FLEET_BOSS.setter
|
||||
def FLEET_BOSS(self, value):
|
||||
|
@ -189,3 +189,6 @@ class GeneratedConfig:
|
||||
Exercise_LowHpConfirmWait = 0.1
|
||||
OpponentRefresh_Count = 0
|
||||
OpponentRefresh_Record = datetime.datetime(2020, 1, 1, 0, 0)
|
||||
|
||||
# Func `Sos`
|
||||
Sos_Chapter = 3 # 3, 4, 5, 6, 7, 8, 9, 10
|
||||
|
@ -8,12 +8,11 @@ from module.ocr.ocr import Digit
|
||||
from module.sos.assets import *
|
||||
from module.template.assets import *
|
||||
from module.ui.assets import CAMPAIGN_CHECK
|
||||
from module.ui.page import page_campaign
|
||||
from module.ui.scroll import Scroll
|
||||
|
||||
OCR_SOS_SIGNAL = Digit(OCR_SIGNAL, letter=(255, 255, 255), threshold=128, name='OCR_SOS_SIGNAL')
|
||||
SOS_SCROLL = Scroll(SOS_SCROLL_AREA, color=(164, 173, 189), name='SOS_SCROLL')
|
||||
RECORD_OPTION = ('DailyRecord', 'sos')
|
||||
RECORD_SINCE = (0,)
|
||||
|
||||
|
||||
class CampaignSos(CampaignRun, CampaignBase):
|
||||
@ -86,11 +85,11 @@ class CampaignSos(CampaignRun, CampaignBase):
|
||||
self._sos_signal_confirm(entrance=target_button)
|
||||
return True
|
||||
|
||||
backup = self.config.cover(DEVICE_CONTROL_METHOD='minitouch')
|
||||
# backup = self.config.cover(DEVICE_CONTROL_METHOD='minitouch')
|
||||
p1, p2 = random_rectangle_vector(
|
||||
(0, -200), box=detection_area, random_range=(-50, -50, 50, 50), padding=20)
|
||||
self.device.drag(p1, p2, segments=2, shake=(0, 25), point_random=(0, 0, 0, 0), shake_random=(0, -5, 0, 5))
|
||||
backup.recover()
|
||||
# backup.recover()
|
||||
self.device.sleep((0.6, 1))
|
||||
self.device.screenshot()
|
||||
return False
|
||||
@ -160,55 +159,40 @@ class CampaignSos(CampaignRun, CampaignBase):
|
||||
if self.appear(CAMPAIGN_CHECK, offset=(20, 20)):
|
||||
break
|
||||
|
||||
def run(self, name=None, folder='campaign_sos', total=1):
|
||||
def run(self, name=None, folder='campaign_sos', mode='normal', total=1):
|
||||
"""
|
||||
Args:
|
||||
name (str): Default to None, because stages in SOS are dynamic.
|
||||
folder (str): Default to 'campaign_sos'.
|
||||
mode (str): Must be `normal` in SOS
|
||||
total (int): Default to 1, because SOS stages can only run once.
|
||||
|
||||
Pages:
|
||||
in: Any page
|
||||
out: page_campaign
|
||||
"""
|
||||
logger.hr('Campaign SOS', level=1)
|
||||
self.ui_weigh_anchor()
|
||||
remain = OCR_SOS_SIGNAL.ocr(self.device.image)
|
||||
logger.attr('SOS signal', remain)
|
||||
if remain == 0:
|
||||
logger.info(f'No SOS signal, End SOS signal search')
|
||||
return True
|
||||
|
||||
# avoid sos calls daily_sos and causes error.
|
||||
self.reward_backup_daily_reward_settings()
|
||||
|
||||
fleet_1 = self.config.SOS_FLEET_1
|
||||
fleet_2 = self.config.SOS_FLEET_2
|
||||
submarine = self.config.SOS_SUBMARINE
|
||||
chapter = self.config.SOS_CHAPTER
|
||||
backup = self.config.cover(
|
||||
FLEET_1=fleet_1,
|
||||
FLEET_2=fleet_2,
|
||||
SUBMARINE=submarine,
|
||||
FLEET_BOSS=1 if not fleet_2 else 2
|
||||
)
|
||||
self.ui_ensure(page_campaign)
|
||||
|
||||
while 1:
|
||||
if self._sos_signal_select(chapter):
|
||||
super().run(f'campaign_{chapter}_5', folder=folder, total=total)
|
||||
# End
|
||||
remain = OCR_SOS_SIGNAL.ocr(self.device.image)
|
||||
logger.attr('remain', remain)
|
||||
if remain < 1:
|
||||
logger.attr('SOS signal', remain)
|
||||
if remain <= 0:
|
||||
logger.info(f'All SOS signals cleared')
|
||||
break
|
||||
|
||||
# Run
|
||||
if self._sos_signal_select(self.config.Sos_Chapter):
|
||||
name = f'campaign_{self.config.Sos_Chapter}_5'
|
||||
self.config.override(Campaign_Name=name)
|
||||
super().run(name, folder=folder, mode=mode, total=total)
|
||||
continue
|
||||
else:
|
||||
self.ui_click(SIGNAL_SEARCH_CLOSE, appear_button=SIGNAL_LIST_CHECK, check_button=CAMPAIGN_CHECK,
|
||||
skip_first_screenshot=True)
|
||||
logger.warn(f'Failed to clear SOS signals, cannot locate chapter {chapter}')
|
||||
logger.warning(f'Failed to clear SOS signals, cannot locate chapter {self.config.Sos_Chapter}')
|
||||
break
|
||||
|
||||
backup.recover()
|
||||
self.reward_recover_daily_reward_settings()
|
||||
return True
|
||||
|
||||
def record_executed_since(self):
|
||||
return self.config.record_executed_since(option=RECORD_OPTION, since=RECORD_SINCE)
|
||||
|
||||
def record_save(self):
|
||||
return self.config.record_save(option=RECORD_OPTION)
|
||||
# Scheduler
|
||||
self.config.task_delay(server_update=True)
|
||||
|
Loading…
Reference in New Issue
Block a user