mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
perf: 干员识别按照 稀有度->精英化->等级->潜能->Id 排序
This commit is contained in:
@@ -23,15 +23,27 @@ public class OperBoxData
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; } = null!; // char_2024_chyue
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 干员名称
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; } = null!; // 重岳
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 精英化等级
|
||||
/// </summary>
|
||||
[JsonProperty("elite")]
|
||||
public int Elite { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 等级
|
||||
/// </summary>
|
||||
[JsonProperty("level")]
|
||||
public int Level { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether 是否拥有
|
||||
/// </summary>
|
||||
[JsonProperty("own")]
|
||||
public bool Own { get; set; } = false;
|
||||
|
||||
|
||||
@@ -1028,6 +1028,8 @@ public class ToolboxViewModel : Screen
|
||||
[JsonProperty("potential")]
|
||||
public int Potential { get; } = potential;
|
||||
|
||||
public int IdNumber { get; } = ExtractIdNumber(id);
|
||||
|
||||
public string RarityStars => IsPallas ? LocalizationHelper.GetPallasString(6, 6) : new('★', Rarity);
|
||||
|
||||
/// <summary>
|
||||
@@ -1056,6 +1058,15 @@ public class ToolboxViewModel : Screen
|
||||
public override string ToString() => $"{Name} (★{Rarity})";
|
||||
|
||||
private bool IsPallas => Id == "char_485_pallas";
|
||||
|
||||
private static int ExtractIdNumber(string id)
|
||||
{
|
||||
// char_002_amiya
|
||||
// ↑取中间
|
||||
int start = id.IndexOf('_') + 1;
|
||||
int end = id.IndexOf('_', start);
|
||||
return int.Parse(id.AsSpan(start, end - start));
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<Operator> _operBoxHaveList = [];
|
||||
@@ -1081,6 +1092,27 @@ public class ToolboxViewModel : Screen
|
||||
JsonDataHelper.Set(JsonDataKey.OperBoxData, JArray.FromObject(details));
|
||||
}
|
||||
|
||||
private void SortOperBoxLists()
|
||||
{
|
||||
OperBoxHaveList = SortOperBoxList(OperBoxHaveList);
|
||||
OperBoxNotHaveList = SortOperBoxList(OperBoxNotHaveList);
|
||||
}
|
||||
|
||||
private static ObservableCollection<Operator> SortOperBoxList(ObservableCollection<Operator> list)
|
||||
{
|
||||
if (list == null || list.Count <= 0)
|
||||
{
|
||||
return list ?? [];
|
||||
}
|
||||
|
||||
return [.. list
|
||||
.OrderByDescending(x => x.Rarity)
|
||||
.ThenByDescending(x => x.Elite)
|
||||
.ThenByDescending(x => x.Level)
|
||||
.ThenByDescending(x => x.Potential)
|
||||
.ThenByDescending(x => x.IdNumber)];
|
||||
}
|
||||
|
||||
private void LoadOperBoxDetails()
|
||||
{
|
||||
// TODO: 删除老数据节省 gui.json 的大小,后续版本可以删除
|
||||
@@ -1121,6 +1153,8 @@ public class ToolboxViewModel : Screen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SortOperBoxLists();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -1174,6 +1208,8 @@ public class ToolboxViewModel : Screen
|
||||
}
|
||||
}
|
||||
|
||||
SortOperBoxLists();
|
||||
|
||||
if (OperBoxNotHaveList.Count > 0)
|
||||
{
|
||||
OperBoxSelectedIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user