mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
rft(wpf): 长草任务序列化接口重构拆分
This commit is contained in:
@@ -13,16 +13,11 @@
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using MaaWpfGui.Configuration.Factory;
|
||||
using MaaWpfGui.Configuration.Single.MaaTask;
|
||||
using MaaWpfGui.Main;
|
||||
using MaaWpfGui.Models;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.Utilities;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Stylet;
|
||||
@@ -84,3 +79,9 @@ public abstract class TaskSettingsViewModel : PropertyChangedBase
|
||||
/// <returns>null为未序列化, false失败, true成功</returns>
|
||||
public abstract bool? SerializeTask(BaseTask? baseTask, int? taskId = null);
|
||||
}
|
||||
|
||||
public interface ITaskQueueModelSerialize
|
||||
{
|
||||
/// <inheritdoc cref="TaskSettingsViewModel.SerializeTask"/>
|
||||
public abstract bool? Serialize(BaseTask? baseTask, int? taskId);
|
||||
}
|
||||
|
||||
@@ -12,19 +12,15 @@
|
||||
// </copyright>
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Windows;
|
||||
using MaaWpfGui.Configuration.Single.MaaTask;
|
||||
using MaaWpfGui.Constants;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using static MaaWpfGui.Main.AsstProxy;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
public class AwardSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class AwardSettingsUserControlModel : TaskSettingsViewModel, AwardSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static AwardSettingsUserControlModel()
|
||||
{
|
||||
@@ -113,25 +109,30 @@ public class AwardSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
{
|
||||
if (baseTask is not AwardTask award)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize).Serialize(baseTask, taskId);
|
||||
|
||||
var task = new AsstAwardTask() {
|
||||
Award = award.Award,
|
||||
Mail = award.Mail,
|
||||
FreeGacha = award.FreeGacha,
|
||||
Orundum = award.Orundum,
|
||||
Mining = award.Mining,
|
||||
SpecialAccess = award.SpecialAccess,
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Award, task),
|
||||
_ => null,
|
||||
};
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
if (baseTask is not AwardTask award)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var task = new AsstAwardTask() {
|
||||
Award = award.Award,
|
||||
Mail = award.Mail,
|
||||
FreeGacha = award.FreeGacha,
|
||||
Orundum = award.Orundum,
|
||||
Mining = award.Mining,
|
||||
SpecialAccess = award.SpecialAccess,
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Award, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,15 @@
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MaaWpfGui.Configuration.Single.MaaTask;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using static MaaWpfGui.Main.AsstProxy;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
public class CustomSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class CustomSettingsUserControlModel : TaskSettingsViewModel, CustomSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static CustomSettingsUserControlModel()
|
||||
{
|
||||
@@ -73,20 +70,25 @@ public class CustomSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
{
|
||||
if (baseTask is not CustomTask custom)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize).Serialize(baseTask, taskId);
|
||||
|
||||
var task = new AsstCustomTask() {
|
||||
CustomTasks = [.. custom.CustomTaskName.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(task => task.Trim())],
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Custom, task),
|
||||
_ => null,
|
||||
};
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
if (baseTask is not CustomTask custom)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var task = new AsstCustomTask() {
|
||||
CustomTasks = [.. custom.CustomTaskName.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(task => task.Trim())],
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Custom, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
/// <summary>
|
||||
/// 理智作战
|
||||
/// </summary>
|
||||
public class FightSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class FightSettingsUserControlModel : TaskSettingsViewModel, FightSettingsUserControlModel.ISerialize
|
||||
{
|
||||
private static readonly ILogger _logger = Log.ForContext<FightSettingsUserControlModel>();
|
||||
private static readonly Lock _lock = new();
|
||||
@@ -702,61 +702,7 @@ public class FightSettingsUserControlModel : TaskSettingsViewModel
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
{
|
||||
if (baseTask is not FightTask fight || taskId is int and <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (fight.UseWeeklySchedule && fight.WeeklySchedule.TryGetValue(Instances.TaskQueueViewModel.CurDayOfWeek, out var isEnabled) && !isEnabled)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var scope = _lock.EnterScope();
|
||||
var stage = GetFightStage(fight);
|
||||
if (stage is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var task = new AsstFightTask() {
|
||||
Stage = stage,
|
||||
Medicine = fight.UseMedicine != false ? fight.MedicineCount : 0,
|
||||
Stone = fight.UseStone != false ? fight.StoneCount : 0,
|
||||
Series = fight.Series,
|
||||
MaxTimes = fight.EnableTimesLimit != false ? fight.TimesLimit : int.MaxValue,
|
||||
ExpiringMedicine = fight.UseExpiringMedicine ? 9999 : 0,
|
||||
IsDrGrandet = fight.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 (task.Stage == "Annihilation" && fight.UseCustomAnnihilation)
|
||||
{
|
||||
task.Stage = fight.AnnihilationStage;
|
||||
}
|
||||
|
||||
if (fight.EnableTargetDrop != false && !string.IsNullOrEmpty(fight.DropId))
|
||||
{
|
||||
task.Drops.Add(fight.DropId, fight.DropCount);
|
||||
}
|
||||
|
||||
if (fight.EnableTimesLimit is not false && fight.Series > 0 && fight.TimesLimit % fight.Series != 0)
|
||||
{
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetStringFormat("FightTimesMayNotExhausted", fight.TimesLimit, fight.Series), UiLogColor.Warning);
|
||||
}
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Fight, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize).Serialize(baseTask, taskId);
|
||||
|
||||
#region 关卡列表更新
|
||||
|
||||
@@ -962,4 +908,63 @@ public class FightSettingsUserControlModel : TaskSettingsViewModel
|
||||
// 仅供 ComboBox本身 和 手写Stage的TextBlock 绑定使用
|
||||
public bool IsOpen { get => field; set => SetAndNotify(ref field, value); } = Instances.TaskQueueViewModel.IsStageOpen(stage);
|
||||
}
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
if (baseTask is not FightTask fight || taskId is int and <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (fight.UseWeeklySchedule && fight.WeeklySchedule.TryGetValue(Instances.TaskQueueViewModel.CurDayOfWeek, out var isEnabled) && !isEnabled)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var scope = _lock.EnterScope();
|
||||
var stage = GetFightStage(fight);
|
||||
if (stage is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var task = new AsstFightTask() {
|
||||
Stage = stage,
|
||||
Medicine = fight.UseMedicine != false ? fight.MedicineCount : 0,
|
||||
Stone = fight.UseStone != false ? fight.StoneCount : 0,
|
||||
Series = fight.Series,
|
||||
MaxTimes = fight.EnableTimesLimit != false ? fight.TimesLimit : int.MaxValue,
|
||||
ExpiringMedicine = fight.UseExpiringMedicine ? 9999 : 0,
|
||||
IsDrGrandet = fight.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 (task.Stage == "Annihilation" && fight.UseCustomAnnihilation)
|
||||
{
|
||||
task.Stage = fight.AnnihilationStage;
|
||||
}
|
||||
|
||||
if (fight.EnableTargetDrop != false && !string.IsNullOrEmpty(fight.DropId))
|
||||
{
|
||||
task.Drops.Add(fight.DropId, fight.DropCount);
|
||||
}
|
||||
|
||||
if (fight.EnableTimesLimit is not false && fight.Series > 0 && fight.TimesLimit % fight.Series != 0)
|
||||
{
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetStringFormat("FightTimesMayNotExhausted", fight.TimesLimit, fight.Series), UiLogColor.Warning);
|
||||
}
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Fight, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,11 @@ using MaaWpfGui.Constants.Enums;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Models;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.States;
|
||||
using MaaWpfGui.Utilities;
|
||||
using MaaWpfGui.Utilities.ValueType;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
@@ -42,7 +40,7 @@ using Mode = InfrastMode;
|
||||
/// <summary>
|
||||
/// 基建任务
|
||||
/// </summary>
|
||||
public class InfrastSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class InfrastSettingsUserControlModel : TaskSettingsViewModel, InfrastSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static InfrastSettingsUserControlModel()
|
||||
{
|
||||
@@ -543,59 +541,64 @@ public class InfrastSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize).Serialize(baseTask, taskId);
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
if (baseTask is not InfrastTask infrast)
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var task = new AsstInfrastTask {
|
||||
Mode = infrast.Mode,
|
||||
Facilitys = [.. infrast.RoomList.Where(i => i.IsEnabled).Select(i => i.Room.ToString())],
|
||||
UsesOfDrones = infrast.UsesOfDrones,
|
||||
ContinueTraining = infrast.ContinueTraining,
|
||||
DormThreshold = infrast.DormThreshold / 100.0,
|
||||
DormFilterNotStationedEnabled = infrast.DormFilterNotStationed,
|
||||
DormTrustEnabled = infrast.DormTrustEnabled,
|
||||
OriginiumShardAutoReplenishment = infrast.OriginiumShardAutoReplenishment,
|
||||
ReceptionMessageBoard = infrast.ReceptionMessageBoard,
|
||||
ReceptionClueExchange = infrast.ReceptionClueExchange,
|
||||
ReceptionSendClue = infrast.SendClue,
|
||||
Filename = infrast.Filename,
|
||||
};
|
||||
|
||||
if (infrast.Mode != Mode.Custom)
|
||||
{
|
||||
}
|
||||
else if (infrast.PlanSelect != -1 && infrast.InfrastPlan.Count <= infrast.PlanSelect)
|
||||
{
|
||||
throw new InvalidOperationException(LocalizationHelper.GetString("CustomInfrastPlanSelectOutOfIndex"));
|
||||
}
|
||||
else if (infrast.PlanSelect >= 0)
|
||||
{
|
||||
task.PlanIndex = infrast.PlanSelect;
|
||||
}
|
||||
else
|
||||
{
|
||||
var now = TimeOnly.FromDateTime(DateTime.Now.ToLocalTime());
|
||||
if (infrast.InfrastPlan.FirstOrDefault(i => i.Period.Any(p => p[0] <= now && now <= p[1])) is { } plan)
|
||||
if (baseTask is not InfrastTask infrast)
|
||||
{
|
||||
task.PlanIndex = plan.Index;
|
||||
return null;
|
||||
}
|
||||
|
||||
var task = new AsstInfrastTask {
|
||||
Mode = infrast.Mode,
|
||||
Facilitys = [.. infrast.RoomList.Where(i => i.IsEnabled).Select(i => i.Room.ToString())],
|
||||
UsesOfDrones = infrast.UsesOfDrones,
|
||||
ContinueTraining = infrast.ContinueTraining,
|
||||
DormThreshold = infrast.DormThreshold / 100.0,
|
||||
DormFilterNotStationedEnabled = infrast.DormFilterNotStationed,
|
||||
DormTrustEnabled = infrast.DormTrustEnabled,
|
||||
OriginiumShardAutoReplenishment = infrast.OriginiumShardAutoReplenishment,
|
||||
ReceptionMessageBoard = infrast.ReceptionMessageBoard,
|
||||
ReceptionClueExchange = infrast.ReceptionClueExchange,
|
||||
ReceptionSendClue = infrast.SendClue,
|
||||
Filename = infrast.Filename,
|
||||
};
|
||||
|
||||
if (infrast.Mode != Mode.Custom)
|
||||
{
|
||||
}
|
||||
else if (infrast.PlanSelect != -1 && infrast.InfrastPlan.Count <= infrast.PlanSelect)
|
||||
{
|
||||
throw new InvalidOperationException(LocalizationHelper.GetString("CustomInfrastPlanSelectOutOfIndex"));
|
||||
}
|
||||
else if (infrast.PlanSelect >= 0)
|
||||
{
|
||||
task.PlanIndex = infrast.PlanSelect;
|
||||
}
|
||||
else
|
||||
{
|
||||
task.PlanIndex = 0;
|
||||
_logger.Warning("No valid plan found for current time, use PlanIndex 0");
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CustomInfrastFileHasPlanNoPeriod"), UiLogColor.Error);
|
||||
var now = TimeOnly.FromDateTime(DateTime.Now.ToLocalTime());
|
||||
if (infrast.InfrastPlan.FirstOrDefault(i => i.Period.Any(p => p[0] <= now && now <= p[1])) is { } plan)
|
||||
{
|
||||
task.PlanIndex = plan.Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
task.PlanIndex = 0;
|
||||
_logger.Warning("No valid plan found for current time, use PlanIndex 0");
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CustomInfrastFileHasPlanNoPeriod"), UiLogColor.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Infrast, task),
|
||||
_ => null,
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Infrast, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
/// <summary>
|
||||
/// 信用购物
|
||||
/// </summary>
|
||||
public class MallSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class MallSettingsUserControlModel : TaskSettingsViewModel, MallSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static MallSettingsUserControlModel()
|
||||
{
|
||||
@@ -190,65 +190,70 @@ public class MallSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize)?.Serialize(baseTask, taskId);
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
if (baseTask is not MallTask mall)
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var fightStageEmpty = false;
|
||||
var tasks = ConfigFactory.CurrentConfig.TaskQueue;
|
||||
int taskIndex = -1, stageIndex = -1;
|
||||
for (int i = 0; i < tasks.Count; i++)
|
||||
{
|
||||
if (ConfigFactory.CurrentConfig.TaskQueue.ElementAt(i) is not FightTask t)
|
||||
if (baseTask is not MallTask mall)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!TaskQueueViewModel.IsTaskEnable(t))
|
||||
{
|
||||
continue;
|
||||
return null;
|
||||
}
|
||||
|
||||
var weekly = Enum.GetValues<DayOfWeek>().Where(d => !t.UseWeeklySchedule || (t.WeeklySchedule.TryGetValue(d, out var isEnabled) && isEnabled));
|
||||
if (weekly.Any(day => GetStageForDayOfWeek(t, day) == string.Empty))
|
||||
var fightStageEmpty = false;
|
||||
var tasks = ConfigFactory.CurrentConfig.TaskQueue;
|
||||
int taskIndex = -1, stageIndex = -1;
|
||||
for (int i = 0; i < tasks.Count; i++)
|
||||
{
|
||||
taskIndex = i;
|
||||
stageIndex = t.StagePlan.IndexOf(string.Empty);
|
||||
fightStageEmpty = true;
|
||||
break;
|
||||
if (ConfigFactory.CurrentConfig.TaskQueue.ElementAt(i) is not FightTask t)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!TaskQueueViewModel.IsTaskEnable(t))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var weekly = Enum.GetValues<DayOfWeek>().Where(d => !t.UseWeeklySchedule || (t.WeeklySchedule.TryGetValue(d, out var isEnabled) && isEnabled));
|
||||
if (weekly.Any(day => GetStageForDayOfWeek(t, day) == string.Empty))
|
||||
{
|
||||
taskIndex = i;
|
||||
stageIndex = t.StagePlan.IndexOf(string.Empty);
|
||||
fightStageEmpty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mall.IsCreditFightAvailable && fightStageEmpty)
|
||||
{
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetStringFormat("CreditFightWhenOF-1Warning", ConfigFactory.CurrentConfig.TaskQueue[taskIndex].Name, taskIndex + 1, stageIndex + 1), UiLogColor.Warning);
|
||||
}
|
||||
if (mall.IsCreditFightAvailable && fightStageEmpty)
|
||||
{
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetStringFormat("CreditFightWhenOF-1Warning", ConfigFactory.CurrentConfig.TaskQueue[taskIndex].Name, taskIndex + 1, stageIndex + 1), UiLogColor.Warning);
|
||||
}
|
||||
|
||||
var task = new AsstMallTask() {
|
||||
CreditFight = mall.IsCreditFightAvailable && !fightStageEmpty,
|
||||
FormationIndex = mall.CreditFightFormation,
|
||||
VisitFriends = mall.IsVisitFriendsAvailable,
|
||||
WithShopping = mall.Shopping,
|
||||
FirstList = [.. mall.FirstList.Split(';').Select(s => s.Trim())],
|
||||
Blacklist = [.. mall.BlackList.Split(';').Select(s => s.Trim()).Union(_blackCharacterListMapping[SettingsViewModel.GameSettings.ClientType])],
|
||||
ForceShoppingIfCreditFull = mall.ShoppingIgnoreBlackListWhenFull,
|
||||
OnlyBuyDiscount = mall.OnlyBuyDiscount,
|
||||
ReserveMaxCredit = mall.ReserveMaxCredit,
|
||||
};
|
||||
var task = new AsstMallTask() {
|
||||
CreditFight = mall.IsCreditFightAvailable && !fightStageEmpty,
|
||||
FormationIndex = mall.CreditFightFormation,
|
||||
VisitFriends = mall.IsVisitFriendsAvailable,
|
||||
WithShopping = mall.Shopping,
|
||||
FirstList = [.. mall.FirstList.Split(';').Select(s => s.Trim())],
|
||||
Blacklist = [.. mall.BlackList.Split(';').Select(s => s.Trim()).Union(Instance._blackCharacterListMapping[SettingsViewModel.GameSettings.ClientType])],
|
||||
ForceShoppingIfCreditFull = mall.ShoppingIgnoreBlackListWhenFull,
|
||||
OnlyBuyDiscount = mall.OnlyBuyDiscount,
|
||||
ReserveMaxCredit = mall.ReserveMaxCredit,
|
||||
};
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Mall, task),
|
||||
_ => null,
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Mall, task),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
string? GetStageForDayOfWeek(FightTask fightTask, DayOfWeek day)
|
||||
{
|
||||
var result = fightTask.StagePlan.FirstOrDefault(stage => Instances.StageManager.IsStageOpen(stage, day));
|
||||
result ??= fightTask.StagePlan.FirstOrDefault();
|
||||
return result;
|
||||
string? GetStageForDayOfWeek(FightTask fightTask, DayOfWeek day)
|
||||
{
|
||||
var result = fightTask.StagePlan.FirstOrDefault(stage => Instances.StageManager.IsStageOpen(stage, day));
|
||||
result ??= fightTask.StagePlan.FirstOrDefault();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ using Theme = MaaWpfGui.Configuration.Single.MaaTask.ReclamationTheme;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
public class ReclamationSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class ReclamationSettingsUserControlModel : TaskSettingsViewModel, ReclamationSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static ReclamationSettingsUserControlModel()
|
||||
{
|
||||
@@ -137,27 +137,32 @@ public class ReclamationSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize)?.Serialize(baseTask, taskId);
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
if (baseTask is not ReclamationTask reclamation)
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
return null;
|
||||
if (baseTask is not ReclamationTask reclamation)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var toolToCraft = !string.IsNullOrEmpty(reclamation.ToolToCraft) ? reclamation.ToolToCraft : LocalizationHelper.GetString("ReclamationToolToCraftPlaceholder", DataHelper.ClientLanguageMapper[SettingsViewModel.GameSettings.ClientType]);
|
||||
var task = new AsstReclamationTask() {
|
||||
Theme = reclamation.Theme,
|
||||
Mode = reclamation.Mode,
|
||||
IncrementMode = reclamation.IncrementMode,
|
||||
MaxCraftCountPerRound = reclamation.MaxCraftCountPerRound,
|
||||
ToolToCraft = [.. toolToCraft.Split(';').Select(s => s.Trim())],
|
||||
ClearStore = reclamation.ClearStore,
|
||||
};
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Reclamation, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
var toolToCraft = !string.IsNullOrEmpty(reclamation.ToolToCraft) ? reclamation.ToolToCraft : LocalizationHelper.GetString("ReclamationToolToCraftPlaceholder", DataHelper.ClientLanguageMapper[SettingsViewModel.GameSettings.ClientType]);
|
||||
var task = new AsstReclamationTask() {
|
||||
Theme = reclamation.Theme,
|
||||
Mode = reclamation.Mode,
|
||||
IncrementMode = reclamation.IncrementMode,
|
||||
MaxCraftCountPerRound = reclamation.MaxCraftCountPerRound,
|
||||
ToolToCraft = [.. toolToCraft.Split(';').Select(s => s.Trim())],
|
||||
ClearStore = reclamation.ClearStore,
|
||||
};
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Reclamation, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
/// <summary>
|
||||
/// 自动公招model
|
||||
/// </summary>
|
||||
public class RecruitSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class RecruitSettingsUserControlModel : TaskSettingsViewModel, RecruitSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static RecruitSettingsUserControlModel()
|
||||
{
|
||||
@@ -254,60 +254,65 @@ public class RecruitSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize)?.Serialize(baseTask, taskId);
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
if (baseTask is not RecruitTask recruit)
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
return null;
|
||||
if (baseTask is not RecruitTask recruit)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var task = new AsstRecruitTask() {
|
||||
Refresh = recruit.RefreshLevel3,
|
||||
ForceRefresh = recruit.ForceRefresh,
|
||||
SetRecruitTime = true,
|
||||
RecruitTimes = recruit.MaxTimes,
|
||||
UseExpedited = recruit.UseExpedited is not false,
|
||||
ExpeditedTimes = recruit.MaxTimes,
|
||||
SelectExtraTags = recruit.ExtraTagMode,
|
||||
Level3FirstList = recruit.Level3PreferTags,
|
||||
NotChooseLevel1 = recruit.Level1NotChoose,
|
||||
ChooseLevel3Time = recruit.Level3Time,
|
||||
ChooseLevel4Time = recruit.Level4Time,
|
||||
ChooseLevel5Time = recruit.Level5Time,
|
||||
ReportToPenguin = SettingsViewModel.GameSettings.EnablePenguin,
|
||||
ReportToYituliu = SettingsViewModel.GameSettings.EnableYituliu,
|
||||
PenguinId = SettingsViewModel.GameSettings.PenguinId,
|
||||
YituliuId = SettingsViewModel.GameSettings.PenguinId,
|
||||
ServerType = Instances.SettingsViewModel.ServerType,
|
||||
};
|
||||
|
||||
if (recruit.Level1NotChoose)
|
||||
{
|
||||
task.ConfirmList.Add(1);
|
||||
}
|
||||
|
||||
if (recruit.Level3Choose)
|
||||
{
|
||||
task.ConfirmList.Add(3);
|
||||
}
|
||||
|
||||
if (recruit.Level4Choose)
|
||||
{
|
||||
task.SelectList.Add(4);
|
||||
task.ConfirmList.Add(4);
|
||||
}
|
||||
|
||||
// ReSharper disable once InvertIf
|
||||
if (recruit.Level5Choose)
|
||||
{
|
||||
task.SelectList.Add(5);
|
||||
task.ConfirmList.Add(5);
|
||||
}
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Recruit, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
var task = new AsstRecruitTask() {
|
||||
Refresh = recruit.RefreshLevel3,
|
||||
ForceRefresh = recruit.ForceRefresh,
|
||||
SetRecruitTime = true,
|
||||
RecruitTimes = recruit.MaxTimes,
|
||||
UseExpedited = recruit.UseExpedited is not false,
|
||||
ExpeditedTimes = recruit.MaxTimes,
|
||||
SelectExtraTags = recruit.ExtraTagMode,
|
||||
Level3FirstList = recruit.Level3PreferTags,
|
||||
NotChooseLevel1 = recruit.Level1NotChoose,
|
||||
ChooseLevel3Time = recruit.Level3Time,
|
||||
ChooseLevel4Time = recruit.Level4Time,
|
||||
ChooseLevel5Time = recruit.Level5Time,
|
||||
ReportToPenguin = SettingsViewModel.GameSettings.EnablePenguin,
|
||||
ReportToYituliu = SettingsViewModel.GameSettings.EnableYituliu,
|
||||
PenguinId = SettingsViewModel.GameSettings.PenguinId,
|
||||
YituliuId = SettingsViewModel.GameSettings.PenguinId,
|
||||
ServerType = Instances.SettingsViewModel.ServerType,
|
||||
};
|
||||
|
||||
if (recruit.Level1NotChoose)
|
||||
{
|
||||
task.ConfirmList.Add(1);
|
||||
}
|
||||
|
||||
if (recruit.Level3Choose)
|
||||
{
|
||||
task.ConfirmList.Add(3);
|
||||
}
|
||||
|
||||
if (recruit.Level4Choose)
|
||||
{
|
||||
task.SelectList.Add(4);
|
||||
task.ConfirmList.Add(4);
|
||||
}
|
||||
|
||||
// ReSharper disable once InvertIf
|
||||
if (recruit.Level5Choose)
|
||||
{
|
||||
task.SelectList.Add(5);
|
||||
task.ConfirmList.Add(5);
|
||||
}
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Recruit, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ using MaaWpfGui.Constants.Enums;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Main;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.Utilities;
|
||||
using MaaWpfGui.Utilities.ValueType;
|
||||
using MaaWpfGui.ViewModels.UI;
|
||||
@@ -36,7 +35,7 @@ using Theme = MaaWpfGui.Configuration.Single.MaaTask.RoguelikeTheme;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
public class RoguelikeSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class RoguelikeSettingsUserControlModel : TaskSettingsViewModel, RoguelikeSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static RoguelikeSettingsUserControlModel()
|
||||
{
|
||||
@@ -536,10 +535,8 @@ public class RoguelikeSettingsUserControlModel : TaskSettingsViewModel
|
||||
/// </summary>
|
||||
public string RoguelikeThemeTip
|
||||
{
|
||||
get
|
||||
{
|
||||
var key = RoguelikeTheme switch
|
||||
{
|
||||
get {
|
||||
var key = RoguelikeTheme switch {
|
||||
Theme.Phantom => "RoguelikeThemeTipPhantom",
|
||||
Theme.Mizuki => "RoguelikeThemeTipMizuki",
|
||||
Theme.Sami => "RoguelikeThemeTipSami",
|
||||
@@ -1055,65 +1052,69 @@ public class RoguelikeSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize)?.Serialize(baseTask, taskId);
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
if (baseTask is not RoguelikeTask roguelike)
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bool roguelikeSquadIsProfessional = roguelike.Mode == Mode.Collectible && roguelike.Theme != Theme.Phantom && roguelike.Squad is "突击战术分队" or "堡垒战术分队" or "远程战术分队" or "破坏战术分队";
|
||||
bool roguelikeSquadIsFoldartal = roguelike.Mode == Mode.Collectible && roguelike.Theme == Theme.Sami && roguelike.Squad == "生活至上分队";
|
||||
var task = new AsstRoguelikeTask() {
|
||||
Theme = roguelike.Theme,
|
||||
Mode = roguelike.Mode,
|
||||
Starts = roguelike.StartCount,
|
||||
Difficulty = roguelike.Difficulty,
|
||||
Squad = roguelike.Squad,
|
||||
Roles = roguelike.Roles,
|
||||
CoreChar = DataHelper.GetCharacterByNameOrAlias(roguelike.CoreChar)?.Name ?? roguelike.CoreChar,
|
||||
UseSupport = roguelike.UseSupport,
|
||||
UseSupportNonFriend = roguelike.UseSupportNonFriend,
|
||||
|
||||
InvestmentEnabled = roguelike.Investment,
|
||||
InvestmentCount = roguelike.InvestCount,
|
||||
InvestmentStopWhenFull = roguelike.StopWhenDepositFull,
|
||||
InvestmentWithMoreScore = roguelike.InvestWithMoreScore && roguelike.Mode == Mode.Investment,
|
||||
RefreshTraderWithDice = roguelike.Theme == Theme.Mizuki && roguelike.RefreshTraderWithDice,
|
||||
|
||||
StopAtFinalBoss = roguelike.StopAtFinalBoss,
|
||||
StopAtMaxLevel = roguelike.StopWhenLevelMax,
|
||||
|
||||
// 刷开局
|
||||
CollectibleModeSquad = roguelike.SquadCollectible,
|
||||
CollectibleModeShopping = roguelike.CollectibleShopping,
|
||||
StartWithEliteTwo = roguelike.StartWithEliteTwo && roguelikeSquadIsProfessional && roguelike.Theme is Theme.Mizuki or Theme.Sami,
|
||||
StartWithEliteTwoNonBattle = roguelike.StartWithEliteTwoOnly && roguelike.Theme is Theme.Mizuki or Theme.Sami,
|
||||
|
||||
// 月度小队
|
||||
MonthlySquadAutoIterate = roguelike.MonthlySquadAutoIterate,
|
||||
MonthlySquadCheckComms = roguelike.MonthlySquadCheckComms,
|
||||
|
||||
// 深入探索
|
||||
DeepExplorationAutoIterate = roguelike.DeepExplorationAutoIterate,
|
||||
|
||||
// 刷常乐节点
|
||||
FindPlaytimeTarget = roguelike.FindPlaytimeTarget, // 等待添加到 RoguelikeTask
|
||||
|
||||
SamiFirstFloorFoldartal = roguelike.Theme == Theme.Sami && roguelike.Mode == Mode.Collectible && roguelike.SamiFirstFloorFoldartal,
|
||||
SamiStartFloorFoldartal = roguelike.SamiFirstFloorFoldartals,
|
||||
SamiNewSquad2StartingFoldartal = roguelike.SamiNewSquad2StartingFoldartal && roguelikeSquadIsFoldartal,
|
||||
SamiNewSquad2StartingFoldartals = [.. roguelike.SamiNewSquad2StartingFoldartals.Split(';').Where(i => !string.IsNullOrEmpty(i)).Take(3)],
|
||||
|
||||
ExpectedCollapsalParadigms = [.. roguelike.ExpectedCollapsalParadigms.Split(';').Where(i => !string.IsNullOrEmpty(i))],
|
||||
|
||||
StartWithSeed = roguelike.StartWithSeed ? roguelike.Seed : null,
|
||||
};
|
||||
|
||||
if (RoguelikeMode == Mode.Collectible && !RoguelikeOnlyStartWithEliteTwo)
|
||||
{
|
||||
var rewardKeys = new Dictionary<RoguelikeCollectibleAward, string>
|
||||
if (baseTask is not RoguelikeTask roguelike)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bool roguelikeSquadIsProfessional = roguelike.Mode == Mode.Collectible && roguelike.Theme != Theme.Phantom && roguelike.Squad is "突击战术分队" or "堡垒战术分队" or "远程战术分队" or "破坏战术分队";
|
||||
bool roguelikeSquadIsFoldartal = roguelike.Mode == Mode.Collectible && roguelike.Theme == Theme.Sami && roguelike.Squad == "生活至上分队";
|
||||
var task = new AsstRoguelikeTask() {
|
||||
Theme = roguelike.Theme,
|
||||
Mode = roguelike.Mode,
|
||||
Starts = roguelike.StartCount,
|
||||
Difficulty = roguelike.Difficulty,
|
||||
Squad = roguelike.Squad,
|
||||
Roles = roguelike.Roles,
|
||||
CoreChar = DataHelper.GetCharacterByNameOrAlias(roguelike.CoreChar)?.Name ?? roguelike.CoreChar,
|
||||
UseSupport = roguelike.UseSupport,
|
||||
UseSupportNonFriend = roguelike.UseSupportNonFriend,
|
||||
|
||||
InvestmentEnabled = roguelike.Investment,
|
||||
InvestmentCount = roguelike.InvestCount,
|
||||
InvestmentStopWhenFull = roguelike.StopWhenDepositFull,
|
||||
InvestmentWithMoreScore = roguelike.InvestWithMoreScore && roguelike.Mode == Mode.Investment,
|
||||
RefreshTraderWithDice = roguelike.Theme == Theme.Mizuki && roguelike.RefreshTraderWithDice,
|
||||
|
||||
StopAtFinalBoss = roguelike.StopAtFinalBoss,
|
||||
StopAtMaxLevel = roguelike.StopWhenLevelMax,
|
||||
|
||||
// 刷开局
|
||||
CollectibleModeSquad = roguelike.SquadCollectible,
|
||||
CollectibleModeShopping = roguelike.CollectibleShopping,
|
||||
StartWithEliteTwo = roguelike.StartWithEliteTwo && roguelikeSquadIsProfessional && roguelike.Theme is Theme.Mizuki or Theme.Sami,
|
||||
StartWithEliteTwoNonBattle = roguelike.StartWithEliteTwoOnly && roguelike.Theme is Theme.Mizuki or Theme.Sami,
|
||||
|
||||
// 月度小队
|
||||
MonthlySquadAutoIterate = roguelike.MonthlySquadAutoIterate,
|
||||
MonthlySquadCheckComms = roguelike.MonthlySquadCheckComms,
|
||||
|
||||
// 深入探索
|
||||
DeepExplorationAutoIterate = roguelike.DeepExplorationAutoIterate,
|
||||
|
||||
// 刷常乐节点
|
||||
FindPlaytimeTarget = roguelike.FindPlaytimeTarget, // 等待添加到 RoguelikeTask
|
||||
|
||||
SamiFirstFloorFoldartal = roguelike.Theme == Theme.Sami && roguelike.Mode == Mode.Collectible && roguelike.SamiFirstFloorFoldartal,
|
||||
SamiStartFloorFoldartal = roguelike.SamiFirstFloorFoldartals,
|
||||
SamiNewSquad2StartingFoldartal = roguelike.SamiNewSquad2StartingFoldartal && roguelikeSquadIsFoldartal,
|
||||
SamiNewSquad2StartingFoldartals = [.. roguelike.SamiNewSquad2StartingFoldartals.Split(';').Where(i => !string.IsNullOrEmpty(i)).Take(3)],
|
||||
|
||||
ExpectedCollapsalParadigms = [.. roguelike.ExpectedCollapsalParadigms.Split(';').Where(i => !string.IsNullOrEmpty(i))],
|
||||
|
||||
StartWithSeed = roguelike.StartWithSeed ? roguelike.Seed : null,
|
||||
};
|
||||
|
||||
if (Instance.RoguelikeMode == Mode.Collectible && !Instance.RoguelikeOnlyStartWithEliteTwo)
|
||||
{
|
||||
var rewardKeys = new Dictionary<RoguelikeCollectibleAward, string>
|
||||
{
|
||||
{ RoguelikeCollectibleAward.HotWater, "hot_water" },
|
||||
{ RoguelikeCollectibleAward.Shield, "shield" },
|
||||
{ RoguelikeCollectibleAward.Ingot, "ingot" },
|
||||
@@ -1125,20 +1126,21 @@ public class RoguelikeSettingsUserControlModel : TaskSettingsViewModel
|
||||
{ RoguelikeCollectibleAward.Ticket, "ticket" },
|
||||
};
|
||||
|
||||
var startWithSelect = new JObject();
|
||||
foreach (var select in RoguelikeStartWithSelectList.Cast<GenericCombinedData<RoguelikeCollectibleAward>>())
|
||||
{
|
||||
if (rewardKeys.TryGetValue(select.Value, out var paramKey))
|
||||
var startWithSelect = new JObject();
|
||||
foreach (var select in Instance.RoguelikeStartWithSelectList.Cast<GenericCombinedData<RoguelikeCollectibleAward>>())
|
||||
{
|
||||
task.CollectibleModeStartRewards[paramKey] = true;
|
||||
if (rewardKeys.TryGetValue(select.Value, out var paramKey))
|
||||
{
|
||||
task.CollectibleModeStartRewards[paramKey] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Roguelike, task),
|
||||
_ => null,
|
||||
};
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.Roguelike, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// </copyright>
|
||||
|
||||
#nullable enable
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using MaaWpfGui.Configuration.Single.MaaTask;
|
||||
using MaaWpfGui.Constants;
|
||||
@@ -20,14 +19,13 @@ using MaaWpfGui.Constants.Enums;
|
||||
using MaaWpfGui.Helper;
|
||||
using MaaWpfGui.Main;
|
||||
using MaaWpfGui.Models.AsstTasks;
|
||||
using MaaWpfGui.Services;
|
||||
using MaaWpfGui.ViewModels.UI;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using static MaaWpfGui.Main.AsstProxy;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
public class StartUpSettingsUserControlModel : TaskSettingsViewModel
|
||||
public class StartUpSettingsUserControlModel : TaskSettingsViewModel, StartUpSettingsUserControlModel.ISerialize
|
||||
{
|
||||
static StartUpSettingsUserControlModel()
|
||||
{
|
||||
@@ -68,29 +66,34 @@ public class StartUpSettingsUserControlModel : TaskSettingsViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null)
|
||||
public override bool? SerializeTask(BaseTask? baseTask, int? taskId = null) => (this as ISerialize)?.Serialize(baseTask, taskId);
|
||||
|
||||
private interface ISerialize : ITaskQueueModelSerialize
|
||||
{
|
||||
if (baseTask is not StartUpTask startUp)
|
||||
bool? ITaskQueueModelSerialize.Serialize(BaseTask? baseTask, int? taskId)
|
||||
{
|
||||
return null;
|
||||
if (baseTask is not StartUpTask startUp)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var clientType = SettingsViewModel.GameSettings.ClientType;
|
||||
var accountName = clientType switch {
|
||||
ClientType.Official or ClientType.Bilibili => startUp.AccountName,
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
var task = new AsstStartUpTask() {
|
||||
ClientType = clientType,
|
||||
StartGame = SettingsViewModel.GameSettings.StartGame,
|
||||
AccountName = accountName,
|
||||
};
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.StartUp, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
var clientType = SettingsViewModel.GameSettings.ClientType;
|
||||
var accountName = clientType switch {
|
||||
ClientType.Official or ClientType.Bilibili => startUp.AccountName,
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
var task = new AsstStartUpTask() {
|
||||
ClientType = clientType,
|
||||
StartGame = SettingsViewModel.GameSettings.StartGame,
|
||||
AccountName = accountName,
|
||||
};
|
||||
|
||||
return taskId switch {
|
||||
int id when id > 0 => Instances.AsstProxy.AsstSetTaskParamsEncoded(id, task),
|
||||
null => Instances.AsstProxy.AsstAppendTaskWithEncoding(TaskType.StartUp, task),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user