PKHeX/PKHeX.Core/Legality/Encounters/IEncounterTemplate.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00

34 lines
1 KiB
C#

namespace PKHeX.Core;
public interface IEncounterTemplate : ISpeciesForm, IVersion, IGeneration, IShiny
{
/// <summary>
/// Indicates if the encounter originated as an egg.
/// </summary>
bool EggEncounter { get; }
/// <summary>
/// Minimum level for the encounter.
/// </summary>
byte LevelMin { get; }
byte LevelMax { get; }
}
public static partial class Extensions
{
private static bool IsWithinEncounterRange(this IEncounterTemplate encounter, int lvl)
{
return encounter.LevelMin <= lvl && lvl <= encounter.LevelMax;
}
public static bool IsWithinEncounterRange(this IEncounterTemplate encounter, PKM pk)
{
if (!pk.HasOriginalMetLocation)
return encounter.IsWithinEncounterRange(pk.CurrentLevel);
if (encounter.EggEncounter)
return pk.CurrentLevel == encounter.LevelMin;
if (encounter is MysteryGift g)
return pk.CurrentLevel == g.Level;
return pk.CurrentLevel == pk.Met_Level;
}
}