using System.Collections.Generic; using System.Linq; namespace PKHeX.Core { public static class BoxManipUtil { /// /// Grouped categories of different . /// public static readonly IReadOnlyList[] ManipCategories = { BoxManipBase.ClearCommon, BoxManipBase.SortCommon, BoxManipBase.SortAdvanced, BoxManipBase.ModifyCommon, }; public static readonly string[] ManipCategoryNames = { "Delete", "Sort", "SortAdvanced", "Modify", }; /// /// Gets a reference that carries out the action of the requested . /// /// Manipulation type. /// Reference to . public static IBoxManip GetManip(this BoxManipType type) => ManipCategories.SelectMany(c => c).FirstOrDefault(m => m.Type == type); /// /// Gets the corresponding name from for the requested . /// /// Manipulation type. /// Category Name public static string? GetManipCategoryName(this BoxManipType type) { for (int i = 0; i < ManipCategories.Length; i++) { if (ManipCategories[i].Any(z => z.Type == type)) return ManipCategoryNames[i]; } return null; } /// /// Gets the corresponding name from for the requested . /// /// Manipulation type. /// Category Name public static string? GetManipCategoryName(this IBoxManip manip) { for (int i = 0; i < ManipCategories.Length; i++) { if (ManipCategories[i].Any(z => z == manip)) return ManipCategoryNames[i]; } return null; } } }