using System.Collections.Generic; using System.Linq; namespace PKHeX.Core { /// /// Represents an Area where can be encountered, which contains a Location ID and data. /// public abstract record EncounterArea(GameVersion Version) : IVersion { public int Location { get; protected init; } public SlotType Type { get; protected init; } = SlotType.Any; protected abstract IReadOnlyList Raw { get; } /// /// Gets the slots contained in the area that match the provided data. /// /// Pokémon Data /// Evolution lineage /// Enumerable list of encounters public abstract IEnumerable GetMatchingSlots(PKM pkm, EvoCriteria[] chain); /// /// Checks if the provided met location ID matches the parameters for the area. /// /// Met Location ID /// True if possibly originated from this area, false otherwise. public virtual bool IsMatchLocation(int location) => Location == location; public bool HasSpecies(int species) => Raw.Any(z => z.Species == species); public IEnumerable GetSpecies(EvoCriteria[] chain) => Raw.Where(z => chain.Any(c => z.Species == c.Species)); } }