mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 10:00:44 +08:00
feat: 战斗列表悖论模拟关卡名转为干员名
This commit is contained in:
@@ -46,11 +46,16 @@ namespace MaaWpfGui.Helper
|
||||
{ "txwy", "zh-tw" },
|
||||
};
|
||||
|
||||
// 储存角色信息的字典
|
||||
/// <summary>
|
||||
/// Gets 储存角色信息的字典
|
||||
/// </summary>
|
||||
public static Dictionary<string, CharacterInfo> Characters { get; } = [];
|
||||
|
||||
public static IReadOnlyDictionary<string, CharacterInfo> Operators => Characters.Where(oper => oper.Value.IsOperator && !_virtuallyOpers.Contains(oper.Key)).ToDictionary();
|
||||
|
||||
/// <summary>
|
||||
/// Gets 当前语言与客户端类型下的干员名列表
|
||||
/// </summary>
|
||||
public static HashSet<string> CharacterNames { get; } = [];
|
||||
|
||||
public static Dictionary<string, (string DisplayName, string ClientName)> RecruitTags { get; private set; } = [];
|
||||
@@ -87,6 +92,7 @@ namespace MaaWpfGui.Helper
|
||||
CharacterNames.Clear();
|
||||
foreach (var (key, value) in characterData)
|
||||
{
|
||||
value.Id = key;
|
||||
Characters.Add(key, value);
|
||||
if (!key.StartsWith("char_"))
|
||||
{
|
||||
@@ -226,21 +232,35 @@ namespace MaaWpfGui.Helper
|
||||
return dict;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过任意服务器中对应的干员名获取干员信息
|
||||
/// </summary>
|
||||
/// <param name="characterName">任意服务器中的干员名</param>
|
||||
/// <returns>对应干员信息</returns>
|
||||
public static CharacterInfo? GetCharacterByNameOrAlias(string characterName)
|
||||
{
|
||||
return _nameToCharacterMap.GetValueOrDefault(characterName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过任意服务器中对应的干员名获取指定语言的干员名
|
||||
/// </summary>
|
||||
/// <param name="characterName">任意服务器中的干员名</param>
|
||||
/// <param name="language">指定语言,默认为当前语言</param>
|
||||
/// <returns>指定语言干员名</returns>
|
||||
public static string? GetLocalizedCharacterName(string? characterName, string? language = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(characterName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetLocalizedCharacterName(GetCharacterByNameOrAlias(characterName), language);
|
||||
return string.IsNullOrEmpty(characterName)
|
||||
? null
|
||||
: GetLocalizedCharacterName(GetCharacterByNameOrAlias(characterName), language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过干员信息获取指定语言的干员名
|
||||
/// </summary>
|
||||
/// <param name="characterInfo">干员信息</param>
|
||||
/// <param name="language">指定语言</param>
|
||||
/// <returns>指定语言干员名</returns>
|
||||
public static string? GetLocalizedCharacterName(CharacterInfo? characterInfo, string? language = null)
|
||||
{
|
||||
if (characterInfo?.Name == null)
|
||||
@@ -260,6 +280,12 @@ namespace MaaWpfGui.Helper
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断干员在指定客户端中是否可用
|
||||
/// </summary>
|
||||
/// <param name="character">干员信息</param>
|
||||
/// <param name="clientType">客户端类型</param>
|
||||
/// <returns>是否可用</returns>
|
||||
public static bool IsCharacterAvailableInClient(CharacterInfo? character, string clientType)
|
||||
{
|
||||
if (character is null)
|
||||
@@ -277,14 +303,44 @@ namespace MaaWpfGui.Helper
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断干员在指定客户端中是否可用
|
||||
/// </summary>
|
||||
/// <param name="characterName">干员名</param>
|
||||
/// <param name="clientType">客户端类型</param>
|
||||
/// <returns>是否可用</returns>
|
||||
public static bool IsCharacterAvailableInClient(string characterName, string clientType)
|
||||
{
|
||||
var character = GetCharacterByNameOrAlias(characterName);
|
||||
return character != null && IsCharacterAvailableInClient(character, clientType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过完整 ID 查询
|
||||
/// </summary>
|
||||
/// <param name="id">干员 id</param>
|
||||
/// <returns>干员信息</returns>
|
||||
public static CharacterInfo? GetCharacterById(string id)
|
||||
{
|
||||
return Characters.GetValueOrDefault(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过代号查询(如 char_002_amiya 中的 amiya)
|
||||
/// </summary>
|
||||
/// <param name="codeName">干员代号</param>
|
||||
/// <returns>干员信息</returns>
|
||||
public static CharacterInfo? GetCharacterByCodeName(string codeName)
|
||||
{
|
||||
return Characters.Values.FirstOrDefault(character =>
|
||||
character.CodeName.Equals(codeName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public class CharacterInfo
|
||||
{
|
||||
[JsonIgnore]
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
@@ -324,10 +380,15 @@ namespace MaaWpfGui.Helper
|
||||
[JsonProperty("rarity")]
|
||||
public int Rarity { get; set; }
|
||||
|
||||
public bool IsOperator => Profession == OperProfession.Caster || Profession == OperProfession.Medic
|
||||
|| Profession == OperProfession.Pioneer || Profession == OperProfession.Sniper
|
||||
|| Profession == OperProfession.Special || Profession == OperProfession.Support
|
||||
|| Profession == OperProfession.Tank || Profession == OperProfession.Warrior;
|
||||
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
|
||||
{
|
||||
@@ -386,6 +447,21 @@ namespace MaaWpfGui.Helper
|
||||
/// </summary>
|
||||
Trap,
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public string CodeName => ExtractCodeName(Id);
|
||||
|
||||
private static string ExtractCodeName(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
// 从"char_002_amiya"中提取"amiya"
|
||||
var parts = id.Split('_');
|
||||
return parts.Length >= 3 ? parts[2] : id;
|
||||
}
|
||||
}
|
||||
|
||||
public class MapInfo
|
||||
|
||||
@@ -1101,7 +1101,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
cachePath = $"{CopilotJsonDir}/{fileName}_{DateTimeOffset.Now.ToUnixTimeMilliseconds()}.json";
|
||||
if (CopilotItemViewModels.Any(i => i.FilePath == cachePath))
|
||||
{
|
||||
_logger.Error("Could not add copilot task with duplicate stage name: " + copilot.StageName);
|
||||
_logger.Error("Could not add copilot task with duplicate stage name: {StageName}", copilot.StageName);
|
||||
_semaphore.Release();
|
||||
return false;
|
||||
}
|
||||
@@ -1118,22 +1118,27 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flags.HasFlag(CopilotModel.DifficultyFlags.Normal))
|
||||
if (ActiveTabIndex == 2)
|
||||
{
|
||||
var item = new CopilotItemViewModel(stageName, cachePath, false, copilotId)
|
||||
{
|
||||
Index = CopilotItemViewModels.Count,
|
||||
};
|
||||
var codeName = stageName![4..^2];
|
||||
var characterInfo = DataHelper.GetCharacterByCodeName(codeName);
|
||||
var name = DataHelper.GetLocalizedCharacterName(characterInfo);
|
||||
var item = new CopilotItemViewModel(name, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, };
|
||||
CopilotItemViewModels.Add(item);
|
||||
}
|
||||
|
||||
if (flags.HasFlag(CopilotModel.DifficultyFlags.Raid))
|
||||
else
|
||||
{
|
||||
var item = new CopilotItemViewModel(stageName, cachePath, true, copilotId)
|
||||
if (flags.HasFlag(CopilotModel.DifficultyFlags.Normal))
|
||||
{
|
||||
Index = CopilotItemViewModels.Count,
|
||||
};
|
||||
CopilotItemViewModels.Add(item);
|
||||
var item = new CopilotItemViewModel(stageName, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, };
|
||||
CopilotItemViewModels.Add(item);
|
||||
}
|
||||
|
||||
if (flags.HasFlag(CopilotModel.DifficultyFlags.Raid))
|
||||
{
|
||||
var item = new CopilotItemViewModel(stageName, cachePath, true, copilotId) { Index = CopilotItemViewModels.Count, };
|
||||
CopilotItemViewModels.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
_semaphore.Release();
|
||||
|
||||
Reference in New Issue
Block a user