Skip to content

Commit

Permalink
Feat: auto activity
Browse files Browse the repository at this point in the history
  • Loading branch information
moesnow committed Dec 17, 2024
1 parent d114410 commit 7511455
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/setting_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def __initCard(self):
self.activityPlanarFissureEnableCard = SwitchSettingCard1(
FIF.CALORIES,
self.tr('启用位面分裂'),
"存在双倍次数时体力优先「合成沉浸器」",
"存在双倍次数时体力优先「饰品提取」",
"activity_planarfissure_enable"
)

Expand Down
1 change: 1 addition & 0 deletions assets/docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 更新日志

### 更新
- "启用位面分裂"开启后,存在双倍次数时体力优先「饰品提取」
- 支持在图形界面中开关所有的推送方式,并修改对应的配置项
- 优化了“解锁帧率”和“触屏模式”的报错提示(需要将游戏图像质量修改为自定义)
- “启用自动战斗检测”开启后,会在启动游戏前尝试检查并修改对应的注册表值
Expand Down
4 changes: 2 additions & 2 deletions tasks/activity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def __init__(self):
self.gardenofplenty = GardenOfPlenty("花藏繁生", cfg.activity_gardenofplenty_enable, cfg.activity_gardenofplenty_instance_type, cfg.instance_names)
self.realmofthestrange = RealmOfTheStrange("异器盈界", cfg.activity_realmofthestrange_enable, cfg.instance_names)
self.realmofthestrange3 = RealmOfTheStrange("异器盈界300%", cfg.activity_realmofthestrange_enable, cfg.instance_names)
self.planarfissure = PlanarFissure("位面分裂", cfg.activity_planarfissure_enable)
self.planarfissure3 = PlanarFissure("位面分裂300%", cfg.activity_planarfissure_enable)
self.planarfissure = PlanarFissure("位面分裂", cfg.activity_planarfissure_enable, cfg.instance_names)
self.planarfissure3 = PlanarFissure("位面分裂300%", cfg.activity_planarfissure_enable, cfg.instance_names)

self.activity_functions = {
"巡星之礼": self.giftofodyssey.start,
Expand Down
58 changes: 56 additions & 2 deletions tasks/activity/planarfissure.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,64 @@
from tasks.power.power import Power
from .doubleactivity import DoubleActivity
from module.screen import screen
from module.automation import auto
from module.logger import log
from tasks.power.instance import Instance
from tasks.weekly.universe import Universe
import time


class PlanarFissure(DoubleActivity):
def __init__(self, name, enabled, instance_names):
super().__init__(name, enabled)
self.instance_names = instance_names

def _run_instances(self, reward_count):
# 暂未支持自动刷取模拟宇宙领取奖励
Power.merge("immersifier")
if reward_count == 0:
return True

instance_type = "饰品提取"
instance_name = self.instance_names[instance_type]

power = Power.get()
full_runs = power // 40

screen.change_to('guide3')
instance_type_crop = (262.0 / 1920, 289.0 / 1080, 422.0 / 1920, 624.0 / 1080)

auto.click_element(instance_type, "text", crop=instance_type_crop)
# 等待界面完全停止
time.sleep(1)

# 需要判断是否有可用存档
if auto.find_element("无可用存档", "text", crop=(688.0 / 1920, 289.0 / 1080, 972.0 / 1920, 369.0 / 1080), include=True):
# 刷差分宇宙存档
if Universe.start(nums=1, save=False, category="divergent"):
# 验证存档
screen.change_to('guide3')
auto.click_element(instance_type, "text", crop=instance_type_crop)
# 等待界面完全停止
time.sleep(1)
if auto.find_element("无可用存档", "text", crop=(688.0 / 1920, 289.0 / 1080, 972.0 / 1920, 369.0 / 1080), include=True):
log.error("暂无可用存档")
return True
else:
return True

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 True

immersifier_count = int(text.split("/")[0])
log.info(f"🟣沉浸器: {immersifier_count}/8")

count = min(immersifier_count + full_runs, reward_count)

if count > 0:
Instance.run("饰品提取", instance_name, 40, count)

return True

0 comments on commit 7511455

Please sign in to comment.