PKHeX/PKHeX.Core/Ribbons/IRibbonSetOnly3.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

35 lines
1.3 KiB
C#

namespace PKHeX.Core
{
/// <summary> Ribbons that originated in Generation 3 and were only present within that Generation. </summary>
internal interface IRibbonSetOnly3
{
int RibbonCountG3Cool { get; set; }
int RibbonCountG3Beauty { get; set; }
int RibbonCountG3Cute { get; set; }
int RibbonCountG3Smart { get; set; }
int RibbonCountG3Tough { get; set; }
}
internal static partial class RibbonExtensions
{
private static readonly string[] RibbonSetNamesOnly3 =
{
nameof(IRibbonSetOnly3.RibbonCountG3Cool), nameof(IRibbonSetOnly3.RibbonCountG3Beauty), nameof(IRibbonSetOnly3.RibbonCountG3Cute),
nameof(IRibbonSetOnly3.RibbonCountG3Smart), nameof(IRibbonSetOnly3.RibbonCountG3Tough),
};
internal static int[] RibbonCounts(this IRibbonSetOnly3 set)
{
if (set == null)
return new int[5];
return new[]
{
set.RibbonCountG3Cool,
set.RibbonCountG3Beauty,
set.RibbonCountG3Cute,
set.RibbonCountG3Smart,
set.RibbonCountG3Tough,
};
}
internal static string[] RibbonNames(this IRibbonSetOnly3 set) => RibbonSetNamesOnly3;
}
}