PKHeX/PKHeX.Core/Legality/Verifiers/Ribbons/RibbonVerifierCommon4.cs
Kurt 88830e0d00
Update from .NET Framework 4.6 to .NET 7 (#3729)
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now.

Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes.

Adds functionality for Batch Editor commands to `>`, `<` and <=/>=

TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants.

Main window has a new layout to account for DPI scaling (8 point grid)

Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects
Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724)
Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720)
Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714)
Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691)
Added: Properties for ribbon/mark count (closes #3659)
Fixed: Traded SV eggs are now checked correctly (closes #3692)
2023-01-21 20:02:33 -08:00

89 lines
3.2 KiB
C#

using static PKHeX.Core.RibbonIndex;
namespace PKHeX.Core;
/// <summary>
/// Parsing logic for <see cref="IRibbonSetCommon4"/>.
/// </summary>
public static class RibbonVerifierCommon4
{
public static void Parse(this IRibbonSetCommon4 r, RibbonVerifierArguments args, ref RibbonResultList list)
{
var pk = args.Entity;
var evos = args.History;
if (r.RibbonFootprint && !RibbonRules.IsRibbonValidFootprint(pk, evos))
list.Add(Footprint);
if (r.RibbonRecord)
list.Add(Record); // Unobtainable
bool gen4 = evos.HasVisitedGen4;
bool gen6 = evos.HasVisitedGen6;
bool bdsp = evos.HasVisitedBDSP;
bool oras6 = gen6 && pk is not { IsUntraded: true, XY: true };
bool sinnoh4 = gen4 && args.Encounter is not EncounterStatic4 { Species: (int)Species.Pichu, Form: 1 };
bool sinnohChamp = sinnoh4 || bdsp; // no gen4 hg/ss
bool cosmetic = sinnoh4 || oras6 || bdsp; // no gen4 hg/ss
bool daily = gen4 || gen6 || bdsp;
if (r.RibbonLegend && !gen4)
list.Add(Legend);
if (r.RibbonChampionSinnoh && !sinnohChamp)
list.Add(ChampionSinnoh);
if (!daily)
FlagDaily(r, ref list);
// Gen6 can get individual ribbons via Ritzy Ribbon Retail -- OR/AS
// Gen4 Ribbon Syndicate is sequential purchase (prerequisite ribbon cannot be disjointed) -- DP/Pt
// Gen8 Ribbon Syndicate is sequential purchase (prerequisite ribbon cannot be disjointed) -- BD/SP
if (!cosmetic)
FlagCosmetic(r, ref list);
else if (!oras6)
FlagCosmeticRequsite(r, ref list);
}
private static void FlagDaily(IRibbonSetCommon4 r, ref RibbonResultList list)
{
if (r.RibbonAlert) list.Add(Alert);
if (r.RibbonShock) list.Add(Shock);
if (r.RibbonDowncast) list.Add(Downcast);
if (r.RibbonCareless) list.Add(Careless);
if (r.RibbonRelax) list.Add(Relax);
if (r.RibbonSnooze) list.Add(Snooze);
if (r.RibbonSmile) list.Add(Smile);
}
private static void FlagCosmetic(IRibbonSetCommon4 r, ref RibbonResultList list)
{
if (r.RibbonGorgeous) list.Add(Gorgeous);
if (r.RibbonRoyal) list.Add(Royal);
if (r.RibbonGorgeousRoyal) list.Add(GorgeousRoyal);
}
private static void FlagCosmeticRequsite(IRibbonSetCommon4 r, ref RibbonResultList list)
{
// Gorgeous -> Royal -> Gorgeous|Royal
bool preReq;
if (!r.RibbonRoyal) // 2
preReq = false; // Skip reading 1; lacking 2 => can't have 3.
else if (!(preReq = r.RibbonGorgeous))
list.Add(Royal); // Needed 1
if (!preReq && r.RibbonGorgeousRoyal) // 3
list.Add(GorgeousRoyal); // Needed 12
}
public static void ParseEgg(this IRibbonSetCommon4 r, ref RibbonResultList list)
{
if (r.RibbonFootprint)
list.Add(Footprint);
if (r.RibbonRecord)
list.Add(Record);
if (r.RibbonLegend)
list.Add(Legend);
if (r.RibbonChampionSinnoh)
list.Add(ChampionSinnoh);
FlagDaily(r, ref list);
FlagCosmetic(r, ref list);
}
}