Add: Task Awaken to GUI

This commit is contained in:
LmeSzinc 2025-01-04 21:55:06 +08:00
parent c8bf55b4ad
commit da81498211
13 changed files with 192 additions and 14 deletions

View File

@ -209,6 +209,10 @@ class AzurLaneAutoScript:
from module.reward.reward import Reward
Reward(config=self.config, device=self.device).run()
def awaken(self):
from module.awaken.awaken import Awaken
Awaken(config=self.config, device=self.device).run()
def shop_frequent(self):
from module.shop.shop_reward import RewardShop
RewardShop(config=self.config, device=self.device).run_frequent()

View File

@ -1338,6 +1338,22 @@
"Storage": {}
}
},
"Awaken": {
"Scheduler": {
"Enable": false,
"NextRun": "2020-01-01 00:00:00",
"Command": "Awaken",
"SuccessInterval": 0,
"FailureInterval": 120,
"ServerUpdate": "00:00"
},
"Awaken": {
"LevelCap": "level120"
},
"Storage": {
"Storage": {}
}
},
"Daily": {
"Scheduler": {
"Enable": false,

View File

@ -55,7 +55,7 @@ class Awaken(Dock):
chip = self._get_button_state(COST_CHIP)
array = self._get_button_state(COST_ARRAY)
logger.attr('AwaikenCost', {'coin': coin, 'chip': chip, 'array': array})
logger.attr('AwakenCost', {'coin': coin, 'chip': chip, 'array': array})
def is_right_moved(button):
# If COST_ARRAY is absent, COST_COIN and COST_CHIP are right moved 54px
@ -70,14 +70,14 @@ class Awaken(Dock):
if coin is not None and not is_right_moved(COST_COIN) \
and chip is not None and not is_right_moved(COST_CHIP):
result = coin and chip and array
logger.attr('AwaikenSufficient', result)
logger.attr('AwakenSufficient', result)
return result
else:
# If array is not needed, coin and chip should both present and right moved
if coin is not None and is_right_moved(COST_COIN) \
and chip is not None and is_right_moved(COST_CHIP):
result = coin and chip
logger.attr('AwaikenSufficient', result)
logger.attr('AwakenSufficient', result)
return result
logger.warning('Invalid awaken cost')
@ -147,13 +147,14 @@ class Awaken(Dock):
result = self._get_awaken_cost(use_array)
if result == 'unexpected_array':
# Get resources time out, assume sufficient
# This shouldn't happen
self.awaken_popup_close()
return 'unexpected_array'
return result
elif result is False:
logger.info('Insufficient resources to awaken')
return 'insufficient'
elif result is True:
# Sufficient resources
break
elif result == 'invalid':
# Retry, and check timeout also
@ -317,17 +318,18 @@ class Awaken(Dock):
use_array: True to awaken to level 125, False to 120
Returns:
str: 'insufficient', 'timeout'
str: 'insufficient', 'finish', 'timeout'
Pages:
in: Any
out: page_dock
"""
logger.hr('Awaken run', level=1)
self.ui_ensure(page_dock)
self.dock_favourite_set(wait_loading=False)
self.dock_sort_method_dsc_set(wait_loading=False)
if use_array:
extra = ['can_awaken', 'can_awaken_plus']
extra = ['can_awaken_plus']
else:
extra = ['can_awaken']
self.dock_filter_set(extra=extra)
@ -336,6 +338,7 @@ class Awaken(Dock):
# page_dock
if self.appear(DOCK_EMPTY, offset=(20, 20)):
logger.info('awaken_run finished, no ships to awaken')
result = 'finish'
break
# page_dock -> SHIP_DETAIL_CHECK
@ -351,11 +354,35 @@ class Awaken(Dock):
continue
if result == 'insufficient':
logger.info('awaken_run finished, resources exhausted')
return result
break
if result == 'timeout':
logger.info(f'awaken_run finished, result={result}')
return result
break
raise ScriptError(f'Unexpected awaken_ship result: {result}')
return result
def run(self):
if self.config.SERVER not in ['cn']:
logger.error(f'Task "Awaken" is not available on server {self.config.SERVER} yet, '
f'please contact server maintainers')
self.config.task_stop()
# Run Awakening+ first
if self.config.Awaken_LevelCap == 'level125':
# Use Cognitive Arrays
self.awaken_run(use_array=True)
# Use Cognitive Chips
self.awaken_run()
elif self.config.Awaken_LevelCap == 'level120':
# Use Cognitive Chips
self.awaken_run()
else:
raise ScriptError(f'Unknown Awaken_LevelCap={self.config.Awaken_LevelCap}')
# Reset dock filters
logger.hr('Awaken run exit', level=1)
self.dock_filter_set()
self.dock_filter_set(wait_loading=False)
# Scheduler
self.config.task_delay(server_update=True)

View File

@ -7231,6 +7231,61 @@
}
}
},
"Awaken": {
"Scheduler": {
"Enable": {
"type": "checkbox",
"value": false,
"option": [
true,
false
]
},
"NextRun": {
"type": "datetime",
"value": "2020-01-01 00:00:00",
"validate": "datetime"
},
"Command": {
"type": "input",
"value": "Awaken",
"display": "hide"
},
"SuccessInterval": {
"type": "input",
"value": 0,
"display": "hide"
},
"FailureInterval": {
"type": "input",
"value": 120,
"display": "hide"
},
"ServerUpdate": {
"type": "input",
"value": "00:00",
"display": "hide"
}
},
"Awaken": {
"LevelCap": {
"type": "select",
"value": "level120",
"option": [
"level120",
"level125"
]
}
},
"Storage": {
"Storage": {
"type": "storage",
"value": {},
"valuetype": "ignore",
"display": "disabled"
}
}
},
"Daily": {
"Scheduler": {
"Enable": {

View File

@ -449,6 +449,10 @@ Reward:
CollectExp: true
CollectMission: true
CollectWeeklyMission: true
Awaken:
LevelCap:
value: level120
option: [ level120, level125 ]
GeneralShop:
UseGems: false
Refresh: false

View File

@ -54,7 +54,8 @@
"Dorm",
"Meowfficer",
"Guild",
"Reward"
"Reward",
"Awaken"
]
},
"DailyMission": {

View File

@ -215,6 +215,9 @@ Reward:
Reward:
- Scheduler
- Reward
Awaken:
- Scheduler
- Awaken
# ==================== DailyMission ====================

View File

@ -251,6 +251,9 @@ class GeneratedConfig:
Reward_CollectMission = True
Reward_CollectWeeklyMission = True
# Group `Awaken`
Awaken_LevelCap = 'level120' # level120, level125
# Group `GeneralShop`
GeneralShop_UseGems = False
GeneralShop_Refresh = False

View File

@ -15,12 +15,13 @@ class ManualConfig:
> Exercise
> Dorm > Meowfficer > Guild > Gacha
> Reward
> ShopFrequent > ShopOnce > Shipyard > Freebies > Minigame
> ShopFrequent > ShopOnce > Shipyard > Freebies
> OpsiExplore
> Minigame > Awaken
> OpsiAshBeacon
> OpsiDaily > OpsiShop > OpsiVoucher
> OpsiAbyssal > OpsiStronghold > OpsiObscure > OpsiArchive
> Daily > Hard > OpsiAshBeacon > OpsiAshAssist > OpsiMonthBoss
> Daily > Hard > OpsiAshBeacon > OpsiAshAssist > OpsiMonthBoss
> Sos > EventSp > EventA > EventB > EventC > EventD
> RaidDaily > CoalitionSp > WarArchives > MaritimeEscort
> Event > Event2 > Raid > Coalition > Main > Main2 > Main3

View File

@ -146,6 +146,10 @@
"name": "Reward",
"help": ""
},
"Awaken": {
"name": "Awaken",
"help": ""
},
"Daily": {
"name": "Daily",
"help": ""
@ -276,7 +280,7 @@
},
"NextRun": {
"name": "Next Run",
"help": "Updated automatically after completing the task to set next scheduled run, typically not manually modified\nHowever you can force immediate scheduling if you clear this text field"
"help": "Updated automatically after completing the task to set next scheduled run, typically not manually modified\nHowever you can force immediate scheduling if text field cleared"
},
"Command": {
"name": "Command",
@ -1591,6 +1595,18 @@
"help": ""
}
},
"Awaken": {
"_info": {
"name": "Cognitive Awakening Settings",
"help": "Awaken all ships in dock til cognitive chips/arrays exhausted"
},
"LevelCap": {
"name": "To Level Cap",
"help": "",
"level120": "Lv.120",
"level125": "Lv.125"
}
},
"GeneralShop": {
"_info": {
"name": "General Shop Settings",

View File

@ -146,6 +146,10 @@
"name": "収穫",
"help": ""
},
"Awaken": {
"name": "Task.Awaken.name",
"help": "Task.Awaken.help"
},
"Daily": {
"name": "デイリー",
"help": ""
@ -1591,6 +1595,18 @@
"help": "Reward.CollectWeeklyMission.help"
}
},
"Awaken": {
"_info": {
"name": "Awaken._info.name",
"help": "Awaken._info.help"
},
"LevelCap": {
"name": "Awaken.LevelCap.name",
"help": "Awaken.LevelCap.help",
"level120": "level120",
"level125": "level125"
}
},
"GeneralShop": {
"_info": {
"name": "GeneralShop._info.name",

View File

@ -146,6 +146,10 @@
"name": "收获",
"help": ""
},
"Awaken": {
"name": "认知觉醒",
"help": ""
},
"Daily": {
"name": "每日任务",
"help": ""
@ -1591,6 +1595,18 @@
"help": ""
}
},
"Awaken": {
"_info": {
"name": "认知觉醒",
"help": "认知觉醒船坞内所有的船直到心智单元耗尽"
},
"LevelCap": {
"name": "觉醒至等级上限",
"help": "",
"level120": "120级",
"level125": "125级"
}
},
"GeneralShop": {
"_info": {
"name": "军火商(通用商店)",

View File

@ -146,6 +146,10 @@
"name": "收穫",
"help": ""
},
"Awaken": {
"name": "認知覺醒",
"help": ""
},
"Daily": {
"name": "每日任務",
"help": ""
@ -1591,6 +1595,18 @@
"help": ""
}
},
"Awaken": {
"_info": {
"name": "認知覺醒",
"help": "認知覺醒船塢內所有的船隻直到心智單元耗盡"
},
"LevelCap": {
"name": "覺醒至等級上限",
"help": "",
"level120": "120級",
"level125": "125級"
}
},
"GeneralShop": {
"_info": {
"name": "軍火商 (通用商店)",