diff --git a/src/MaaCore/Task/Fight/FightTimesTaskPlugin.cpp b/src/MaaCore/Task/Fight/FightTimesTaskPlugin.cpp index c1a15bb594..6cedcc4878 100644 --- a/src/MaaCore/Task/Fight/FightTimesTaskPlugin.cpp +++ b/src/MaaCore/Task/Fight/FightTimesTaskPlugin.cpp @@ -33,7 +33,7 @@ bool asst::FightTimesTaskPlugin::_run() return false; } } - ProcessTask(*this, { "FightSeries-List-1" }).run(); + ProcessTask(*this, { "FightSeries-List-" + std::to_string(m_series) }).run(); inited = true; return true; diff --git a/src/MaaCore/Task/Fight/FightTimesTaskPlugin.h b/src/MaaCore/Task/Fight/FightTimesTaskPlugin.h index 42dd0f63fb..ddb0829dd3 100644 --- a/src/MaaCore/Task/Fight/FightTimesTaskPlugin.h +++ b/src/MaaCore/Task/Fight/FightTimesTaskPlugin.h @@ -9,11 +9,13 @@ namespace asst virtual ~FightTimesTaskPlugin() override = default; virtual bool verify(AsstMsg msg, const json::value& details) const override; + void set_series(int series) { m_series = series; } protected: virtual bool _run() override; private: bool inited = false; // 是否成功初始化为1次,初始化后后续不再检测 (实现调整次数后移除此变量 + int m_series = 1; // 连续战斗次数 }; } diff --git a/src/MaaCore/Task/Interface/FightTask.cpp b/src/MaaCore/Task/Interface/FightTask.cpp index 1f33e4c0b7..3ae0138946 100644 --- a/src/MaaCore/Task/Interface/FightTask.cpp +++ b/src/MaaCore/Task/Interface/FightTask.cpp @@ -51,7 +51,7 @@ asst::FightTask::FightTask(const AsstCallback& callback, Assistant* inst) m_dr_grandet_task_plugin_ptr = m_fight_task_ptr->register_plugin(); m_dr_grandet_task_plugin_ptr->set_enable(false); m_fight_task_ptr->register_plugin()->set_retry_times(3); - m_fight_task_ptr->register_plugin(); + m_fight_times_task_plugin_prt = m_fight_task_ptr->register_plugin(); m_medicine_plugin = m_fight_task_ptr->register_plugin(); m_subtasks.emplace_back(m_start_up_task_ptr); @@ -69,6 +69,11 @@ bool asst::FightTask::set_params(const json::value& params) const int expiring_medicine = params.get("expiring_medicine", 0); const int stone = params.get("stone", 0); const int times = params.get("times", INT_MAX); + const int series = params.get("series", 1); + if (series < 1 || series > 6) { + Log.error("Invalid series"); + return false; + } bool enable_penguin = params.get("report_to_penguin", false); bool enable_yituliu = params.get("report_to_yituliu", false); std::string penguin_id = params.get("penguin_id", ""); @@ -121,6 +126,7 @@ bool asst::FightTask::set_params(const json::value& params) .set_times_limit("StoneConfirm", stone) .set_times_limit("StartButton1", times) .set_times_limit("StartButton2", times); + m_fight_times_task_plugin_prt->set_series(series); m_medicine_plugin->set_count(medicine); m_medicine_plugin->set_use_expiring(expiring_medicine != 0); m_medicine_plugin->set_dr_grandet(is_dr_grandet); diff --git a/src/MaaCore/Task/Interface/FightTask.h b/src/MaaCore/Task/Interface/FightTask.h index 8de81bbb5a..e9b59a0681 100644 --- a/src/MaaCore/Task/Interface/FightTask.h +++ b/src/MaaCore/Task/Interface/FightTask.h @@ -5,6 +5,7 @@ namespace asst { + class FightTimesTaskPlugin; class ProcessTask; class StageDropsTaskPlugin; class StageNavigationTask; @@ -26,6 +27,7 @@ namespace asst std::shared_ptr m_start_up_task_ptr = nullptr; std::shared_ptr m_stage_navigation_task_ptr = nullptr; std::shared_ptr m_fight_task_ptr = nullptr; + std::shared_ptr m_fight_times_task_plugin_prt = nullptr; std::shared_ptr m_medicine_plugin = nullptr; std::shared_ptr m_stage_drops_plugin_ptr = nullptr; std::shared_ptr m_dr_grandet_task_plugin_ptr = nullptr; diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 3e0a0b7e22..c6b562bfa3 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -176,6 +176,7 @@ namespace MaaWpfGui.Constants public const string UseStoneQuantity = "MainFunction.UseStone.Quantity"; public const string TimesLimited = "MainFunction.TimesLimited"; public const string TimesLimitedQuantity = "MainFunction.TimesLimited.Quantity"; + public const string SeriesQuantity = "MainFunction.Series.Quantity"; public const string DropsEnable = "MainFunction.Drops.Enable"; public const string DropsItemId = "MainFunction.Drops.ItemId"; public const string DropsItemName = "MainFunction.Drops.ItemName"; diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 5451f9f91d..860af40057 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -1615,8 +1615,15 @@ namespace MaaWpfGui.Main private readonly Dictionary _latestTaskId = new(); - private static JObject SerializeFightTaskParams(string stage, int maxMedicine, int maxStone, int maxTimes, - string dropsItemId, int dropsItemQuantity, bool isMainFight = true) + private static JObject SerializeFightTaskParams( + string stage, + int maxMedicine, + int maxStone, + int maxTimes, + int series, + string dropsItemId, + int dropsItemQuantity, + bool isMainFight = true) { var taskParams = new JObject { @@ -1624,6 +1631,7 @@ namespace MaaWpfGui.Main ["medicine"] = maxMedicine, ["stone"] = maxStone, ["times"] = maxTimes, + ["series"] = series, ["report_to_penguin"] = Instances.SettingsViewModel.EnablePenguin, ["report_to_yituliu"] = Instances.SettingsViewModel.EnableYituliu, }; @@ -1650,13 +1658,14 @@ namespace MaaWpfGui.Main /// 最大使用理智药数量。 /// 最大吃石头数量。 /// 指定次数。 + /// 连战次数。 /// 指定掉落 ID。 /// 指定掉落数量。 /// 是否是主任务,决定c#侧是否记录任务id /// 是否成功。 - public bool AsstAppendFight(string stage, int maxMedicine, int maxStone, int maxTimes, string dropsItemId, int dropsItemQuantity, bool isMainFight = true) + public bool AsstAppendFight(string stage, int maxMedicine, int maxStone, int maxTimes, int series, string dropsItemId, int dropsItemQuantity, bool isMainFight = true) { - var taskParams = SerializeFightTaskParams(stage, maxMedicine, maxStone, maxTimes, dropsItemId, dropsItemQuantity, isMainFight); + var taskParams = SerializeFightTaskParams(stage, maxMedicine, maxStone, maxTimes, series, dropsItemId, dropsItemQuantity, isMainFight); AsstTaskId id = AsstAppendTaskWithEncoding("Fight", taskParams); if (isMainFight) { @@ -1677,11 +1686,12 @@ namespace MaaWpfGui.Main /// 最大使用理智药数量。 /// 最大吃石头数量。 /// 指定次数。 + /// 连战次数。 /// 指定掉落 ID。 /// 指定掉落数量。 /// 是否是主任务,决定c#侧是否记录任务id /// 是否成功。 - public bool AsstSetFightTaskParams(string stage, int maxMedicine, int maxStone, int maxTimes, string dropsItemId, int dropsItemQuantity, bool isMainFight = true) + public bool AsstSetFightTaskParams(string stage, int maxMedicine, int maxStone, int maxTimes, int series, string dropsItemId, int dropsItemQuantity, bool isMainFight = true) { var type = isMainFight ? TaskType.Fight : TaskType.FightRemainingSanity; if (!_latestTaskId.ContainsKey(type)) @@ -1695,7 +1705,7 @@ namespace MaaWpfGui.Main return false; } - var taskParams = SerializeFightTaskParams(stage, maxMedicine, maxStone, maxTimes, dropsItemId, dropsItemQuantity); + var taskParams = SerializeFightTaskParams(stage, maxMedicine, maxStone, maxTimes, series, dropsItemId, dropsItemQuantity); return AsstSetTaskParamsWithEncoding(id, taskParams); } diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 192f28ac38..3e9b6e32db 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -352,6 +352,7 @@ Other client types are not supported Perform Battles Material Quantity + Series Stage Alternative Remaining Sanity diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 374b235670..5fa616b0ea 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -352,6 +352,7 @@ Bilibili: ログイン インターフェイスに表示されるアカウント 周回数指定 素材を限定 ドロップ数 + 連戦回数 ステージ 代替ステージ 余剰理性の消費 diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index 33ffb149d7..c6dc7a10cf 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -352,6 +352,7 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산) 횟수 제한 드롭 제한 드롭 수 + 연전 횟수 스테이지 선택 대안 남은 이성 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 6fbd5893f3..ffd850d9ea 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -352,6 +352,7 @@ 指定次数 指定材料 刷取数量 + 连战次数 关卡选择 备选 剩余理智 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 9c3f284230..65e2dcea44 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -350,6 +350,7 @@ 指定次數 指定材料 刷取數量 + 連戰次數 關卡選擇 備選 剩餘理智 diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index 2714a721c5..27ead3b089 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -1151,6 +1151,11 @@ namespace MaaWpfGui.ViewModels.UI } } + if (!int.TryParse(Series, out var series)) + { + series = 1; + } + int dropsQuantity = 0; if (IsSpecifiedDrops) { @@ -1162,7 +1167,7 @@ namespace MaaWpfGui.ViewModels.UI string curStage = Stage; - bool mainFightRet = Instances.AsstProxy.AsstAppendFight(curStage, medicine, stone, times, DropsItemId, dropsQuantity); + bool mainFightRet = Instances.AsstProxy.AsstAppendFight(curStage, medicine, stone, times, series, DropsItemId, dropsQuantity); if (!mainFightRet) { @@ -1179,14 +1184,14 @@ namespace MaaWpfGui.ViewModels.UI continue; } - mainFightRet = Instances.AsstProxy.AsstAppendFight(stage, medicine, 0, int.MaxValue, string.Empty, 0); + mainFightRet = Instances.AsstProxy.AsstAppendFight(stage, medicine, 0, int.MaxValue, series, string.Empty, 0); break; } } if (mainFightRet && UseRemainingSanityStage && !string.IsNullOrEmpty(RemainingSanityStage)) { - return Instances.AsstProxy.AsstAppendFight(RemainingSanityStage, 0, 0, int.MaxValue, string.Empty, 0, false); + return Instances.AsstProxy.AsstAppendFight(RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); } return mainFightRet; @@ -1231,6 +1236,11 @@ namespace MaaWpfGui.ViewModels.UI } } + if (!int.TryParse(Series, out var series)) + { + series = 1; + } + int dropsQuantity = 0; if (IsSpecifiedDrops) { @@ -1240,12 +1250,12 @@ namespace MaaWpfGui.ViewModels.UI } } - Instances.AsstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, DropsItemId, dropsQuantity); + Instances.AsstProxy.AsstSetFightTaskParams(Stage, medicine, stone, times, series, DropsItemId, dropsQuantity); } private void SetFightRemainingSanityParams() { - Instances.AsstProxy.AsstSetFightTaskParams(RemainingSanityStage, 0, 0, int.MaxValue, string.Empty, 0, false); + Instances.AsstProxy.AsstSetFightTaskParams(RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); } private void SetInfrastParams() @@ -2258,6 +2268,11 @@ namespace MaaWpfGui.ViewModels.UI } */ + /// + /// Gets or private sets the list of series. + /// + public List SeriesList { get; private set; } = ["1", "2", "3", "4", "5", "6"]; + private ObservableCollection _stageList = new(); /// @@ -2923,6 +2938,28 @@ namespace MaaWpfGui.ViewModels.UI } } + private string _series = ConfigurationHelper.GetValue(ConfigurationKeys.SeriesQuantity, "1"); + + /// + /// Gets or sets the max number of times. + /// + // 所以为啥这玩意是 string 呢?改配置的时候把上面那些也都改成 int 吧 + public string Series + { + get => _series; + set + { + if (_series == value) + { + return; + } + + SetAndNotify(ref _series, value); + SetFightParams(); + ConfigurationHelper.SetValue(ConfigurationKeys.SeriesQuantity, value); + } + } + #region Drops private bool? _isSpecifiedDropsWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DropsEnable, bool.FalseString)); diff --git a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml index b3ef886839..e80aff17c5 100644 --- a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml @@ -24,6 +24,7 @@ + @@ -150,6 +151,32 @@ + + + + + + + + + + + + + + @@ -277,7 +304,7 @@ Visibility="{c:Binding 'CustomStageCode and UseRemainingSanityStage'}" /> - +