mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-19 00:43:14 +00:00
1c4a1af633
Detect channel, only detect Channel PIDIV for RS origin (only really care about method1/2/4 being used when it shouldn't) Channel does this weird thing called not setting the met level. Refactor set suggested met location to a method that can suppress popups.
31 lines
979 B
C#
31 lines
979 B
C#
namespace PKHeX.Core
|
|
{
|
|
public interface IEncounterable
|
|
{
|
|
int Species { get; }
|
|
string Name { get; }
|
|
bool EggEncounter { get; }
|
|
int LevelMin { get; }
|
|
int LevelMax { get; }
|
|
}
|
|
|
|
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)
|
|
{
|
|
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;
|
|
}
|
|
return encounter.IsWithinRange(pkm.CurrentLevel);
|
|
}
|
|
}
|
|
}
|