mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
rft: Wpf刷理智任务、基建任务序列化 (#12281)
This commit is contained in:
@@ -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,94 +2035,7 @@ namespace MaaWpfGui.Main
|
||||
|
||||
private readonly Dictionary<AsstTaskId, TaskType> _taskStatus = [];
|
||||
|
||||
private static JObject SerializeFightTaskParams(
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷理智。
|
||||
/// </summary>
|
||||
/// <param name="stage">关卡名。</param>
|
||||
/// <param name="maxMedicine">最大使用理智药数量。</param>
|
||||
/// <param name="maxStone">最大吃石头数量。</param>
|
||||
/// <param name="maxTimes">指定次数。</param>
|
||||
/// <param name="series">连战次数。</param>
|
||||
/// <param name="dropsItemId">指定掉落 ID。</param>
|
||||
/// <param name="dropsItemQuantity">指定掉落数量。</param>
|
||||
/// <param name="isMainFight">是否是主任务,决定c#侧是否记录任务id</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置刷理智任务参数。
|
||||
/// </summary>
|
||||
/// <param name="stage">关卡名。</param>
|
||||
/// <param name="maxMedicine">最大使用理智药数量。</param>
|
||||
/// <param name="maxStone">最大吃石头数量。</param>
|
||||
/// <param name="maxTimes">指定次数。</param>
|
||||
/// <param name="series">连战次数。</param>
|
||||
/// <param name="dropsItemId">指定掉落 ID。</param>
|
||||
/// <param name="dropsItemQuantity">指定掉落数量。</param>
|
||||
/// <param name="isMainFight">是否是主任务,决定c#侧是否记录任务id</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
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 IReadOnlyDictionary<AsstTaskId, TaskType> TaskStatus => _taskStatus;
|
||||
|
||||
public bool AsstAppendCloseDown(string clientType)
|
||||
{
|
||||
@@ -2150,44 +2063,6 @@ namespace MaaWpfGui.Main
|
||||
return MaaService.AsstBackToHome(_handle);
|
||||
}
|
||||
|
||||
public bool AsstSetInfrastTaskParams()
|
||||
{
|
||||
const TaskType Type = TaskType.Infrast;
|
||||
int id = _taskStatus.FirstOrDefault(i => i.Value == Type).Key;
|
||||
if (id == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var taskParams = InfrastSettingsUserControlModel.Instance.Serialize().Params;
|
||||
return AsstSetTaskParamsWithEncoding(id, taskParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 公招识别。
|
||||
/// </summary>
|
||||
/// <param name="selectLevel">会去点击标签的 Tag 等级。</param>
|
||||
/// <param name="setTime">是否设置 9 小时。</param>
|
||||
/// <param name="chooseLevel3Time">3 星招募时间</param>
|
||||
/// <param name="chooseLevel4Time">4 星招募时间</param>
|
||||
/// <param name="chooseLevel5Time">5 星招募时间</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
public bool AsstStartRecruitCalc(int[] selectLevel, bool setTime, int chooseLevel3Time, int chooseLevel4Time, int chooseLevel5Time)
|
||||
{
|
||||
var task = new AsstRecruitTask()
|
||||
{
|
||||
SelectList = selectLevel.ToList(),
|
||||
ConfirmList = [-1], // 仅公招识别时将-1加入comfirm_level
|
||||
SetRecruitTime = setTime,
|
||||
ChooseLevel3Time = chooseLevel3Time,
|
||||
ChooseLevel4Time = chooseLevel4Time,
|
||||
ChooseLevel5Time = chooseLevel5Time,
|
||||
ServerType = Instances.SettingsViewModel.ServerType,
|
||||
};
|
||||
var (type, taskParams) = task.Serialize();
|
||||
return AsstAppendTaskWithEncoding(TaskType.RecruitCalc, type, taskParams) && AsstStart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仓库识别。
|
||||
/// </summary>
|
||||
@@ -2240,9 +2115,15 @@ namespace MaaWpfGui.Main
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ContainsTask(TaskType type)
|
||||
public bool AsstSetTaskParamsEncoded(AsstTaskId id, JObject? taskParams = null)
|
||||
{
|
||||
return _taskStatus.ContainsValue(type);
|
||||
if (id == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
taskParams ??= [];
|
||||
return AsstSetTaskParams(_handle, id, JsonConvert.SerializeObject(taskParams));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// but WITHOUT ANY WARRANTY
|
||||
// </copyright>
|
||||
#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();
|
||||
}
|
||||
|
||||
126
src/MaaWpfGui/Models/AsstTasks/AsstFightTask.cs
Normal file
126
src/MaaWpfGui/Models/AsstTasks/AsstFightTask.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
// <copyright file="AsstFightTask.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;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MaaWpfGui.Models.AsstTasks;
|
||||
|
||||
public class AsstFightTask : AsstBaseTask
|
||||
{
|
||||
public override AsstTaskType TaskType => AsstTaskType.Fight;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 关卡id
|
||||
/// </summary>
|
||||
[JsonProperty("stage")]
|
||||
public string Stage { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 最大吃药数量
|
||||
/// </summary>
|
||||
[JsonProperty("medicine")]
|
||||
public int Medicine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 临期药品数量
|
||||
/// </summary>
|
||||
[JsonProperty("expiring_medicine")]
|
||||
public int ExpiringMedicine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 最大碎石数量
|
||||
/// </summary>
|
||||
[JsonProperty("stone")]
|
||||
public int Stone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 最大次数
|
||||
/// </summary>
|
||||
[JsonProperty("times")]
|
||||
public int MaxTimes { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 连战次数
|
||||
/// </summary>
|
||||
[JsonProperty("series")]
|
||||
public int Series { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether gets or sets 葛朗台
|
||||
/// </summary>
|
||||
[JsonProperty("DrGrandet")]
|
||||
public bool IsDrGrandet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 掉落物品id, 数量
|
||||
/// </summary>
|
||||
public Dictionary<string, int> Drops { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 是否回报企鹅物流,默认 false
|
||||
/// </summary>
|
||||
[JsonProperty("report_to_penguin")]
|
||||
public bool ReportToPenguin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 企鹅物流回报id, 可选,默认为空。仅在 <see cref="ReportToPenguin"/> 为 true 时有效
|
||||
/// </summary>
|
||||
public string PenguinId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 是否回报一图流,默认 false
|
||||
/// </summary>
|
||||
[JsonProperty("report_to_yituliu")]
|
||||
public bool ReportToYituliu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 一图流回报id,可选,默认为空。仅在 <see cref="ReportToYituliu"/> 为 true 时有效
|
||||
/// </summary>
|
||||
public string YituliuId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 服务器,可选,默认 "CN", 会影响上传。选项:"CN" | "US" | "JP" | "KR"
|
||||
/// </summary>
|
||||
[JsonProperty("server")]
|
||||
public string ServerType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 客户端类型
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
@@ -644,35 +644,35 @@ namespace MaaWpfGui.Services.RemoteControl
|
||||
switch (item)
|
||||
{
|
||||
case "Base":
|
||||
taskRet &= InvokeInstanceFunction<bool>(Instances.TaskQueueViewModel, "AppendInfrast");
|
||||
taskRet &= Instances.TaskQueueViewModel.AppendInfrast();
|
||||
break;
|
||||
|
||||
case "WakeUp":
|
||||
taskRet &= InvokeStaticFunction<bool>(Instances.TaskQueueViewModel.GetType(), "AppendStart");
|
||||
taskRet &= TaskQueueViewModel.AppendStart();
|
||||
break;
|
||||
|
||||
case "Combat":
|
||||
taskRet &= InvokeInstanceFunction<bool>(Instances.TaskQueueViewModel, "AppendFight");
|
||||
taskRet &= Instances.TaskQueueViewModel.AppendFight();
|
||||
break;
|
||||
|
||||
case "Recruiting":
|
||||
taskRet &= InvokeStaticFunction<bool>(Instances.TaskQueueViewModel.GetType(), "AppendRecruit");
|
||||
taskRet &= TaskQueueViewModel.AppendRecruit();
|
||||
break;
|
||||
|
||||
case "Mall":
|
||||
taskRet &= InvokeInstanceFunction<bool>(Instances.TaskQueueViewModel, "AppendMall");
|
||||
taskRet &= TaskQueueViewModel.AppendMall();
|
||||
break;
|
||||
|
||||
case "Mission":
|
||||
taskRet &= InvokeStaticFunction<bool>(Instances.TaskQueueViewModel.GetType(), "AppendAward");
|
||||
taskRet &= TaskQueueViewModel.AppendAward();
|
||||
break;
|
||||
|
||||
case "AutoRoguelike":
|
||||
taskRet &= InvokeStaticFunction<bool>(Instances.TaskQueueViewModel.GetType(), "AppendRoguelike");
|
||||
taskRet &= TaskQueueViewModel.AppendRoguelike();
|
||||
break;
|
||||
|
||||
case "Reclamation":
|
||||
taskRet &= InvokeStaticFunction<bool>(Instances.TaskQueueViewModel.GetType(), "AppendReclamation");
|
||||
taskRet &= TaskQueueViewModel.AppendReclamation();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -23,11 +23,13 @@ using System.Windows.Threading;
|
||||
using HandyControl.Controls;
|
||||
using MaaWpfGui.Constants;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.States;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
using Stylet;
|
||||
using static MaaWpfGui.Main.AsstProxy;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UI
|
||||
@@ -219,7 +221,19 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
levelList.Add(6);
|
||||
}
|
||||
|
||||
Instances.AsstProxy.AsstStartRecruitCalc(levelList.ToArray(), RecruitAutoSetTime, TaskQueueViewModel.RecruitTask.ChooseLevel3Time, TaskQueueViewModel.RecruitTask.ChooseLevel4Time, TaskQueueViewModel.RecruitTask.ChooseLevel5Time);
|
||||
var task = new AsstRecruitTask()
|
||||
{
|
||||
SelectList = levelList,
|
||||
ConfirmList = [-1], // 仅公招识别时将-1加入comfirm_level
|
||||
SetRecruitTime = RecruitAutoSetTime,
|
||||
ChooseLevel3Time = TaskQueueViewModel.RecruitTask.ChooseLevel3Time,
|
||||
ChooseLevel4Time = TaskQueueViewModel.RecruitTask.ChooseLevel4Time,
|
||||
ChooseLevel5Time = TaskQueueViewModel.RecruitTask.ChooseLevel5Time,
|
||||
ServerType = Instances.SettingsViewModel.ServerType,
|
||||
};
|
||||
var (type, taskParams) = task.Serialize();
|
||||
bool ret = Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.RecruitCalc, type, taskParams);
|
||||
ret &= Instances.AsstProxy.AsstStart();
|
||||
}
|
||||
|
||||
private bool _recruitmentShowPotential = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitmentShowPotential, bool.TrueString));
|
||||
|
||||
@@ -27,6 +27,7 @@ using MaaWpfGui.Extensions;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Main;
|
||||
using MaaWpfGui.Models;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.States;
|
||||
using MaaWpfGui.Utilities;
|
||||
@@ -36,9 +37,11 @@ using MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
using Stylet;
|
||||
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
|
||||
{
|
||||
@@ -1349,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;
|
||||
}
|
||||
|
||||
@@ -1543,59 +1546,18 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
}
|
||||
}
|
||||
|
||||
private static bool AppendStart()
|
||||
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);
|
||||
}
|
||||
|
||||
private bool AppendFight()
|
||||
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);
|
||||
@@ -1612,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<AsstFightTask>();
|
||||
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;
|
||||
@@ -1632,78 +1612,59 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
/// </summary>
|
||||
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 void SetInfrastParams()
|
||||
public static void SetInfrastParams()
|
||||
{
|
||||
if (!Instances.AsstProxy.ContainsTask(AsstProxy.TaskType.Infrast))
|
||||
const TaskType Type = TaskType.Infrast;
|
||||
int id = Instances.AsstProxy.TaskStatus.FirstOrDefault(i => i.Value == Type).Key;
|
||||
if (id == default)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Instances.AsstProxy.AsstSetInfrastTaskParams();
|
||||
var taskParams = InfrastSettingsUserControlModel.Instance.Serialize().Params;
|
||||
Instances.AsstProxy.AsstSetTaskParamsEncoded(id, taskParams);
|
||||
}
|
||||
|
||||
private bool AppendInfrast()
|
||||
public bool AppendInfrast()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
if (InfrastTask.CustomInfrastEnabled && (!File.Exists(InfrastTask.CustomInfrastFile) || InfrastTask.CustomInfrastPlanInfoList.Count == 0))
|
||||
{
|
||||
AddLog(LocalizationHelper.GetString("CustomizeInfrastSelectionEmpty"), UiLogColor.Error);
|
||||
@@ -1711,53 +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);
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, IEnumerable<string>> _blackCharacterListMapping = new()
|
||||
public static bool AppendMall()
|
||||
{
|
||||
{ string.Empty, ["讯使", "嘉维尔", "坚雷"] },
|
||||
{ "Official", ["讯使", "嘉维尔", "坚雷"] },
|
||||
{ "Bilibili", ["讯使", "嘉维尔", "坚雷"] },
|
||||
{ "YoStarEN", ["Courier", "Gavial", "Dur-nar"] },
|
||||
{ "YoStarJP", ["クーリエ", "ガヴィル", "ジュナー"] },
|
||||
{ "YoStarKR", ["쿠리어", "가비알", "듀나"] },
|
||||
{ "txwy", ["訊使", "嘉維爾", "堅雷"] },
|
||||
};
|
||||
|
||||
private bool AppendMall()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
var (type, param) = MallTask.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Mall, type, param);
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Mall, type, param);
|
||||
}
|
||||
|
||||
private static bool AppendAward()
|
||||
public static bool AppendAward()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
var (type, param) = AwardTask.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Award, type, param);
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Award, type, param);
|
||||
}
|
||||
|
||||
private static bool AppendRecruit()
|
||||
public static bool AppendRecruit()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
var (type, param) = RecruitTask.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Recruit, type, param);
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Recruit, type, param);
|
||||
}
|
||||
|
||||
private static bool AppendRoguelike()
|
||||
public static bool AppendRoguelike()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
var (type, param) = RoguelikeTask.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Roguelike, type, param);
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Roguelike, type, param);
|
||||
}
|
||||
|
||||
private static bool AppendReclamation()
|
||||
public static bool AppendReclamation()
|
||||
{
|
||||
// 被RemoteControlService反射调用,暂不移除
|
||||
var (type, param) = ReclamationTask.Serialize();
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(AsstProxy.TaskType.Reclamation, type, param);
|
||||
return Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Reclamation, type, param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of medicine used.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of originiums used.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the max number of times.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the max number of times.
|
||||
/// </summary>
|
||||
// 所以为啥这玩意是 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);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the quantity of drops.
|
||||
/// </summary>
|
||||
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));
|
||||
|
||||
@@ -23,6 +23,7 @@ using MaaWpfGui.Models;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.Utilities.ValueType;
|
||||
using MaaWpfGui.ViewModels.UI;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -440,7 +441,7 @@ public class InfrastSettingsUserControlModel : TaskViewModel
|
||||
}
|
||||
|
||||
SetAndNotify(ref _customInfrastPlanIndex, value);
|
||||
Instances.TaskQueueViewModel.SetInfrastParams();
|
||||
TaskQueueViewModel.SetInfrastParams();
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.CustomInfrastPlanIndex, value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user