From b9edeacf037b7fc4d1a0d66dc94af622715577c4 Mon Sep 17 00:00:00 2001 From: moesnow <11678347+moesnow@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:50:26 +0800 Subject: [PATCH] Feat: auto ornament --- app/setting_interface.py | 4 ++-- assets/config/config.example.yaml | 2 +- assets/docs/Changelog.md | 1 + tasks/power/power.py | 3 +-- tasks/weekly/universe.py | 19 ++++++++++++++++++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/setting_interface.py b/app/setting_interface.py index e7b0aebe..6f6ec465 100644 --- a/app/setting_interface.py +++ b/app/setting_interface.py @@ -378,8 +378,8 @@ def __initCard(self): ) self.universeBonusEnableCard = SwitchSettingCard1( FIF.IOT, - self.tr('领取沉浸奖励'), - None, + self.tr('领取沉浸奖励/执行饰品提取'), + "类别为“模拟宇宙”时,自动领取沉浸奖励。类别为“差分宇宙”时,在领取积分奖励后自动执行饰品提取消耗沉浸器。", "universe_bonus_enable" ) self.universeFrequencyCard = ComboBoxSettingCard2( diff --git a/assets/config/config.example.yaml b/assets/config/config.example.yaml index a9cea0eb..307c3681 100644 --- a/assets/config/config.example.yaml +++ b/assets/config/config.example.yaml @@ -128,7 +128,7 @@ universe_enable: false # 是否启用模拟宇宙功能。true 开启,false universe_operation_mode: exe # 模拟宇宙运行方式,可选 "源码"(source)或 "集成"(exe)。 universe_category: divergent # 模拟宇宙类型,可选 "差分宇宙"(divergent)或 "模拟宇宙"(universe)。 universe_disable_gpu: false # 是否禁用GPU加速。true 开启,false 关闭。 -universe_bonus_enable: false # 是否领取沉浸奖励。true 开启,false 关闭。 +universe_bonus_enable: false # 类别为“模拟宇宙”时,自动领取沉浸奖励。类别为“差分宇宙”时,在领取积分奖励后自动执行饰品提取消耗沉浸器。true 开启,false 关闭。 universe_frequency: weekly # 模拟宇宙运行频率,可选 "每周"(weekly)或 "每天"(daily)。 universe_count: 34 # 模拟宇宙运行次数,设置每次启动时尝试运行的次数。 universe_path: .\3rdparty\Auto_Simulated_Universe # 模拟宇宙路径,指向模拟宇宙脚本或程序的位置。 diff --git a/assets/docs/Changelog.md b/assets/docs/Changelog.md index b5c7a81d..dd9086fa 100644 --- a/assets/docs/Changelog.md +++ b/assets/docs/Changelog.md @@ -4,6 +4,7 @@ ### 更新 - 支持 “触屏模式(云游戏移动端 UI)” 启动游戏(工具箱) +- “领取沉浸奖励” 选项更改为 “领取沉浸奖励/执行饰品提取”(领取积分奖励后将自动执行饰品提取) - 修复更换新壁纸 “愿今夜无梦” 后无法进入邮箱 - 修复无法识别并跳过末日幻影快速挑战提示框 [#406](https://github.com/moesnow/March7thAssistant/issues/406) diff --git a/tasks/power/power.py b/tasks/power/power.py index 55686603..49f3cc71 100644 --- a/tasks/power/power.py +++ b/tasks/power/power.py @@ -67,8 +67,7 @@ def process_ornament(instance_type, instance_name, power): screen.change_to("guide3") immersifier_crop = (1623.0 / 1920, 40.0 / 1080, 162.0 / 1920, 52.0 / 1080) - text = auto.get_single_line_text(crop=immersifier_crop, blacklist=[ - '+', '米'], max_retries=3) + text = auto.get_single_line_text(crop=immersifier_crop, blacklist=['+', '米'], max_retries=3) if "/8" not in text: log.error("沉浸器数量识别失败") return diff --git a/tasks/weekly/universe.py b/tasks/weekly/universe.py index 44e0a4f3..9dde6cfe 100644 --- a/tasks/weekly/universe.py +++ b/tasks/weekly/universe.py @@ -11,6 +11,7 @@ import sys import os from module.config import asu_config +from tasks.power.instance import Instance class Universe: @@ -201,9 +202,25 @@ def get_reward(category): auto.click_element("./assets/images/zh_CN/base/click_close.png", "image", 0.8, max_retries=10) time.sleep(1) auto.press_key("esc") - return + if category == "divergent" and cfg.universe_bonus_enable: + Universe.process_ornament() Base.send_notification_with_screenshot(cfg.notify_template['SimulatedUniverseCompleted']) + @staticmethod + def process_ornament(): + screen.change_to("guide3") + + immersifier_crop = (1623.0 / 1920, 40.0 / 1080, 162.0 / 1920, 52.0 / 1080) + text = auto.get_single_line_text(crop=immersifier_crop, blacklist=['+', '米'], max_retries=3) + if "/8" not in text: + log.error("沉浸器数量识别失败") + return + + immersifier_count = int(text.split("/")[0]) + log.info(f"🟣沉浸器: {immersifier_count}/8") + if immersifier_count > 0: + Instance.run("饰品提取", cfg.instance_names["饰品提取"], 40, immersifier_count) + @staticmethod def gui(): if Universe.before_start():