mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
1486b7f14a
Remove move combobox flicker hack (no longer necessary) Add more Array.Empty usages cache mysterygift sizes seal some classes no functionality changes
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Common Encounter Properties base interface.
|
|
/// </summary>
|
|
public interface IEncounterable
|
|
{
|
|
int Species { get; }
|
|
string Name { get; }
|
|
bool EggEncounter { get; }
|
|
int LevelMin { get; }
|
|
int LevelMax { get; }
|
|
|
|
PKM ConvertToPKM(ITrainerInfo SAV);
|
|
}
|
|
|
|
public static partial class Extensions
|
|
{
|
|
private static bool IsWithinRange(this IEncounterable encounter, int lvl)
|
|
{
|
|
return encounter.LevelMin <= lvl && lvl <= encounter.LevelMax;
|
|
}
|
|
|
|
public static bool IsWithinRange(this IEncounterable encounter, PKM pkm)
|
|
{
|
|
if (!pkm.HasOriginalMetLocation)
|
|
return encounter.IsWithinRange(pkm.CurrentLevel);
|
|
if (encounter.EggEncounter)
|
|
return pkm.CurrentLevel == Legal.GetEggHatchLevel(pkm);
|
|
if (encounter is MysteryGift g)
|
|
return pkm.CurrentLevel == g.Level;
|
|
return pkm.CurrentLevel == pkm.Met_Level;
|
|
}
|
|
|
|
internal static string GetEncounterTypeName(this IEncounterable Encounter) => Encounter?.Name ?? "Unknown";
|
|
}
|
|
}
|