using System; using System.Collections.Generic; namespace PKHeX.Core { /// /// Calculated Information storage with properties useful for parsing the legality of the input . /// public sealed class LegalInfo { /// The object used for comparisons. private readonly PKM pkm; /// The generation of games the originated from. public int Generation { get; internal set; } /// The Game the originated from. public GameVersion Game { get; internal set; } /// The matched Encounter details for the . public IEncounterable EncounterMatch { get => _match; set { if (_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(); } } private IEncounterable _match = EncounterInvalid.Default; /// Base Relearn Moves for the . public IReadOnlyList RelearnBase { get; internal set; } = Array.Empty(); /// Top level Legality Check result list for the . public readonly List Parse = new List(); public CheckResult[] Relearn { get; internal set; } = new CheckResult[4]; public CheckMoveResult[] Moves { get; internal set; } = new CheckMoveResult[4]; private static readonly ValidEncounterMoves NONE = new ValidEncounterMoves(); 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) { pkm = pk; // Store repeatedly accessed values Game = (GameVersion)pkm.Version; Generation = pkm.GenNumber; } /// List of all near-matches that were rejected for a given reason. public List? InvalidMatches; internal void Reject(CheckResult c) { (InvalidMatches ??= new List()).Add(new EncounterRejected(EncounterMatch, c)); } } }