rft: Wpf重构生息演算任务参数序列化

perf: 移除不必要的分隔符
This commit is contained in:
status102
2025-02-14 21:20:08 +08:00
parent fb1b3859a2
commit 7f8ba1719f
3 changed files with 55 additions and 47 deletions

View File

@@ -13,10 +13,13 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.Services;
using MaaWpfGui.Utilities.ValueType;
using MaaWpfGui.ViewModels.UI;
using Newtonsoft.Json.Linq;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
@@ -77,7 +80,7 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
}
}
private string _reclamationToolToCraft = ConfigurationHelper.GetValue(ConfigurationKeys.ReclamationToolToCraft, string.Empty);
private string _reclamationToolToCraft = ConfigurationHelper.GetValue(ConfigurationKeys.ReclamationToolToCraft, string.Empty).Replace('', ';');
public string ReclamationToolToCraft
{
@@ -93,6 +96,7 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
set
{
value = value.Replace('', ';');
SetAndNotify(ref _reclamationToolToCraft, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ReclamationToolToCraft, value);
}
@@ -130,4 +134,38 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
ConfigurationHelper.SetValue(ConfigurationKeys.ReclamationMaxCraftCountPerRound, value.ToString());
}
}
/// <summary>
/// 自动生息演算。
/// </summary>
/// <param name="toolToCraft">要组装的支援道具。</param>
/// <param name="theme">生息演算主题["Tales"]</param>
/// <param name="mode">
/// 策略。可用值包括:
/// <list type="bullet">
/// <item>
/// <term><c>0</c></term>
/// <description>无存档时通过进出关卡刷生息点数</description>
/// </item>
/// <item>
/// <term><c>1</c></term>
/// <description>有存档时通过合成支援道具刷生息点数</description>
/// </item>
/// </list>
/// </param>
/// <param name="incrementMode">点击类型0 连点1 长按</param>
/// <param name="numCraftBatches">单次最大制造轮数</param>
/// <returns>返回(Asst任务类型, 参数)</returns>
public (AsstTaskType Type, JObject Params) Serialize()
{
var data = new JObject
{
["theme"] = ReclamationTheme,
["mode"] = ReclamationMode,
["increment_mode"] = ReclamationIncrementMode,
["num_craft_batches"] = ReclamationMaxCraftCountPerRound,
["tools_to_craft"] = new JArray(ReclamationToolToCraft.Split(';').Select(s => s.Trim())),
};
return (AsstTaskType.Reclamation, data);
}
}