From 9e4550aff16ccc392ef72405cad1594d1d20102d Mon Sep 17 00:00:00 2001 From: nEEtdo0d Date: Fri, 29 Oct 2021 16:10:49 -0400 Subject: [PATCH] Fix: Split shop task based on check frequency; general shop changes inventory 3 times daily and other shops change inventory 1 time daily --- alas.py | 8 +++- config/template.json | 14 ++++++- module/config/argument/args.json | 32 +++++++++++++++- module/config/argument/menu.json | 3 +- module/config/argument/override.yaml | 7 +++- module/config/argument/task.yaml | 4 +- module/config/config_manual.py | 2 +- module/config/i18n/en-US.json | 8 +++- module/config/i18n/ja-JP.json | 10 +++-- module/config/i18n/zh-CN.json | 6 ++- module/config/i18n/zh-TW.json | 10 +++-- module/shop/shop_reward.py | 57 ++++++++++++++-------------- 12 files changed, 114 insertions(+), 47 deletions(-) diff --git a/alas.py b/alas.py index bdac5843b..8ef498d45 100644 --- a/alas.py +++ b/alas.py @@ -135,9 +135,13 @@ class AzurLaneAutoScript: from module.reward.reward import Reward Reward(config=self.config, device=self.device).run() - def shop(self): + def shop_frequent(self): from module.shop.shop_reward import RewardShop - RewardShop(config=self.config, device=self.device).run() + RewardShop(config=self.config, device=self.device).run_frequent() + + def shop_once(self): + from module.shop.shop_reward import RewardShop + RewardShop(config=self.config, device=self.device).run_once() def shipyard(self): from module.shipyard.shipyard_reward import RewardShipyard diff --git a/config/template.json b/config/template.json index d7f785b04..4dfce43dc 100644 --- a/config/template.json +++ b/config/template.json @@ -677,11 +677,11 @@ "CollectMission": true } }, - "Shop": { + "ShopFrequent": { "Scheduler": { "Enable": false, "NextRun": "2020-01-01 00:00:00", - "Command": "Shop", + "Command": "ShopFrequent", "SuccessInterval": 30, "FailureInterval": 30, "ServerUpdate": "00:00, 12:00, 18:00" @@ -690,6 +690,16 @@ "UseGems": false, "Refresh": false, "Filter": "BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2\n> Cube\n> FoodT6 > FoodT5" + } + }, + "ShopOnce": { + "Scheduler": { + "Enable": false, + "NextRun": "2020-01-01 00:00:00", + "Command": "ShopOnce", + "SuccessInterval": 30, + "FailureInterval": 30, + "ServerUpdate": "00:00" }, "GuildShop": { "Refresh": true, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index fb9bbdd3c..252a84392 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -3079,7 +3079,7 @@ } } }, - "Shop": { + "ShopFrequent": { "Scheduler": { "Enable": { "type": "checkbox", @@ -3091,7 +3091,7 @@ }, "Command": { "type": "disable", - "value": "Shop" + "value": "ShopFrequent" }, "SuccessInterval": { "type": "disable", @@ -3119,6 +3119,34 @@ "type": "textarea", "value": "BookRedT3 > BookYellowT3 > BookBlueT3 > BookRedT2\n> Cube\n> FoodT6 > FoodT5" } + } + }, + "ShopOnce": { + "Scheduler": { + "Enable": { + "type": "checkbox", + "value": false + }, + "NextRun": { + "type": "input", + "value": "2020-01-01 00:00:00" + }, + "Command": { + "type": "disable", + "value": "ShopOnce" + }, + "SuccessInterval": { + "type": "disable", + "value": 30 + }, + "FailureInterval": { + "type": "disable", + "value": 30 + }, + "ServerUpdate": { + "type": "disable", + "value": "00:00" + } }, "GuildShop": { "Refresh": { diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index ea3ff1815..7ae4ba68d 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -23,7 +23,8 @@ "Meowfficer", "Guild", "Reward", - "Shop", + "ShopFrequent", + "ShopOnce", "Shipyard", "Gacha", "DataKey" diff --git a/module/config/argument/override.yaml b/module/config/argument/override.yaml index e80080822..0e9376bd2 100644 --- a/module/config/argument/override.yaml +++ b/module/config/argument/override.yaml @@ -150,11 +150,16 @@ Reward: SuccessInterval: 60-120 FailureInterval: 60-120 ServerUpdate: 00:00 -Shop: +ShopFrequent: Scheduler: SuccessInterval: 30 FailureInterval: 30 ServerUpdate: 00:00, 12:00, 18:00 +ShopOnce: + Scheduler: + SuccessInterval: 30 + FailureInterval: 30 + ServerUpdate: 00:00 Shipyard: Scheduler: SuccessInterval: 30 diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index 37cb986f1..f2494f7c6 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -104,9 +104,11 @@ Guild: Reward: - Scheduler - Reward -Shop: +ShopFrequent: - Scheduler - GeneralShop +ShopOnce: + - Scheduler - GuildShop - MedalShop - MeritShop diff --git a/module/config/config_manual.py b/module/config/config_manual.py index 0c06b8777..97ed0b041 100644 --- a/module/config/config_manual.py +++ b/module/config/config_manual.py @@ -7,7 +7,7 @@ class ManualConfig: SCHEDULER_PRIORITY = """ Restart > Research > Commission > Tactical > Dorm > Meowfficer > Guild > Reward - > Gacha > Shop > Shipyard > DataKey + > Gacha > ShopFrequent > ShopOnce > Shipyard > DataKey > OpsiExplore > OpsiObscure > Exercise > Daily > Hard > OpsiAshAssist > Sos > EventSp > EventAb > RaidDaily > WarArchives diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 712ad528e..81f1bc9e4 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -102,8 +102,12 @@ "name": "Reward", "help": "" }, - "Shop": { - "name": "Shop", + "ShopFrequent": { + "name": "ShopFrequent", + "help": "" + }, + "ShopOnce": { + "name": "ShopOnce", "help": "" }, "Shipyard": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 150567102..134ce771c 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -102,9 +102,13 @@ "name": "Task.Reward.name", "help": "Task.Reward.help" }, - "Shop": { - "name": "Task.Shop.name", - "help": "Task.Shop.help" + "ShopFrequent": { + "name": "Task.ShopFrequent.name", + "help": "Task.ShopFrequent.help" + }, + "ShopOnce": { + "name": "Task.ShopOnce.name", + "help": "Task.ShopOnce.help" }, "Shipyard": { "name": "Task.Shipyard.name", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 3ac0b681e..98916f022 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -102,10 +102,14 @@ "name": "收获", "help": "" }, - "Shop": { + "ShopFrequent": { "name": "商店购买", "help": "" }, + "ShopOnce": { + "name": "Task.ShopOnce.name", + "help": "" + }, "Shipyard": { "name": "开发船坞", "help": "" diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 2a57e1af5..52384fee3 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -102,9 +102,13 @@ "name": "Task.Reward.name", "help": "Task.Reward.help" }, - "Shop": { - "name": "Task.Shop.name", - "help": "Task.Shop.help" + "ShopFrequent": { + "name": "Task.ShopFrequent.name", + "help": "Task.ShopFrequent.help" + }, + "ShopOnce": { + "name": "Task.ShopOnce.name", + "help": "Task.ShopOnce.help" }, "Shipyard": { "name": "Task.Shipyard.name", diff --git a/module/shop/shop_reward.py b/module/shop/shop_reward.py index d9ab2d5f9..a8a08e2fb 100644 --- a/module/shop/shop_reward.py +++ b/module/shop/shop_reward.py @@ -46,7 +46,7 @@ class RewardShop(GachaUI, ShopUI, GeneralShop, GuildShop, MedalShop, MeritShop): continue break - def run(self): + def run_frequent(self): self.ui_goto_shop() if self._shop_visit('general'): @@ -54,31 +54,32 @@ class RewardShop(GachaUI, ShopUI, GeneralShop, GuildShop, MedalShop, MeritShop): if self.shop_bottom_navbar_ensure(left=5): self._shop_repeat(shop_type='general') - if self.config.Scheduler_NextRun.hour == get_server_last_update('00:00').hour: - if self._shop_visit('merit'): - logger.hr('Merit shop', level=1) - if self.shop_bottom_navbar_ensure(left=4): - self._shop_repeat(shop_type='merit') - - if self._shop_visit('guild'): - logger.hr('Guild shop', level=1) - if self.shop_bottom_navbar_ensure(left=1): - self._shop_repeat(shop_type='guild') - - if self._shop_visit('medal'): - logger.hr('Medal shop', level=1) - self.ui_goto_gacha() - if self.gacha_side_navbar_ensure(bottom=2): - for _ in [1, 2]: - if self.gacha_bottom_navbar_ensure(left=_, is_build=False): - self.shop_buy(shop_type='medal', - selection=self.config.MedalShop_Filter) - else: - logger.warning('Failed to arrive at expected ' - 'build interface for medal exchanges, ' - f'left={_}, try again next time') - else: - logger.info(f'Next run {self.config.Scheduler_NextRun} is not at 00:00 (server time), ' - f'skip merit, guild and medal shops') - self.config.task_delay(server_update=True) + + def run_once(self): + self.ui_goto_shop() + + if self._shop_visit('merit'): + logger.hr('Merit shop', level=1) + if self.shop_bottom_navbar_ensure(left=4): + self._shop_repeat(shop_type='merit') + + if self._shop_visit('guild'): + logger.hr('Guild shop', level=1) + if self.shop_bottom_navbar_ensure(left=1): + self._shop_repeat(shop_type='guild') + + if self._shop_visit('medal'): + logger.hr('Medal shop', level=1) + self.ui_goto_gacha() + if self.gacha_side_navbar_ensure(bottom=2): + for _ in [1, 2]: + if self.gacha_bottom_navbar_ensure(left=_, is_build=False): + self.shop_buy(shop_type='medal', + selection=self.config.MedalShop_Filter) + else: + logger.warning('Failed to arrive at expected ' + 'build interface for medal exchanges, ' + f'left={_}, try again next time') + + self.config.task_delay(server_update=True) \ No newline at end of file