PKHeX/PKHeX.Core/Ribbons/IRibbonSetCommon3.cs
Kurt 6921a2ebee Initial ribbon refactor
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.
2017-06-19 21:43:44 -07:00

30 lines
990 B
C#

namespace PKHeX.Core
{
/// <summary> Common Ribbons introduced in Generation 3 </summary>
internal interface IRibbonSetCommon3
{
bool RibbonChampionG3Hoenn { get; set; }
bool RibbonArtist { get; set; }
bool RibbonEffort { get; set; }
}
internal static partial class RibbonExtensions
{
private static readonly string[] RibbonSetNamesCommon3 =
{
nameof(IRibbonSetCommon3.RibbonChampionG3Hoenn), nameof(IRibbonSetCommon3.RibbonArtist), nameof(IRibbonSetCommon3.RibbonEffort)
};
internal static bool[] RibbonBits(this IRibbonSetCommon3 set)
{
if (set == null)
return new bool[3];
return new[]
{
set.RibbonChampionG3Hoenn,
set.RibbonArtist,
set.RibbonEffort,
};
}
internal static string[] RibbonNames(this IRibbonSetCommon3 set) => RibbonSetNamesCommon3;
}
}