2022-08-27 06:43:36 +00:00
|
|
|
using System.Collections.Generic;
|
2021-06-30 03:58:06 +00:00
|
|
|
using System.Linq;
|
2016-11-08 16:43:57 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents an Area where <see cref="PKM"/> can be encountered, which contains a Location ID and <see cref="EncounterSlot"/> data.
|
|
|
|
/// </summary>
|
|
|
|
public abstract record EncounterArea(GameVersion Version) : IVersion
|
2016-11-08 16:43:57 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
public int Location { get; protected init; }
|
2022-09-23 20:36:44 +00:00
|
|
|
public SlotType Type { get; protected init; }
|
2022-06-18 18:04:24 +00:00
|
|
|
protected abstract IReadOnlyList<EncounterSlot> Raw { get; }
|
|
|
|
|
2019-09-12 05:06:24 +00:00
|
|
|
/// <summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
/// Gets the slots contained in the area that match the provided data.
|
2019-09-12 05:06:24 +00:00
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
/// <param name="pk">Pokémon Data</param>
|
|
|
|
/// <param name="chain">Evolution lineage</param>
|
|
|
|
/// <returns>Enumerable list of encounters</returns>
|
|
|
|
public abstract IEnumerable<EncounterSlot> GetMatchingSlots(PKM pk, EvoCriteria[] chain);
|
2019-11-19 16:38:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Checks if the provided met location ID matches the parameters for the area.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="location">Met Location ID</param>
|
|
|
|
/// <returns>True if possibly originated from this area, false otherwise.</returns>
|
|
|
|
public virtual bool IsMatchLocation(int location) => Location == location;
|
2021-06-30 03:58:06 +00:00
|
|
|
|
2022-08-27 06:43:36 +00:00
|
|
|
public bool HasSpecies(ushort species) => Raw.Any(z => z.Species == species);
|
2022-06-18 18:04:24 +00:00
|
|
|
public IEnumerable<EncounterSlot> GetSpecies(EvoCriteria[] chain) => Raw.Where(z => chain.Any(c => z.Species == c.Species));
|
2016-11-08 16:43:57 +00:00
|
|
|
}
|