mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 10:32:19 +08:00
chore: 整合枚举类 OperProfession 和 Role (#13914)
* chore: 整合枚举类OperProfession和Role * fix: 加载数据时报错
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// <copyright file="Role.cs" company="MaaAssistantArknights">
|
||||
// <copyright file="OperatorType.cs" company="MaaAssistantArknights">
|
||||
// Part of the MaaWpfGui project, maintained by the MaaAssistantArknights team (Maa Team)
|
||||
// Copyright (C) 2021-2025 MaaAssistantArknights Contributors
|
||||
//
|
||||
@@ -16,8 +16,13 @@ namespace MaaWpfGui.Constants.Enums;
|
||||
/// <summary>
|
||||
/// 干员职业类型枚举。
|
||||
/// </summary>
|
||||
public enum Role
|
||||
public enum OperatorType
|
||||
{
|
||||
/// <summary>
|
||||
/// 未知, 默认值
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// 近卫/Guard
|
||||
/// </summary>
|
||||
@@ -62,4 +67,14 @@ public enum Role
|
||||
/// 无人机/召唤物/Drone/Summon
|
||||
/// </summary>
|
||||
Drone,
|
||||
|
||||
/// <summary>
|
||||
/// 召唤物 (from asst::BattleDataConfig, MAA内部分类使用Drone
|
||||
/// </summary>
|
||||
Token = Drone,
|
||||
|
||||
/// <summary>
|
||||
/// 装置
|
||||
/// </summary>
|
||||
Trap,
|
||||
}
|
||||
@@ -18,6 +18,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MaaWpfGui.Constants;
|
||||
using MaaWpfGui.Constants.Enums;
|
||||
using MaaWpfGui.ViewModels.UI;
|
||||
using MaaWpfGui.ViewModels.UserControl.Settings;
|
||||
using Newtonsoft.Json;
|
||||
@@ -372,7 +373,7 @@ namespace MaaWpfGui.Helper
|
||||
public string? Position { get; set; }
|
||||
|
||||
[JsonProperty("profession")]
|
||||
public OperProfession Profession { get; set; } = OperProfession.Unknown;
|
||||
public OperatorType Type { get; set; } = OperatorType.Unknown;
|
||||
|
||||
[JsonProperty("rangeId")]
|
||||
public List<string>? RangeId { get; set; }
|
||||
@@ -380,73 +381,15 @@ namespace MaaWpfGui.Helper
|
||||
[JsonProperty("rarity")]
|
||||
public int Rarity { get; set; }
|
||||
|
||||
public bool IsOperator => Profession is
|
||||
OperProfession.Caster or
|
||||
OperProfession.Medic or
|
||||
OperProfession.Pioneer or
|
||||
OperProfession.Sniper or
|
||||
OperProfession.Special or
|
||||
OperProfession.Support or
|
||||
OperProfession.Tank or
|
||||
OperProfession.Warrior;
|
||||
|
||||
public enum OperProfession
|
||||
{
|
||||
/// <summary>
|
||||
/// 未知, 默认值
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// 术士
|
||||
/// </summary>
|
||||
Caster,
|
||||
|
||||
/// <summary>
|
||||
/// 医疗
|
||||
/// </summary>
|
||||
Medic,
|
||||
|
||||
/// <summary>
|
||||
/// 先锋
|
||||
/// </summary>
|
||||
Pioneer,
|
||||
|
||||
/// <summary>
|
||||
/// 狙击
|
||||
/// </summary>
|
||||
Sniper,
|
||||
|
||||
/// <summary>
|
||||
/// 特种
|
||||
/// </summary>
|
||||
Special,
|
||||
|
||||
/// <summary>
|
||||
/// 辅助
|
||||
/// </summary>
|
||||
Support,
|
||||
|
||||
/// <summary>
|
||||
/// 重装
|
||||
/// </summary>
|
||||
Tank,
|
||||
|
||||
/// <summary>
|
||||
/// 近卫
|
||||
/// </summary>
|
||||
Warrior,
|
||||
|
||||
/// <summary>
|
||||
/// 召唤物 (from asst::BattleDataConfig, MAA内部分类使用Drone
|
||||
/// </summary>
|
||||
Token,
|
||||
|
||||
/// <summary>
|
||||
/// 未知?
|
||||
/// </summary>
|
||||
Trap,
|
||||
}
|
||||
public bool IsOperator => Type is
|
||||
OperatorType.Caster or
|
||||
OperatorType.Medic or
|
||||
OperatorType.Pioneer or
|
||||
OperatorType.Sniper or
|
||||
OperatorType.Special or
|
||||
OperatorType.Support or
|
||||
OperatorType.Tank or
|
||||
OperatorType.Warrior;
|
||||
|
||||
[JsonIgnore]
|
||||
public string CodeName => ExtractCodeName(Id);
|
||||
|
||||
@@ -83,27 +83,27 @@ public class SSSCopilotModel : CopilotBase
|
||||
[JsonProperty("stages")]
|
||||
public List<Stage>? Stages { get; set; }
|
||||
|
||||
private static readonly Dictionary<Role, string[]> _roleAliases = new()
|
||||
private static readonly Dictionary<OperatorType, string[]> _typeAliases = new()
|
||||
{
|
||||
{ Role.Warrior, ["Warrior", "Guard", "近卫"] },
|
||||
{ Role.Pioneer, ["Pioneer", "Vanguard", "先锋"] },
|
||||
{ Role.Medic, ["Medic", "医疗"] },
|
||||
{ Role.Tank, ["Tank", "Defender", "重装", "坦克"] },
|
||||
{ Role.Sniper, ["Sniper", "狙击"] },
|
||||
{ Role.Caster, ["Caster", "术师", "术士", "法师"] },
|
||||
{ Role.Support, ["Support", "Supporter", "辅助", "支援"] },
|
||||
{ Role.Special, ["Special", "Specialist", "特种"] },
|
||||
{ Role.Drone, ["Drone", "Summon", "无人机", "召唤物"] },
|
||||
{ OperatorType.Warrior, ["Warrior", "Guard", "近卫"] },
|
||||
{ OperatorType.Pioneer, ["Pioneer", "Vanguard", "先锋"] },
|
||||
{ OperatorType.Medic, ["Medic", "医疗"] },
|
||||
{ OperatorType.Tank, ["Tank", "Defender", "重装", "坦克"] },
|
||||
{ OperatorType.Sniper, ["Sniper", "狙击"] },
|
||||
{ OperatorType.Caster, ["Caster", "术师", "术士", "法师"] },
|
||||
{ OperatorType.Support, ["Support", "Supporter", "辅助", "支援"] },
|
||||
{ OperatorType.Special, ["Special", "Specialist", "特种"] },
|
||||
{ OperatorType.Drone, ["Drone", "Summon", "无人机", "召唤物"] },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, Role> _nameToRole =
|
||||
_roleAliases.SelectMany(kv => kv.Value.Select(v => new { v, kv.Key }))
|
||||
private static readonly Dictionary<string, OperatorType> _nameToOperType =
|
||||
_typeAliases.SelectMany(kv => kv.Value.Select(v => new { v, kv.Key }))
|
||||
.ToDictionary(x => x.v, x => x.Key, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
private static string GetLocalizedToolmenName(string key)
|
||||
{
|
||||
return _nameToRole.TryGetValue(key, out var role)
|
||||
? LocalizationHelper.GetString(role.ToString())
|
||||
return _nameToOperType.TryGetValue(key, out var operType)
|
||||
? LocalizationHelper.GetString(operType.ToString())
|
||||
: key;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user