rft: wpf生息演算任务序列化

This commit is contained in:
status102
2025-03-02 11:51:19 +08:00
parent 0a2d2970f6
commit 564f9e5dce
2 changed files with 84 additions and 8 deletions

View File

@@ -0,0 +1,76 @@
// <copyright file="AsstReclamationTask.cs" company="MaaAssistantArknights">
// 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
// </copyright>
#nullable enable
using System.Collections.Generic;
using MaaWpfGui.Services;
using Newtonsoft.Json.Linq;
namespace MaaWpfGui.Models.AsstTasks;
/// <summary>
/// 自动生息演算。
/// </summary>
public class AsstReclamationTask : AsstBaseTask
{
public override AsstTaskType TaskType => AsstTaskType.Reclamation;
/// <summary>
/// Gets or sets 生息演算主题
/// </summary>
public string Theme { get; set; } = "Tales";
/// <summary>
/// Gets or sets 生息演算模式
/// <list type="bullet">
/// <item>
/// <term><c>0</c></term>
/// <description>无存档时通过进出关卡刷生息点数</description>
/// </item>
/// <item>
/// <term><c>1</c></term>
/// <description>有存档时通过合成支援道具刷生息点数</description>
/// </item>
/// </list>
/// </summary>
public int Mode { get; set; } = 0;
/// <summary>
/// Gets or sets 点击类型0 连点1 长按
/// </summary>
public int IncrementMode { get; set; } = 0;
/// <summary>
/// Gets or sets 单次最大制造轮数
/// </summary>
public int MaxCraftCountPerRound { get; set; } = 1;
/// <summary>
/// Gets or sets 要组装的支援道具。
/// </summary>
public List<string> ToolToCraft { get; set; } = [];
public override (AsstTaskType TaskType, JObject Params) Serialize()
{
var data = new JObject
{
["theme"] = Theme,
["mode"] = Mode,
["increment_mode"] = IncrementMode,
["num_craft_batches"] = MaxCraftCountPerRound,
["tools_to_craft"] = new JArray(ToolToCraft),
};
return (TaskType, data);
}
}

View File

@@ -16,6 +16,7 @@ using System.Collections.Generic;
using System.Linq;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.Models.AsstTasks;
using MaaWpfGui.Services;
using MaaWpfGui.Utilities.ValueType;
using MaaWpfGui.ViewModels.UI;
@@ -158,14 +159,13 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
/// <returns>返回(Asst任务类型, 参数)</returns>
public override (AsstTaskType Type, JObject Params) Serialize()
{
var data = new JObject
return new AsstReclamationTask()
{
["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);
Theme = ReclamationTheme,
Mode = ReclamationMode,
IncrementMode = ReclamationIncrementMode,
MaxCraftCountPerRound = ReclamationMaxCraftCountPerRound,
ToolToCraft = ReclamationToolToCraft.Split(';').Select(s => s.Trim()).ToList(),
}.Serialize();
}
}