diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs
index 0172f7c4ba..35d7000a31 100644
--- a/src/MaaWpfGui/Main/AsstProxy.cs
+++ b/src/MaaWpfGui/Main/AsstProxy.cs
@@ -2208,19 +2208,12 @@ namespace MaaWpfGui.Main
public bool AsstStartGacha(bool once = true)
{
- var taskParams = new JObject
+ var task = new AsstCustomTask()
{
- ["task_names"] = new JArray
- {
- once ? "GachaOnce" : "GachaTenTimes",
-
- // TEST
- // "Block",
- },
+ CustomTasks = [once ? "GachaOnce" : "GachaTenTimes"],
};
- AsstTaskId id = AsstAppendTaskWithEncoding(AsstTaskType.Custom, taskParams);
- _taskStatus.Add(id, TaskType.Gacha);
- return id != 0 && AsstStart();
+ var (type, param) = task.Serialize();
+ return AsstAppendTaskWithEncoding(TaskType.Gacha, type, param) && AsstStart();
}
public bool AsstStartVideoRec(string filename)
diff --git a/src/MaaWpfGui/Models/AsstTasks/AsstCustomTask.cs b/src/MaaWpfGui/Models/AsstTasks/AsstCustomTask.cs
new file mode 100644
index 0000000000..954d03c885
--- /dev/null
+++ b/src/MaaWpfGui/Models/AsstTasks/AsstCustomTask.cs
@@ -0,0 +1,30 @@
+//
+// 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 AsstCustomTask : AsstBaseTask
+{
+ public override AsstTaskType TaskType => AsstTaskType.Custom;
+
+ [JsonProperty("task_names")]
+ public List CustomTasks { get; set; } = [];
+
+ public override (AsstTaskType TaskType, JObject Params) Serialize() => (AsstTaskType.Custom, JObject.FromObject(this));
+}
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index 8341c3af9e..cf1a8c9b20 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -1347,8 +1347,11 @@ namespace MaaWpfGui.ViewModels.UI
break;
case "Custom":
- taskRet &= AppendCustom();
- break;
+ {
+ var (type, param) = CustomTask.Serialize();
+ taskRet &= Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param);
+ break;
+ }
default:
--count;
@@ -1757,18 +1760,6 @@ namespace MaaWpfGui.ViewModels.UI
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param);
}
- private static bool AppendCustom()
- {
- var taskParams = new JObject
- {
- ["task_names"] = new JArray
- {
- CustomTask.TaskName,
- },
- };
- return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Custom, AsstTaskType.Custom, taskParams);
- }
-
///
/// Gets a value indicating whether it is initialized.
///
diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs
index d7e7e35782..af659e4b6d 100644
--- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs
+++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/CustomSettingsUserControlModel.cs
@@ -1,4 +1,4 @@
-//
+//
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
@@ -13,6 +13,9 @@
#nullable enable
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
+using MaaWpfGui.Models.AsstTasks;
+using MaaWpfGui.Services;
+using Newtonsoft.Json.Linq;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
@@ -36,4 +39,13 @@ public class CustomSettingsUserControlModel : TaskViewModel
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.DebugTaskName, value);
}
}
+
+ public override (AsstTaskType Type, JObject Params) Serialize()
+ {
+ var task = new AsstCustomTask()
+ {
+ CustomTasks = { TaskName },
+ };
+ return task.Serialize();
+ }
}