mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-21 01:43:10 +00:00
6921a2ebee
remove legality check's use of reflection which checked individual properties; add interfaces to interact with the ribbons of each PKM type. With this, every ribbon attribute is accessible via its corresponding interface (cast) will have to add checks for individual interfaces as per #1250 I didn't feel like adding much documentation, is pretty straightforward. Cast a pkm object to the desired ribbon set; if not null, can access ribbons regardless of pkm format.
37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary> Ribbons introduced in Generation 3 for Special Events </summary>
|
|
internal interface IRibbonSetEvent3
|
|
{
|
|
bool RibbonEarth { get; set; }
|
|
bool RibbonNational { get; set; }
|
|
bool RibbonCountry { get; set; }
|
|
bool RibbonChampionBattle { get; set; }
|
|
bool RibbonChampionRegional { get; set; }
|
|
bool RibbonChampionNational { get; set; }
|
|
}
|
|
|
|
internal static partial class RibbonExtensions
|
|
{
|
|
private static readonly string[] RibbonSetNamesEvent3 =
|
|
{
|
|
nameof(IRibbonSetEvent3.RibbonEarth), nameof(IRibbonSetEvent3.RibbonNational), nameof(IRibbonSetEvent3.RibbonCountry),
|
|
nameof(IRibbonSetEvent3.RibbonChampionBattle), nameof(IRibbonSetEvent3.RibbonChampionRegional), nameof(IRibbonSetEvent3.RibbonChampionNational)
|
|
};
|
|
internal static bool[] RibbonBits(this IRibbonSetEvent3 set)
|
|
{
|
|
if (set == null)
|
|
return new bool[6];
|
|
return new[]
|
|
{
|
|
set.RibbonEarth,
|
|
set.RibbonNational,
|
|
set.RibbonCountry,
|
|
set.RibbonChampionBattle,
|
|
set.RibbonChampionRegional,
|
|
set.RibbonChampionNational,
|
|
};
|
|
}
|
|
internal static string[] RibbonNames(this IRibbonSetEvent3 set) => RibbonSetNamesEvent3;
|
|
}
|
|
}
|