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. public readonly PKM Entity; /// 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; private const int MoveCount = 4; public readonly MoveResult[] Relearn = new MoveResult[MoveCount]; public readonly MoveResult[] Moves = new MoveResult[MoveCount]; public EvolutionHistory EvoChainsAllGens => _evochains ??= EvolutionChain.GetEvolutionChainsAllGens(Entity, EncounterMatch); private EvolutionHistory? _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; /// 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) { Entity = pk; Parse = parse; StoreMetadata(pk.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; } }