From 5d67936591bf795e9d48aa049ecdfa5863ea8643 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Tue, 8 Apr 2025 19:33:20 +0800 Subject: [PATCH] =?UTF-8?q?rft:=20Wpf=E5=88=B7=E7=90=86=E6=99=BA=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/AsstProxy.cs | 96 +---------- .../Models/AsstTasks/AsstBaseTask.cs | 8 +- .../Models/AsstTasks/AsstFightTask.cs | 126 ++++++++++++++ .../ViewModels/UI/TaskQueueViewModel.cs | 155 +++++++----------- .../FightSettingsUserControlModel.cs | 67 +++++--- 5 files changed, 233 insertions(+), 219 deletions(-) create mode 100644 src/MaaWpfGui/Models/AsstTasks/AsstFightTask.cs diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 9ea8b0da92..d184708d36 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -947,7 +947,7 @@ namespace MaaWpfGui.Main } } - private void ProcSubTaskMsg(AsstMsg msg, JObject details) + private static void ProcSubTaskMsg(AsstMsg msg, JObject details) { // 下面几行注释暂时没用到,先注释起来... // string taskChain = details["taskchain"].ToString(); @@ -2035,97 +2035,8 @@ namespace MaaWpfGui.Main private readonly Dictionary _taskStatus = []; - private static JObject SerializeFightTaskParams( public IReadOnlyDictionary TaskStatus => _taskStatus; - string stage, - int maxMedicine, - int maxStone, - int maxTimes, - int series, - string dropsItemId, - int dropsItemQuantity, - bool isMainFight = true) - { - var taskParams = new JObject - { - ["stage"] = stage, - ["medicine"] = maxMedicine, - ["stone"] = maxStone, - ["times"] = maxTimes, - ["series"] = series, - ["report_to_penguin"] = SettingsViewModel.GameSettings.EnablePenguin, - ["report_to_yituliu"] = SettingsViewModel.GameSettings.EnableYituliu, - }; - if (dropsItemQuantity != 0 && !string.IsNullOrWhiteSpace(dropsItemId)) - { - taskParams["drops"] = new JObject - { - [dropsItemId] = dropsItemQuantity, - }; - } - - taskParams["client_type"] = SettingsViewModel.GameSettings.ClientType; - taskParams["penguin_id"] = SettingsViewModel.GameSettings.PenguinId; - taskParams["DrGrandet"] = TaskQueueViewModel.FightTask.IsDrGrandet; - taskParams["expiring_medicine"] = isMainFight && TaskQueueViewModel.FightTask.UseExpiringMedicine ? 9999 : 0; - taskParams["server"] = Instances.SettingsViewModel.ServerType; - return taskParams; - } - - /// - /// 刷理智。 - /// - /// 关卡名。 - /// 最大使用理智药数量。 - /// 最大吃石头数量。 - /// 指定次数。 - /// 连战次数。 - /// 指定掉落 ID。 - /// 指定掉落数量。 - /// 是否是主任务,决定c#侧是否记录任务id - /// 是否成功。 - 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, series, dropsItemId, dropsItemQuantity, isMainFight); - AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.Fight, taskParams); - if (isMainFight) - { - _taskStatus.Add(id, TaskType.Fight); - } - else - { - _taskStatus.Add(id, TaskType.FightRemainingSanity); - } - - return id != 0; - } - - /// - /// 设置刷理智任务参数。 - /// - /// 关卡名。 - /// 最大使用理智药数量。 - /// 最大吃石头数量。 - /// 指定次数。 - /// 连战次数。 - /// 指定掉落 ID。 - /// 指定掉落数量。 - /// 是否是主任务,决定c#侧是否记录任务id - /// 是否成功。 - 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; - var id = _taskStatus.FirstOrDefault(t => t.Value == type).Key; - if (id == 0) - { - return false; - } - - var taskParams = SerializeFightTaskParams(stage, maxMedicine, maxStone, maxTimes, series, dropsItemId, dropsItemQuantity); - return AsstSetTaskParamsWithEncoding(id, taskParams); - } - public bool AsstAppendCloseDown(string clientType) { if (!AsstStop()) @@ -2215,11 +2126,6 @@ namespace MaaWpfGui.Main return AsstSetTaskParams(_handle, id, JsonConvert.SerializeObject(taskParams)); } - public bool ContainsTask(TaskType type) - { - return _taskStatus.ContainsValue(type); - } - /// /// 启动。 /// diff --git a/src/MaaWpfGui/Models/AsstTasks/AsstBaseTask.cs b/src/MaaWpfGui/Models/AsstTasks/AsstBaseTask.cs index 351cf4a8cf..7e81d9887d 100644 --- a/src/MaaWpfGui/Models/AsstTasks/AsstBaseTask.cs +++ b/src/MaaWpfGui/Models/AsstTasks/AsstBaseTask.cs @@ -11,7 +11,6 @@ // but WITHOUT ANY WARRANTY // #nullable enable -using System; using MaaWpfGui.Services; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -19,12 +18,9 @@ using Newtonsoft.Json.Linq; namespace MaaWpfGui.Models.AsstTasks; [JsonObject(MemberSerialization.OptIn)] -public class AsstBaseTask +public abstract class AsstBaseTask { public virtual AsstTaskType TaskType { get; private set; } - public virtual (AsstTaskType TaskType, JObject Params) Serialize() - { - throw new NotImplementedException(); - } + public abstract (AsstTaskType TaskType, JObject Params) Serialize(); } diff --git a/src/MaaWpfGui/Models/AsstTasks/AsstFightTask.cs b/src/MaaWpfGui/Models/AsstTasks/AsstFightTask.cs new file mode 100644 index 0000000000..e65453be4d --- /dev/null +++ b/src/MaaWpfGui/Models/AsstTasks/AsstFightTask.cs @@ -0,0 +1,126 @@ +// +// MaaWpfGui - A part of the MaaCoreArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License v3.0 only as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY +// +#nullable enable +using System.Collections.Generic; +using MaaWpfGui.Services; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace MaaWpfGui.Models.AsstTasks; + +public class AsstFightTask : AsstBaseTask +{ + public override AsstTaskType TaskType => AsstTaskType.Fight; + + /// + /// Gets or sets 关卡id + /// + [JsonProperty("stage")] + public string Stage { get; set; } = string.Empty; + + /// + /// Gets or sets 最大吃药数量 + /// + [JsonProperty("medicine")] + public int Medicine { get; set; } + + /// + /// Gets or sets 临期药品数量 + /// + [JsonProperty("expiring_medicine")] + public int ExpiringMedicine { get; set; } + + /// + /// Gets or sets 最大碎石数量 + /// + [JsonProperty("stone")] + public int Stone { get; set; } + + /// + /// Gets or sets 最大次数 + /// + [JsonProperty("times")] + public int MaxTimes { get; set; } = 1; + + /// + /// Gets or sets 连战次数 + /// + [JsonProperty("series")] + public int Series { get; set; } = 1; + + /// + /// Gets or sets a value indicating whether gets or sets 葛朗台 + /// + [JsonProperty("DrGrandet")] + public bool IsDrGrandet { get; set; } + + /// + /// Gets or sets 掉落物品id, 数量 + /// + public Dictionary Drops { get; set; } = []; + + /// + /// Gets or sets a value indicating whether 是否回报企鹅物流,默认 false + /// + [JsonProperty("report_to_penguin")] + public bool ReportToPenguin { get; set; } + + /// + /// Gets or sets 企鹅物流回报id, 可选,默认为空。仅在 为 true 时有效 + /// + public string PenguinId { get; set; } = string.Empty; + + /// + /// Gets or sets a value indicating whether 是否回报一图流,默认 false + /// + [JsonProperty("report_to_yituliu")] + public bool ReportToYituliu { get; set; } + + /// + /// Gets or sets 一图流回报id,可选,默认为空。仅在 为 true 时有效 + /// + public string YituliuId { get; set; } = string.Empty; + + /// + /// Gets or sets 服务器,可选,默认 "CN", 会影响上传。选项:"CN" | "US" | "JP" | "KR" + /// + [JsonProperty("server")] + public string ServerType { get; set; } = string.Empty; + + /// + /// Gets or sets 客户端类型 + /// + [JsonProperty("client_type")] + public string ClientType { get; set; } = string.Empty; + + public override (AsstTaskType TaskType, JObject Params) Serialize() + { + var param = JObject.FromObject(this); + if (ReportToPenguin && !string.IsNullOrWhiteSpace(PenguinId)) + { + param["penguin_id"] = PenguinId; + } + + if (ReportToYituliu && !string.IsNullOrWhiteSpace(YituliuId)) + { + param["yituliu_id"] = YituliuId; + } + + if (Drops.Count > 0) + { + param["drops"] = JObject.FromObject(Drops); + } + + return (AsstTaskType.Custom, param); + } +} diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index 152ad44e53..17f90efa1d 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -41,6 +41,7 @@ using static MaaWpfGui.Main.AsstProxy; using Application = System.Windows.Application; using IContainer = StyletIoC.IContainer; using Screen = Stylet.Screen; +using Task = System.Threading.Tasks.Task; namespace MaaWpfGui.ViewModels.UI { @@ -1351,7 +1352,7 @@ namespace MaaWpfGui.ViewModels.UI case "Custom": { var (type, param) = CustomTask.Serialize(); - taskRet &= Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param); + taskRet &= Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Reclamation, type, param); break; } @@ -1548,56 +1549,15 @@ namespace MaaWpfGui.ViewModels.UI public static bool AppendStart() { var (type, param) = StartUpTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.StartUp, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.StartUp, type, param); } public bool AppendFight() { - int medicine = 0; - if (FightTask.UseMedicine) - { - if (!int.TryParse(FightTask.MedicineNumber, out medicine)) - { - medicine = 0; - } - } - - int stone = 0; - if (FightTask.UseStone) - { - if (!int.TryParse(FightTask.StoneNumber, out stone)) - { - stone = 0; - } - } - - int times = int.MaxValue; - if (FightTask.HasTimesLimited) - { - if (!int.TryParse(FightTask.MaxTimes, out times)) - { - times = 0; - } - } - - if (!int.TryParse(FightTask.Series, out var series)) - { - series = 1; - } - - int dropsQuantity = 0; - if (FightTask.IsSpecifiedDrops) - { - if (!int.TryParse(FightTask.DropsQuantity, out dropsQuantity)) - { - dropsQuantity = 0; - } - } - string curStage = FightTask.Stage; - bool mainFightRet = Instances.AsstProxy.AsstAppendFight(curStage, medicine, stone, times, series, FightTask.DropsItemId, dropsQuantity); - + var (type, mainParam) = FightTask.Serialize(); + bool mainFightRet = Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.FightRemainingSanity, type, mainParam); if (!mainFightRet) { AddLog(LocalizationHelper.GetString("UnsupportedStages") + ": " + curStage, UiLogColor.Error); @@ -1614,14 +1574,32 @@ namespace MaaWpfGui.ViewModels.UI } AddLog(LocalizationHelper.GetString("AnnihilationTaskTip"), UiLogColor.Info); - mainFightRet = Instances.AsstProxy.AsstAppendFight(stage, medicine, 0, int.MaxValue, series, string.Empty, 0); + var task = mainParam.ToObject(); + task.Stage = stage; + task.Stone = 0; + task.MaxTimes = int.MaxValue; + task.Drops = []; + mainFightRet = Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.FightRemainingSanity, type, task.Serialize().Params); break; } } if (mainFightRet && FightTask.UseRemainingSanityStage && !string.IsNullOrEmpty(FightTask.RemainingSanityStage)) { - return Instances.AsstProxy.AsstAppendFight(FightTask.RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); + var task = new AsstFightTask() + { + Stage = FightTask.RemainingSanityStage, + MaxTimes = int.MaxValue, + Series = 1, + IsDrGrandet = FightTask.IsDrGrandet, + ReportToPenguin = SettingsViewModel.GameSettings.EnablePenguin, + ReportToYituliu = SettingsViewModel.GameSettings.EnableYituliu, + PenguinId = SettingsViewModel.GameSettings.PenguinId, + YituliuId = SettingsViewModel.GameSettings.PenguinId, + ServerType = Instances.SettingsViewModel.ServerType, + ClientType = SettingsViewModel.GameSettings.ClientType, + }; + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.FightRemainingSanity, type, task.Serialize().Params); } return mainFightRet; @@ -1634,63 +1612,42 @@ namespace MaaWpfGui.ViewModels.UI /// public void SetFightParams() { - if (!EnableSetFightParams || !Instances.AsstProxy.ContainsTask(AsstProxy.TaskType.Fight)) + var type = TaskType.Fight; + var id = Instances.AsstProxy.TaskStatus.FirstOrDefault(t => t.Value == type).Key; + if (!EnableSetFightParams || id == default) { return; } - int medicine = 0; - if (FightTask.UseMedicine) - { - if (!int.TryParse(FightTask.MedicineNumber, out medicine)) - { - medicine = 0; - } - } - - int stone = 0; - if (FightTask.UseStone) - { - if (!int.TryParse(FightTask.StoneNumber, out stone)) - { - stone = 0; - } - } - - int times = int.MaxValue; - if (FightTask.HasTimesLimited) - { - if (!int.TryParse(FightTask.MaxTimes, out times)) - { - times = 0; - } - } - - if (!int.TryParse(FightTask.Series, out var series)) - { - series = 1; - } - - int dropsQuantity = 0; - if (FightTask.IsSpecifiedDrops) - { - if (!int.TryParse(FightTask.DropsQuantity, out dropsQuantity)) - { - dropsQuantity = 0; - } - } - - Instances.AsstProxy.AsstSetFightTaskParams(FightTask.Stage, medicine, stone, times, series, FightTask.DropsItemId, dropsQuantity); + var taskParams = FightTask.Serialize().Params; + Instances.AsstProxy.AsstSetTaskParamsEncoded(id, taskParams); } - public void SetFightRemainingSanityParams() + public static void SetFightRemainingSanityParams() { - if (!Instances.AsstProxy.ContainsTask(AsstProxy.TaskType.FightRemainingSanity)) + var type = TaskType.FightRemainingSanity; + var id = Instances.AsstProxy.TaskStatus.FirstOrDefault(t => t.Value == type).Key; + if (id == default) { return; } - Instances.AsstProxy.AsstSetFightTaskParams(FightTask.RemainingSanityStage, 0, 0, int.MaxValue, 1, string.Empty, 0, false); + var task = new AsstFightTask() + { + Stage = FightTask.RemainingSanityStage, + MaxTimes = int.MaxValue, + Series = 1, + IsDrGrandet = FightTask.IsDrGrandet, + ReportToPenguin = SettingsViewModel.GameSettings.EnablePenguin, + ReportToYituliu = SettingsViewModel.GameSettings.EnableYituliu, + PenguinId = SettingsViewModel.GameSettings.PenguinId, + YituliuId = SettingsViewModel.GameSettings.PenguinId, + ServerType = Instances.SettingsViewModel.ServerType, + ClientType = SettingsViewModel.GameSettings.ClientType, + }; + + var taskParams = task.Serialize().Params; + Instances.AsstProxy.AsstSetTaskParamsEncoded(id, taskParams); } public static void SetInfrastParams() @@ -1715,37 +1672,37 @@ namespace MaaWpfGui.ViewModels.UI } var (type, param) = InfrastTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Infrast, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Infrast, type, param); } public static bool AppendMall() { var (type, param) = MallTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Mall, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Mall, type, param); } public static bool AppendAward() { var (type, param) = AwardTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Award, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Award, type, param); } public static bool AppendRecruit() { var (type, param) = RecruitTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Recruit, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Recruit, type, param); } public static bool AppendRoguelike() { var (type, param) = RoguelikeTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Roguelike, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Roguelike, type, param); } public static bool AppendReclamation() { var (type, param) = ReclamationTask.Serialize(); - return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param); + return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Reclamation, type, param); } /// diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs index 142178af2a..c2a1e28843 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/FightSettingsUserControlModel.cs @@ -17,7 +17,11 @@ using System.Collections.ObjectModel; using System.Windows; using MaaWpfGui.Constants; using MaaWpfGui.Helper; +using MaaWpfGui.Models.AsstTasks; +using MaaWpfGui.Services; using MaaWpfGui.Utilities.ValueType; +using MaaWpfGui.ViewModels.UI; +using Newtonsoft.Json.Linq; namespace MaaWpfGui.ViewModels.UserControl.TaskQueue; @@ -251,7 +255,7 @@ public class FightSettingsUserControlModel : TaskViewModel } SetAndNotify(ref _remainingSanityStage, value); - Instances.TaskQueueViewModel.SetFightRemainingSanityParams(); + TaskQueueViewModel.SetFightRemainingSanityParams(); ConfigurationHelper.SetValue(ConfigurationKeys.RemainingSanityStage, value); } } @@ -313,12 +317,12 @@ public class FightSettingsUserControlModel : TaskViewModel set => UseMedicineWithNull = value; } - private string _medicineNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicineQuantity, "999"); + private int _medicineNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicineQuantity, 999); /// /// Gets or sets the amount of medicine used. /// - public string MedicineNumber + public int MedicineNumber { get => _medicineNumber; set @@ -329,9 +333,8 @@ public class FightSettingsUserControlModel : TaskViewModel } SetAndNotify(ref _medicineNumber, value); - Instances.TaskQueueViewModel.SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicineQuantity, MedicineNumber); + ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicineQuantity, value.ToString()); } } @@ -356,7 +359,7 @@ public class FightSettingsUserControlModel : TaskViewModel SetAndNotify(ref _useStoneWithNull, value); if (value != false) { - MedicineNumber = "999"; + MedicineNumber = 999; if (!UseMedicine) { UseMedicineWithNull = value; @@ -384,12 +387,12 @@ public class FightSettingsUserControlModel : TaskViewModel set => UseStoneWithNull = value; } - private string _stoneNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseStoneQuantity, "0"); + private int _stoneNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseStoneQuantity, 0); /// /// Gets or sets the amount of originiums used. /// - public string StoneNumber + public int StoneNumber { get => _stoneNumber; set @@ -401,7 +404,7 @@ public class FightSettingsUserControlModel : TaskViewModel SetAndNotify(ref _stoneNumber, value); Instances.TaskQueueViewModel.SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.UseStoneQuantity, StoneNumber); + ConfigurationHelper.SetValue(ConfigurationKeys.UseStoneQuantity, value.ToString()); } } @@ -431,12 +434,12 @@ public class FightSettingsUserControlModel : TaskViewModel set => HasTimesLimitedWithNull = value; } - private string _maxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimitedQuantity, "5"); + private int _maxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimitedQuantity, 5); /// /// Gets or sets the max number of times. /// - public string MaxTimes + public int MaxTimes { get => _maxTimes; set @@ -448,17 +451,16 @@ public class FightSettingsUserControlModel : TaskViewModel SetAndNotify(ref _maxTimes, value); Instances.TaskQueueViewModel.SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimitedQuantity, MaxTimes); + ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimitedQuantity, value.ToString()); } } - private string _series = ConfigurationHelper.GetValue(ConfigurationKeys.SeriesQuantity, "1"); + private int _series = ConfigurationHelper.GetValue(ConfigurationKeys.SeriesQuantity, 1); /// /// Gets or sets the max number of times. /// - // 所以为啥这玩意是 string 呢?改配置的时候把上面那些也都改成 int 吧 - public string Series + public int Series { get => _series; set @@ -470,7 +472,7 @@ public class FightSettingsUserControlModel : TaskViewModel SetAndNotify(ref _series, value); Instances.TaskQueueViewModel.SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.SeriesQuantity, value); + ConfigurationHelper.SetValue(ConfigurationKeys.SeriesQuantity, value.ToString()); } } @@ -612,19 +614,19 @@ public class FightSettingsUserControlModel : TaskViewModel DropsItemName = LocalizationHelper.GetString("NotSelected"); } - private string _dropsQuantity = ConfigurationHelper.GetValue(ConfigurationKeys.DropsQuantity, "5"); + private int _dropsQuantity = ConfigurationHelper.GetValue(ConfigurationKeys.DropsQuantity, 5); /// /// Gets or sets the quantity of drops. /// - public string DropsQuantity + public int DropsQuantity { get => _dropsQuantity; set { SetAndNotify(ref _dropsQuantity, value); Instances.TaskQueueViewModel.SetFightParams(); - ConfigurationHelper.SetValue(ConfigurationKeys.DropsQuantity, DropsQuantity); + ConfigurationHelper.SetValue(ConfigurationKeys.DropsQuantity, value.ToString()); } } @@ -771,6 +773,33 @@ public class FightSettingsUserControlModel : TaskViewModel return value; } + public override (AsstTaskType Type, JObject Params) Serialize() + { + var task = new AsstFightTask() + { + Stage = Stage, + Medicine = UseMedicine ? MedicineNumber : 0, + Stone = UseStone ? StoneNumber : 0, + Series = Series, + MaxTimes = HasTimesLimited ? MaxTimes : int.MaxValue, + ExpiringMedicine = UseExpiringMedicine ? 9999 : 0, + IsDrGrandet = IsDrGrandet, + ReportToPenguin = SettingsViewModel.GameSettings.EnablePenguin, + ReportToYituliu = SettingsViewModel.GameSettings.EnableYituliu, + PenguinId = SettingsViewModel.GameSettings.PenguinId, + YituliuId = SettingsViewModel.GameSettings.PenguinId, + ServerType = Instances.SettingsViewModel.ServerType, + ClientType = SettingsViewModel.GameSettings.ClientType, + }; + + if (IsSpecifiedDrops) + { + task.Drops.Add(DropsItemId, DropsQuantity); + } + + return task.Serialize(); + } + #region 双入口设置可见性 private bool _customInfrastPlanShowInFightSettings = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, bool.FalseString));