diff --git a/src/MaaCore/Task/Interface/CopilotTask.cpp b/src/MaaCore/Task/Interface/CopilotTask.cpp index 9f045a07ba..dfcaebf751 100644 --- a/src/MaaCore/Task/Interface/CopilotTask.cpp +++ b/src/MaaCore/Task/Interface/CopilotTask.cpp @@ -92,6 +92,9 @@ bool asst::CopilotTask::set_params(const json::value& params) return false; } + // 选择指定编队 + m_formation_task_ptr->set_select_formation(params.get("select_formation", 3)); + // 自动补信赖 m_formation_task_ptr->set_add_trust(params.get("add_trust", false)); m_formation_task_ptr->set_add_user_additional(params.get("add_user_additional", false)); diff --git a/src/MaaCore/Task/Interface/MallTask.cpp b/src/MaaCore/Task/Interface/MallTask.cpp index bb4a3ca446..54cc768f0a 100644 --- a/src/MaaCore/Task/Interface/MallTask.cpp +++ b/src/MaaCore/Task/Interface/MallTask.cpp @@ -91,6 +91,12 @@ bool asst::MallTask::set_params(const json::value& params) if (!m_running) { bool credit_fight = params.get("credit_fight", false); m_credit_fight_task_ptr->set_enable(credit_fight); + if (credit_fight) { + int select_formation = params.get("select_formation", 4); + Log.trace("selecting formation", select_formation); + select_formation--; + m_credit_fight_task_ptr->set_select_formation(select_formation); + } } return true; diff --git a/src/MaaCore/Task/Miscellaneous/CreditFightTask.cpp b/src/MaaCore/Task/Miscellaneous/CreditFightTask.cpp index a1c32127b7..bf3c5a0c6a 100644 --- a/src/MaaCore/Task/Miscellaneous/CreditFightTask.cpp +++ b/src/MaaCore/Task/Miscellaneous/CreditFightTask.cpp @@ -1,15 +1,11 @@ #include "CreditFightTask.h" -#include - #include "Config/TaskData.h" #include "Task/AbstractTask.h" #include "Task/Fight/StageNavigationTask.h" -#include "Task/Interface/CopilotTask.h" #include "Task/ProcessTask.h" #include "Utils/Ranges.hpp" -#include "Utils/WorkingDir.hpp" asst::CreditFightTask::CreditFightTask(const AsstCallback& callback, Assistant* inst, std::string_view task_chain) : PackageTask(callback, inst, task_chain) @@ -18,21 +14,21 @@ asst::CreditFightTask::CreditFightTask(const AsstCallback& callback, Assistant* auto stage_navigation_task_ptr = std::make_shared(m_callback, m_inst, task_chain); auto stop_task_ptr = std::make_shared(m_callback, m_inst, task_chain); auto not_use_prts_task_ptr = std::make_shared(m_callback, m_inst, task_chain); - auto copilot_task_ptr = std::make_shared(m_callback, m_inst); + m_copilot_task_ptr = std::make_shared(m_callback, m_inst); // 开始 start_up_task_ptr->set_tasks({ "StageBegin" }).set_times_limit("GoLastBattle", 0); // 自动战斗 - json::value copilot_params = json::object { + m_copilot_params = json::object { { "filename", utils::path_to_utf8_string(ResDir.get() / "copilot" / "OF-1_credit_fight.json") }, { "formation", true }, { "support_unit_name", "_RANDOM_" }, }; - copilot_task_ptr->set_params(copilot_params); + m_copilot_task_ptr->set_params(m_copilot_params); // 关卡导航 - stage_navigation_task_ptr->set_stage_name(copilot_task_ptr->get_stage_name()); + stage_navigation_task_ptr->set_stage_name(m_copilot_task_ptr->get_stage_name()); // 不使用代理指挥 not_use_prts_task_ptr->set_tasks({ "NotUsePrts", "Stop" }); @@ -43,6 +39,12 @@ asst::CreditFightTask::CreditFightTask(const AsstCallback& callback, Assistant* m_subtasks.emplace_back(start_up_task_ptr); m_subtasks.emplace_back(stage_navigation_task_ptr); m_subtasks.emplace_back(not_use_prts_task_ptr); - m_subtasks.emplace_back(copilot_task_ptr); + m_subtasks.emplace_back(m_copilot_task_ptr); m_subtasks.emplace_back(stop_task_ptr); } + +void asst::CreditFightTask::set_select_formation(int index) +{ + m_copilot_params["select_formation"] = index; + m_copilot_task_ptr->set_params(m_copilot_params); +} diff --git a/src/MaaCore/Task/Miscellaneous/CreditFightTask.h b/src/MaaCore/Task/Miscellaneous/CreditFightTask.h index bc4715e84d..670f85bd3f 100644 --- a/src/MaaCore/Task/Miscellaneous/CreditFightTask.h +++ b/src/MaaCore/Task/Miscellaneous/CreditFightTask.h @@ -2,6 +2,10 @@ #include "Task/PackageTask.h" +#include "Task/Interface/CopilotTask.h" +#include "Utils/WorkingDir.hpp" + +#include #include namespace asst @@ -13,5 +17,14 @@ namespace asst CreditFightTask(const AsstCallback& callback, Assistant* inst, std::string_view task_chain); virtual ~CreditFightTask() override = default; + + void set_select_formation(int index); + private: + std::shared_ptr m_copilot_task_ptr = nullptr; + json::value m_copilot_params = json::object { + { "filename", utils::path_to_utf8_string(ResDir.get() / "copilot" / "OF-1_credit_fight.json") }, + { "formation", true }, + { "support_unit_name", "_RANDOM_" }, + }; }; } // namespace asst diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 97d57368e3..b31c2f518e 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -114,6 +114,7 @@ namespace MaaWpfGui.Constants public const string LastCreditFightTaskTime = "Visit.LastCreditFightTaskTime"; public const string CreditFightTaskEnabled = "Visit.CreditFightTaskEnabled"; + public const string CreditFightSelectFormation = "Visit.CreditFightSelectFormation"; public const string RecruitMaxTimes = "AutoRecruit.MaxTimes"; public const string RefreshLevel3 = "AutoRecruit.RefreshLevel3"; @@ -138,6 +139,7 @@ namespace MaaWpfGui.Constants public const string CopilotUserAdditional = "Copilot.UserAdditional"; public const string CopilotLoopTimes = "Copilot.LoopTimes"; public const string CopilotTaskList = "Copilot.CopilotTaskList"; + public const string CopilotSelectFormation = "Copilot.SelectFormation"; public const string UpdateProxy = "VersionUpdate.Proxy"; public const string VersionType = "VersionUpdate.VersionType"; diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index f979086c85..16ebf070b8 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1673,16 +1673,18 @@ namespace MaaWpfGui.Main /// 领取信用及商店购物。 /// /// 是否信用战斗。 + /// 信用战斗选择编队 /// 是否购物。 /// 优先购买列表。 /// 黑名单列表。 /// 是否在信用溢出时无视黑名单 /// 是否成功。 - public bool AsstAppendMall(bool creditFight, bool withShopping, string[] firstList, string[] blacklist, bool forceShoppingIfCreditFull) + public bool AsstAppendMall(bool creditFight, int selectFormation, bool withShopping, string[] firstList, string[] blacklist, bool forceShoppingIfCreditFull) { var taskParams = new JObject { ["credit_fight"] = creditFight, + ["select_formation"] = selectFormation, ["shopping"] = withShopping, ["buy_first"] = new JArray { firstList }, ["blacklist"] = new JArray { blacklist }, diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 9845ea9c0f..39a9b5655e 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -614,6 +614,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla When selecting Tags always select three Tags Insufficient operators Stage recognition error + Use formation Start formation Selection of operator: Current step: {0} {1} diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index ebf6d012e7..9cadf5136c 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -614,6 +614,7 @@ Bilibili: ログイン インターフェイスに表示されるアカウント タグを選択すると、常に 3 つのタグが選択されます 利用可能なオペレーターが不足しています ステージ認識エラー + 使用編成 編成開始 オペレーターを選択: 現在の手順: {0} {1} diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 74906f3d77..b1d4031c69 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -614,6 +614,7 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산) 태그를 선택할 때 항상 태그 3개를 선택하세요. 오퍼레이터 부족 스테이지 인식 오류 + 사용 형성 편성 시작 오퍼레이터를 선택: 현재 단계: {0} {1} diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 7234588e69..c88606b24e 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -614,6 +614,7 @@ 选择 Tags 时总是选择三个 Tag 可用干员不足 关卡识别错误 + 使用编队 开始编队 选择干员: 当前步骤: {0} {1} diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index c4a63dd3b8..07cbe7cc9a 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -614,6 +614,7 @@ 可用幹員不足 選擇 Tags 時總是選擇三個 Tag 關卡辨識錯誤 + 使用編隊 開始編隊 選擇幹員: 當前步驟: {0} {1} diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index dadd1ffc73..244e340138 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -1999,6 +1999,21 @@ namespace MaaWpfGui.ViewModels.UI } } + private int _creditFightSelectFormation = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.CreditFightSelectFormation, "4")); + + /// + /// Gets or sets a value indicating which formation will be select in credit fight. + /// + public int CreditFightSelectFormation + { + get => _creditFightSelectFormation; + set + { + SetAndNotify(ref _creditFightSelectFormation, value); + ConfigurationHelper.SetValue(ConfigurationKeys.CreditFightSelectFormation, value.ToString()); + } + } + /* 信用商店设置 */ private bool _creditShopping = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CreditShopping, bool.TrueString)); diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index 6fab4c32ba..9a16f5472a 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -1242,6 +1242,7 @@ namespace MaaWpfGui.ViewModels.UI return Instances.AsstProxy.AsstAppendMall( !string.IsNullOrEmpty(this.Stage) && Instances.SettingsViewModel.CreditFightTaskEnabled, + Instances.SettingsViewModel.CreditFightSelectFormation, Instances.SettingsViewModel.CreditShopping, buyFirst, blackList, diff --git a/src/MaaWpfGui/Views/UserControl/MallSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/MallSettingsUserControl.xaml index eb04551bc7..127f1ef420 100644 --- a/src/MaaWpfGui/Views/UserControl/MallSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/MallSettingsUserControl.xaml @@ -40,6 +40,28 @@ Text="{DynamicResource CreditFight}" TextWrapping="Wrap" /> + + + + + + + +