mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
rft: Wpf重构生息演算任务参数序列化
perf: 移除不必要的分隔符
This commit is contained in:
@@ -2615,42 +2615,6 @@ namespace MaaWpfGui.Main
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
/// <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>是否成功。</returns>
|
||||
public bool AsstAppendReclamation(string[] toolToCraft, string theme = "Tales", int mode = 1, int incrementMode = 0, int numCraftBatches = 16)
|
||||
{
|
||||
var taskParams = new JObject
|
||||
{
|
||||
["tools_to_craft"] = new JArray(toolToCraft),
|
||||
["theme"] = theme,
|
||||
["mode"] = mode,
|
||||
["increment_mode"] = incrementMode,
|
||||
["num_craft_batches"] = numCraftBatches,
|
||||
};
|
||||
AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.Reclamation, taskParams);
|
||||
_taskStatus.Add(id, TaskType.Reclamation);
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 公招识别。
|
||||
/// </summary>
|
||||
@@ -2780,6 +2744,19 @@ namespace MaaWpfGui.Main
|
||||
return id != 0 && AsstStart();
|
||||
}
|
||||
|
||||
public bool AsstAppendTaskWithEncoding(TaskType wpfTasktype, AsstTaskType type, JObject? taskParams = null)
|
||||
{
|
||||
taskParams ??= [];
|
||||
AsstTaskId id = AsstAppendTask(_handle, type.ToString(), JsonConvert.SerializeObject(taskParams));
|
||||
if (id == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_taskStatus.Add(id, wpfTasktype);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ContainsTask(TaskType type)
|
||||
{
|
||||
return _taskStatus.ContainsValue(type);
|
||||
|
||||
@@ -1861,16 +1861,9 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
|
||||
private static bool AppendReclamation()
|
||||
{
|
||||
var toolToCraft = ReclamationTask.ReclamationToolToCraft.Split(';', ';').Select(s => s.Trim());
|
||||
|
||||
_ = int.TryParse(ReclamationTask.ReclamationMode, out var mode);
|
||||
|
||||
return Instances.AsstProxy.AsstAppendReclamation(
|
||||
toolToCraft.ToArray(),
|
||||
ReclamationTask.ReclamationTheme,
|
||||
mode,
|
||||
ReclamationTask.ReclamationIncrementMode,
|
||||
ReclamationTask.ReclamationMaxCraftCountPerRound);
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
var (type, param) = ReclamationTask.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user