mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-23 19:03:11 +00:00
768047cd80
* Rewrite ribbon verification * Explicitly verifies all ribbons instead of chained iterators. * Verifies using only the stack, using `struct` and `Span<T>`. No allocation on heap, or `IEnumerable` iterators. * Verifies all egg ribbons using a separate method, explicitly implemented. No reflection overhead. * Separates each ribbon interface to separate `static` classes. Easier to identify code needing change on new game update. * Extracted logic for specific ribbons. Can easily revise complicated ribbon's acquisition rules. * Simplifies GiveAll/RemoveAll legal ribbon mutations. No reflection overhead, and no allocation. * Can be expanded in the future if we need to track conditions for ribbon acquisition (was Sinnoh Champ received in BDSP or Gen4?) End result is a more performant implementation and easier to maintain & reuse logic.
31 lines
961 B
C#
31 lines
961 B
C#
using static PKHeX.Core.RibbonIndex;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Parsing logic for <see cref="IRibbonSetCommon3"/>.
|
|
/// </summary>
|
|
public static class RibbonVerifierCommon3
|
|
{
|
|
public static void Parse(this IRibbonSetCommon3 r, RibbonVerifierArguments args, ref RibbonResultList list)
|
|
{
|
|
var evos = args.History;
|
|
var pk = args.Entity;
|
|
if (r.RibbonChampionG3 && !evos.HasVisitedGen3)
|
|
list.Add(ChampionG3);
|
|
if (r.RibbonArtist && !evos.HasVisitedGen3)
|
|
list.Add(Artist);
|
|
if (r.RibbonEffort && !RibbonRules.IsRibbonValidEffort(pk, evos, args.Encounter.Generation))
|
|
list.Add(Effort);
|
|
}
|
|
|
|
public static void ParseEgg(this IRibbonSetCommon3 r, ref RibbonResultList list)
|
|
{
|
|
if (r.RibbonChampionG3)
|
|
list.Add(ChampionG3);
|
|
if (r.RibbonArtist)
|
|
list.Add(Artist);
|
|
if (r.RibbonEffort)
|
|
list.Add(Effort);
|
|
}
|
|
}
|