2021-06-30 03:58:06 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2016-11-08 16:43:57 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2019-09-12 05:06:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents an Area where <see cref="PKM"/> can be encountered, which contains a Location ID and <see cref="EncounterSlot"/> data.
|
|
|
|
|
/// </summary>
|
2021-12-05 01:56:56 +00:00
|
|
|
|
public abstract record EncounterArea(GameVersion Version) : IVersion
|
2019-09-12 05:06:24 +00:00
|
|
|
|
{
|
2020-12-22 01:05:05 +00:00
|
|
|
|
public int Location { get; protected init; }
|
|
|
|
|
public SlotType Type { get; protected init; } = SlotType.Any;
|
2021-06-30 03:58:06 +00:00
|
|
|
|
protected abstract IReadOnlyList<EncounterSlot> Raw { get; }
|
2017-03-19 12:19:45 +00:00
|
|
|
|
|
2019-09-13 06:20:52 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the slots contained in the area that match the provided data.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pkm">Pokémon Data</param>
|
2020-06-28 03:18:29 +00:00
|
|
|
|
/// <param name="chain">Evolution lineage</param>
|
2019-09-13 06:20:52 +00:00
|
|
|
|
/// <returns>Enumerable list of encounters</returns>
|
2022-05-08 01:29:36 +00:00
|
|
|
|
public abstract IEnumerable<EncounterSlot> GetMatchingSlots(PKM pkm, EvoCriteria[] chain);
|
2019-11-19 16:38:18 +00:00
|
|
|
|
|
2019-11-21 01:01:34 +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>
|
2019-11-19 16:38:18 +00:00
|
|
|
|
public virtual bool IsMatchLocation(int location) => Location == location;
|
2021-06-30 03:58:06 +00:00
|
|
|
|
|
|
|
|
|
public bool HasSpecies(int species) => Raw.Any(z => z.Species == species);
|
2022-05-08 01:29:36 +00:00
|
|
|
|
public IEnumerable<EncounterSlot> GetSpecies(EvoCriteria[] chain) => Raw.Where(z => chain.Any(c => z.Species == c.Species));
|
2017-12-03 20:20:49 +00:00
|
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|