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

57 lines
2.4 KiB
C#

namespace PKHeX.Core
{
/// <summary> Common Ribbons introduced in Generation 6 </summary>
internal interface IRibbonSetCommon6
{
bool RibbonChampionKalos { get; set; }
bool RibbonChampionG6Hoenn { get; set; }
bool RibbonBestFriends { get; set; }
bool RibbonTraining { get; set; }
bool RibbonBattlerSkillful { get; set; }
bool RibbonBattlerExpert { get; set; }
bool RibbonContestStar { get; set; }
bool RibbonMasterCoolness { get; set; }
bool RibbonMasterBeauty { get; set; }
bool RibbonMasterCuteness { get; set; }
bool RibbonMasterCleverness { get; set; }
bool RibbonMasterToughness { get; set; }
int RibbonCountMemoryContest { get; set; }
int RibbonCountMemoryBattle { get; set; }
}
internal static partial class RibbonExtensions
{
private static readonly string[] RibbonSetNamesCommon6Bool =
{
nameof(IRibbonSetCommon6.RibbonChampionKalos), nameof(IRibbonSetCommon6.RibbonChampionG6Hoenn), nameof(IRibbonSetCommon6.RibbonBestFriends),
nameof(IRibbonSetCommon6.RibbonTraining), nameof(IRibbonSetCommon6.RibbonBattlerSkillful), nameof(IRibbonSetCommon6.RibbonBattlerExpert),
nameof(IRibbonSetCommon6.RibbonContestStar), nameof(IRibbonSetCommon6.RibbonMasterCoolness), nameof(IRibbonSetCommon6.RibbonMasterBeauty),
nameof(IRibbonSetCommon6.RibbonMasterCuteness), nameof(IRibbonSetCommon6.RibbonMasterCleverness), nameof(IRibbonSetCommon6.RibbonMasterToughness),
};
internal static bool[] RibbonBits(this IRibbonSetCommon6 set)
{
if (set == null)
return new bool[12];
return new[]
{
set.RibbonChampionKalos,
set.RibbonChampionG6Hoenn,
set.RibbonBestFriends,
set.RibbonTraining,
set.RibbonBattlerSkillful,
set.RibbonBattlerExpert,
set.RibbonContestStar,
set.RibbonMasterCoolness,
set.RibbonMasterBeauty,
set.RibbonMasterCuteness,
set.RibbonMasterCleverness,
set.RibbonMasterToughness,
};
}
internal static string[] RibbonNamesBool(this IRibbonSetCommon6 set) => RibbonSetNamesCommon6Bool;
}
}