using System.Collections.Generic; namespace PKHeX.Core { /// /// Calculated Information storage with properties useful for parsing the legality of the input . /// public sealed class LegalInfo : IGeneration { /// The object used for comparisons. private readonly PKM pkm; /// The generation of games the originated from. public int Generation { get; private set; } /// The matched Encounter details for the . public IEncounterable EncounterMatch { get => _match; set { if (!ReferenceEquals(_match, EncounterInvalid.Default) && (value.LevelMin != _match.LevelMin || value.Species != _match.Species)) _evochains = null; // clear if evo chain has the potential to be different _match = value; Parse.Clear(); } } /// /// Original encounter data for the . /// /// /// Generation 1/2 that are transferred forward to Generation 7 are restricted to new encounter details. /// By retaining their original match, more information can be provided by the parse. /// public IEncounterable EncounterOriginal => EncounterOriginalGB ?? EncounterMatch; internal IEncounterable? EncounterOriginalGB; private IEncounterable _match = EncounterInvalid.Default; /// Top level Legality Check result list for the . internal readonly List Parse; public readonly CheckResult[] Relearn = new CheckResult[4]; public CheckMoveResult[] Moves { get; internal set; } = new CheckMoveResult[4]; private static readonly ValidEncounterMoves NONE = new(); public ValidEncounterMoves EncounterMoves { get; internal set; } = NONE; public IReadOnlyList[] EvoChainsAllGens => _evochains ??= EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterMatch); private IReadOnlyList[]? _evochains; /// related information that generated the / value(s). public PIDIV PIDIV { get => _pidiv; internal set { _pidiv = value; PIDParsed = true; } } public bool PIDParsed { get; private set; } private PIDIV _pidiv = PIDIV.None; /// Indicates whether or not the can originate from the . /// This boolean is true until all valid encounters are tested, after which it is false. public bool PIDIVMatches { get; internal set; } = true; /// Indicates whether or not the can originate from the with explicit matching. /// This boolean is true until all valid entries are tested for all possible matches, after which it is false. public bool FrameMatches { get; internal set; } = true; public LegalInfo(PKM pk, List parse) { pkm = pk; Parse = parse; StoreMetadata(pkm.Generation); } internal void StoreMetadata(int gen) { // We can call this method at the start for any Gen3+ encounter iteration. // We need to call this for each Gen1/2 encounter as Version is not stored for those origins. Generation = gen; } } }