feat: MAA任务可使用计划表信息
This commit is contained in:
@@ -290,30 +290,33 @@ class MaaUserConfig(ConfigBase):
|
|||||||
"Notify", "CompanyWebHookBotUrl", ""
|
"Notify", "CompanyWebHookBotUrl", ""
|
||||||
)
|
)
|
||||||
|
|
||||||
# def get_plan_info(self) -> Dict[str, Union[str, int]]:
|
def get_plan_info(self) -> Dict[str, Union[str, int]]:
|
||||||
# """获取当前的计划下信息"""
|
"""获取当前的计划下信息"""
|
||||||
|
|
||||||
# if self.get(self.Info_StageMode) == "固定":
|
if self.get("Info", "StageMode") == "固定":
|
||||||
# return {
|
return {
|
||||||
# "MedicineNumb": self.get(self.Info_MedicineNumb),
|
"MedicineNumb": self.get("Info", "MedicineNumb"),
|
||||||
# "SeriesNumb": self.get(self.Info_SeriesNumb),
|
"SeriesNumb": self.get("Info", "SeriesNumb"),
|
||||||
# "Stage": self.get(self.Info_Stage),
|
"Stage": self.get("Info", "Stage"),
|
||||||
# "Stage_1": self.get(self.Info_Stage_1),
|
"Stage_1": self.get("Info", "Stage_1"),
|
||||||
# "Stage_2": self.get(self.Info_Stage_2),
|
"Stage_2": self.get("Info", "Stage_2"),
|
||||||
# "Stage_3": self.get(self.Info_Stage_3),
|
"Stage_3": self.get("Info", "Stage_3"),
|
||||||
# "Stage_Remain": self.get(self.Info_Stage_Remain),
|
"Stage_Remain": self.get("Info", "Stage_Remain"),
|
||||||
# }
|
}
|
||||||
# elif "计划" in self.get(self.Info_StageMode):
|
else:
|
||||||
# plan = Config.plan_dict[self.get(self.Info_StageMode)]["Config"]
|
plan = Config.PlanConfig[uuid.UUID(self.get("Info", "StageMode"))]
|
||||||
# return {
|
if isinstance(plan, MaaPlanConfig):
|
||||||
# "MedicineNumb": plan.get(plan.get_current_info("MedicineNumb")),
|
return {
|
||||||
# "SeriesNumb": plan.get(plan.get_current_info("SeriesNumb")),
|
"MedicineNumb": plan.get_current_info("MedicineNumb").getValue(),
|
||||||
# "Stage": plan.get(plan.get_current_info("Stage")),
|
"SeriesNumb": plan.get_current_info("SeriesNumb").getValue(),
|
||||||
# "Stage_1": plan.get(plan.get_current_info("Stage_1")),
|
"Stage": plan.get_current_info("Stage").getValue(),
|
||||||
# "Stage_2": plan.get(plan.get_current_info("Stage_2")),
|
"Stage_1": plan.get_current_info("Stage_1").getValue(),
|
||||||
# "Stage_3": plan.get(plan.get_current_info("Stage_3")),
|
"Stage_2": plan.get_current_info("Stage_2").getValue(),
|
||||||
# "Stage_Remain": plan.get(plan.get_current_info("Stage_Remain")),
|
"Stage_3": plan.get_current_info("Stage_3").getValue(),
|
||||||
# }
|
"Stage_Remain": plan.get_current_info("Stage_Remain").getValue(),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid plan type")
|
||||||
|
|
||||||
|
|
||||||
class MaaConfig(ConfigBase):
|
class MaaConfig(ConfigBase):
|
||||||
@@ -406,24 +409,27 @@ class MaaPlanConfig(ConfigBase):
|
|||||||
]:
|
]:
|
||||||
setattr(self, f"{group}_{name}", self.config_item_dict[group][name])
|
setattr(self, f"{group}_{name}", self.config_item_dict[group][name])
|
||||||
|
|
||||||
# def get_current_info(self, name: str) -> ConfigItem:
|
def get_current_info(self, name: str) -> ConfigItem:
|
||||||
# """获取当前的计划表配置项"""
|
"""获取当前的计划表配置项"""
|
||||||
|
|
||||||
# if self.get(self.Info_Mode) == "ALL":
|
if self.get("Info", "Mode") == "ALL":
|
||||||
|
|
||||||
# return self.config_item_dict["ALL"][name]
|
return self.config_item_dict["ALL"][name]
|
||||||
|
|
||||||
# elif self.get(self.Info_Mode) == "Weekly":
|
elif self.get("Info", "Mode") == "Weekly":
|
||||||
|
|
||||||
# dt = datetime.now()
|
dt = datetime.now()
|
||||||
# if dt.time() < datetime.min.time().replace(hour=4):
|
if dt.time() < datetime.min.time().replace(hour=4):
|
||||||
# dt = dt - timedelta(days=1)
|
dt = dt - timedelta(days=1)
|
||||||
# today = dt.strftime("%A")
|
today = dt.strftime("%A")
|
||||||
|
|
||||||
# if today in self.config_item_dict:
|
if today in self.config_item_dict:
|
||||||
# return self.config_item_dict[today][name]
|
return self.config_item_dict[today][name]
|
||||||
# else:
|
else:
|
||||||
# return self.config_item_dict["ALL"][name]
|
return self.config_item_dict["ALL"][name]
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise ValueError("The mode is invalid.")
|
||||||
|
|
||||||
|
|
||||||
class GeneralUserConfig(ConfigBase):
|
class GeneralUserConfig(ConfigBase):
|
||||||
|
|||||||
@@ -20,17 +20,16 @@
|
|||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import uuid
|
||||||
import asyncio
|
import asyncio
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
import uuid
|
|
||||||
import win32com.client
|
import win32com.client
|
||||||
from fastapi import WebSocket
|
|
||||||
from functools import partial
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from fastapi import WebSocket
|
||||||
|
from datetime import datetime, timedelta
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
from typing import Union, List, Dict, Optional
|
from typing import List, Dict, Optional
|
||||||
|
|
||||||
from app.core import Broadcast, Config, MaaConfig, MaaUserConfig
|
from app.core import Broadcast, Config, MaaConfig, MaaUserConfig
|
||||||
from app.models.schema import TaskMessage
|
from app.models.schema import TaskMessage
|
||||||
@@ -1458,16 +1457,25 @@ class MaaManager:
|
|||||||
data["Configurations"]["Default"]["TaskQueue.Order.AutoRoguelike"] = "6"
|
data["Configurations"]["Default"]["TaskQueue.Order.AutoRoguelike"] = "6"
|
||||||
data["Configurations"]["Default"]["TaskQueue.Order.Reclamation"] = "7"
|
data["Configurations"]["Default"]["TaskQueue.Order.Reclamation"] = "7"
|
||||||
|
|
||||||
|
if isinstance(self.cur_user_data, MaaUserConfig):
|
||||||
|
try:
|
||||||
|
plan_data = self.cur_user_data.get_plan_info()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
f"获取用户 {self.user_list[self.index]['user_id']} 的代理计划信息失败: {e}"
|
||||||
|
)
|
||||||
|
plan_data = {}
|
||||||
|
else:
|
||||||
|
plan_data = {}
|
||||||
|
|
||||||
data["Configurations"]["Default"]["MainFunction.UseMedicine"] = (
|
data["Configurations"]["Default"]["MainFunction.UseMedicine"] = (
|
||||||
"False"
|
"False" if plan_data.get("MedicineNumb", 0) == 0 else "True"
|
||||||
if self.cur_user_data.get("Info", "MedicineNumb") == 0
|
|
||||||
else "True"
|
|
||||||
) # 吃理智药
|
) # 吃理智药
|
||||||
data["Configurations"]["Default"]["MainFunction.UseMedicine.Quantity"] = (
|
data["Configurations"]["Default"]["MainFunction.UseMedicine.Quantity"] = (
|
||||||
str(self.cur_user_data.get("Info", "MedicineNumb"))
|
str(plan_data.get("MedicineNumb", 0))
|
||||||
) # 吃理智药数量
|
) # 吃理智药数量
|
||||||
data["Configurations"]["Default"]["MainFunction.Series.Quantity"] = (
|
data["Configurations"]["Default"]["MainFunction.Series.Quantity"] = (
|
||||||
self.cur_user_data.get("Info", "SeriesNumb")
|
plan_data.get("SeriesNumb", "0")
|
||||||
) # 连战次数
|
) # 连战次数
|
||||||
|
|
||||||
if mode == "Annihilation":
|
if mode == "Annihilation":
|
||||||
@@ -1515,37 +1523,33 @@ class MaaManager:
|
|||||||
elif mode == "Routine":
|
elif mode == "Routine":
|
||||||
|
|
||||||
data["Configurations"]["Default"]["MainFunction.Stage1"] = (
|
data["Configurations"]["Default"]["MainFunction.Stage1"] = (
|
||||||
self.cur_user_data.get("Info", "Stage")
|
plan_data.get("Stage") if plan_data.get("Stage", "-") != "-" else ""
|
||||||
if self.cur_user_data.get("Info", "Stage") != "-"
|
|
||||||
else ""
|
|
||||||
) # 主关卡
|
) # 主关卡
|
||||||
data["Configurations"]["Default"]["MainFunction.Stage2"] = (
|
data["Configurations"]["Default"]["MainFunction.Stage2"] = (
|
||||||
self.cur_user_data.get("Info", "Stage_1")
|
plan_data.get("Stage_1")
|
||||||
if self.cur_user_data.get("Info", "Stage_1") != "-"
|
if plan_data.get("Stage_1", "-") != "-"
|
||||||
else ""
|
else ""
|
||||||
) # 备选关卡1
|
) # 备选关卡1
|
||||||
data["Configurations"]["Default"]["MainFunction.Stage3"] = (
|
data["Configurations"]["Default"]["MainFunction.Stage3"] = (
|
||||||
self.cur_user_data.get("Info", "Stage_2")
|
plan_data.get("Stage_2")
|
||||||
if self.cur_user_data.get("Info", "Stage_2") != "-"
|
if plan_data.get("Stage_2", "-") != "-"
|
||||||
else ""
|
else ""
|
||||||
) # 备选关卡2
|
) # 备选关卡2
|
||||||
data["Configurations"]["Default"]["MainFunction.Stage4"] = (
|
data["Configurations"]["Default"]["MainFunction.Stage4"] = (
|
||||||
self.cur_user_data.get("Info", "Stage_3")
|
plan_data.get("Stage_3")
|
||||||
if self.cur_user_data.get("Info", "Stage_3") != "-"
|
if plan_data.get("Stage_3", "-") != "-"
|
||||||
else ""
|
else ""
|
||||||
) # 备选关卡3
|
) # 备选关卡3
|
||||||
data["Configurations"]["Default"]["Fight.RemainingSanityStage"] = (
|
data["Configurations"]["Default"]["Fight.RemainingSanityStage"] = (
|
||||||
self.cur_user_data.get("Info", "Stage_Remain")
|
plan_data.get("Stage_Remain")
|
||||||
if self.cur_user_data.get("Info", "Stage_Remain") != "-"
|
if plan_data.get("Stage_Remain", "-") != "-"
|
||||||
else ""
|
else ""
|
||||||
) # 剩余理智关卡
|
) # 剩余理智关卡
|
||||||
data["Configurations"]["Default"][
|
data["Configurations"]["Default"][
|
||||||
"GUI.UseAlternateStage"
|
"GUI.UseAlternateStage"
|
||||||
] = "True" # 备选关卡
|
] = "True" # 备选关卡
|
||||||
data["Configurations"]["Default"]["Fight.UseRemainingSanityStage"] = (
|
data["Configurations"]["Default"]["Fight.UseRemainingSanityStage"] = (
|
||||||
"True"
|
"True" if plan_data.get("Stage_Remain", "-") != "-" else "False"
|
||||||
if self.cur_user_data.get("Info", "Stage_Remain") != "-"
|
|
||||||
else "False"
|
|
||||||
) # 使用剩余理智
|
) # 使用剩余理智
|
||||||
|
|
||||||
if self.cur_user_data.get("Info", "Mode") == "简洁":
|
if self.cur_user_data.get("Info", "Mode") == "简洁":
|
||||||
|
|||||||
Reference in New Issue
Block a user