Fix dropdown suggested green moves from showing swsh moves

Extract the IsLandlocked check to the IsMovesetRestricted which already exists.
This commit is contained in:
Kurt 2021-11-23 22:58:41 -08:00
parent f34bc9c3fa
commit ecee6ae8a1
3 changed files with 33 additions and 12 deletions

View file

@ -135,7 +135,37 @@ namespace PKHeX.Core
internal static bool HasVisitedB2W2(this PKM pkm, int species) => pkm.InhabitedGeneration(5, species);
internal static bool HasVisitedORAS(this PKM pkm, int species) => pkm.InhabitedGeneration(6, species) && (pkm.AO || !pkm.IsUntraded);
internal static bool HasVisitedUSUM(this PKM pkm, int species) => pkm.InhabitedGeneration(7, species) && (pkm.USUM || !pkm.IsUntraded);
internal static bool IsMovesetRestricted(this PKM pkm, int gen) => (gen == 7 && pkm.Version is (int)GameVersion.GO or (int)GameVersion.GP or (int)GameVersion.GE) || pkm.IsUntraded;
/// <summary>
/// Indicates if the moveset is restricted to only the original version.
/// </summary>
/// <param name="pkm">Entity to check</param>
/// <returns></returns>
internal static bool IsMovesetRestricted(this PKM pkm)
{
if (pkm.IsUntraded)
return true;
if (pkm.BDSP)
return true;
return false;
}
/// <summary>
/// Indicates if the moveset is restricted to only the original version.
/// </summary>
/// <param name="pkm">Entity to check</param>
/// <param name="gen">Generation the move check is for</param>
/// <returns></returns>
internal static bool IsMovesetRestricted(this PKM pkm, int gen)
{
if (pkm.IsMovesetRestricted())
return true;
return gen switch
{
7 when pkm.Version is (int)GameVersion.GO or (int)GameVersion.GP or (int)GameVersion.GE => true,
_ => false,
};
}
public static int GetMaxLengthOT(int generation, LanguageID language) => language switch
{

View file

@ -173,20 +173,11 @@ namespace PKHeX.Core
internal static IEnumerable<int> GetValidMoves(PKM pkm, IReadOnlyList<EvoCriteria> evoChain, int generation, MoveSourceType types = MoveSourceType.ExternalSources, bool RemoveTransferHM = true)
{
GameVersion version = (GameVersion)pkm.Version;
if (!pkm.IsUntraded && !IsLandlockedFormat(pkm))
if (!pkm.IsMovesetRestricted(generation))
version = Any;
return GetValidMoves(pkm, version, evoChain, generation, types: types, RemoveTransferHM: RemoveTransferHM);
}
private static bool IsLandlockedFormat(PKM pkm)
{
if (pkm.BDSP)
return true;
if (pkm.LGPE)
return pkm.Format == 7;
return false;
}
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, int form, GameVersion version = Any)
{
return GetValidRelearn(pkm, species, form, Breeding.GetCanInheritMoves(species), version);

View file

@ -33,7 +33,7 @@ namespace PKHeX.Core
private static IEnumerable<int> GetValidMoves(PKM pkm, IReadOnlyList<IReadOnlyList<EvoCriteria>> evoChains, MoveSourceType types = MoveSourceType.ExternalSources, bool RemoveTransferHM = true)
{
GameVersion version = (GameVersion)pkm.Version;
if (!pkm.IsUntraded)
if (!pkm.IsMovesetRestricted())
version = GameVersion.Any;
return GetValidMoves(pkm, version, evoChains, types: types, RemoveTransferHM: RemoveTransferHM);
}