mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-16 09:08:02 +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.
30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary> Ribbons introduced in Generation 3 and were transferred to future Generations (4 and 5 only). </summary>
|
|
internal interface IRibbonSetUnique3
|
|
{
|
|
/// <summary> Ribbon awarded for clearing Hoenn's Battle Tower's Lv. 50 challenge. </summary>
|
|
bool RibbonWinning { get; set; }
|
|
/// <summary> Ribbon awarded for clearing Hoenn's Battle Tower's Lv. 100 challenge. </summary>
|
|
bool RibbonVictory { get; set; }
|
|
}
|
|
|
|
internal static partial class RibbonExtensions
|
|
{
|
|
private static readonly string[] RibbonSetNamesUnique3 =
|
|
{
|
|
nameof(IRibbonSetUnique3.RibbonWinning), nameof(IRibbonSetUnique3.RibbonVictory),
|
|
};
|
|
internal static bool[] RibbonBits(this IRibbonSetUnique3 set)
|
|
{
|
|
if (set == null)
|
|
return new bool[2];
|
|
return new[]
|
|
{
|
|
set.RibbonWinning,
|
|
set.RibbonVictory,
|
|
};
|
|
}
|
|
internal static string[] RibbonNames(this IRibbonSetUnique3 set) => RibbonSetNamesUnique3;
|
|
}
|
|
}
|