diff --git a/alas.py b/alas.py index a525e272b..8a5056444 100644 --- a/alas.py +++ b/alas.py @@ -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() diff --git a/config/template.json b/config/template.json index 112004c49..e1e4ea2d3 100644 --- a/config/template.json +++ b/config/template.json @@ -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, diff --git a/module/awaken/awaken.py b/module/awaken/awaken.py index 712424842..240990e1d 100644 --- a/module/awaken/awaken.py +++ b/module/awaken/awaken.py @@ -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) diff --git a/module/config/argument/args.json b/module/config/argument/args.json index e62b90f71..c8eb0ab74 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -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": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index c898e3528..6bbfd5ff8 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -449,6 +449,10 @@ Reward: CollectExp: true CollectMission: true CollectWeeklyMission: true +Awaken: + LevelCap: + value: level120 + option: [ level120, level125 ] GeneralShop: UseGems: false Refresh: false diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index 5e4d0f9b9..faa9b571b 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -54,7 +54,8 @@ "Dorm", "Meowfficer", "Guild", - "Reward" + "Reward", + "Awaken" ] }, "DailyMission": { diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index 74e40c088..95457737f 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -215,6 +215,9 @@ Reward: Reward: - Scheduler - Reward + Awaken: + - Scheduler + - Awaken # ==================== DailyMission ==================== diff --git a/module/config/config_generated.py b/module/config/config_generated.py index f5e2ec226..635e1dfb1 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -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 diff --git a/module/config/config_manual.py b/module/config/config_manual.py index b1b0ab466..bba88a081 100644 --- a/module/config/config_manual.py +++ b/module/config/config_manual.py @@ -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 diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 484571696..1de3eecc9 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -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", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 118882807..9153d1cac 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -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", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 4b191f233..c5cf3c0e9 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -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": "军火商(通用商店)", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 56035f02b..1490dfe88 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -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": "軍火商 (通用商店)",