mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-20 14:09:17 -05:00
Delete old utility methods (unused)
MoveEgg: already range check in the Safe method Inline some logic
This commit is contained in:
parent
b241c19520
commit
ad28f7b261
|
|
@ -61,46 +61,12 @@ public static partial class Legal
|
|||
internal static int GetMaxSpeciesOrigin(PKM pk)
|
||||
{
|
||||
if (pk.Format == 1)
|
||||
return GetMaxSpeciesOrigin(1);
|
||||
return MaxSpeciesID_1;
|
||||
if (pk.Format == 2 || pk.VC)
|
||||
return GetMaxSpeciesOrigin(2);
|
||||
return MaxSpeciesID_2;
|
||||
return GetMaxSpeciesOrigin(pk.Generation);
|
||||
}
|
||||
|
||||
internal static int GetMaxSpeciesOrigin(int generation, GameVersion version) => generation switch
|
||||
{
|
||||
1 => MaxSpeciesID_1,
|
||||
2 => MaxSpeciesID_2,
|
||||
3 => MaxSpeciesID_3,
|
||||
4 => MaxSpeciesID_4,
|
||||
5 => MaxSpeciesID_5,
|
||||
6 => MaxSpeciesID_6,
|
||||
7 when GameVersion.GG.Contains(version) => MaxSpeciesID_7b,
|
||||
7 when GameVersion.USUM.Contains(version) => MaxSpeciesID_7_USUM,
|
||||
7 => MaxSpeciesID_7,
|
||||
8 when version is GameVersion.PLA => MaxSpeciesID_8a,
|
||||
8 when GameVersion.BDSP.Contains(version) => MaxSpeciesID_8b,
|
||||
8 => MaxSpeciesID_8_R2,
|
||||
_ => -1,
|
||||
};
|
||||
|
||||
internal static int GetMaxSpeciesOrigin(EntityContext context) => context switch
|
||||
{
|
||||
EntityContext.Gen1 => MaxSpeciesID_1,
|
||||
EntityContext.Gen2 => MaxSpeciesID_2,
|
||||
EntityContext.Gen3 => MaxSpeciesID_3,
|
||||
EntityContext.Gen4 => MaxSpeciesID_4,
|
||||
EntityContext.Gen5 => MaxSpeciesID_5,
|
||||
EntityContext.Gen6 => MaxSpeciesID_6,
|
||||
EntityContext.Gen7 => MaxSpeciesID_7_USUM,
|
||||
EntityContext.Gen8 => MaxSpeciesID_8_R2,
|
||||
|
||||
EntityContext.Gen7b => MaxSpeciesID_7b,
|
||||
EntityContext.Gen8a => MaxSpeciesID_8a,
|
||||
EntityContext.Gen8b => MaxSpeciesID_8b,
|
||||
_ => -1,
|
||||
};
|
||||
|
||||
internal static int GetMaxSpeciesOrigin(int generation) => generation switch
|
||||
{
|
||||
1 => MaxSpeciesID_1,
|
||||
|
|
@ -114,19 +80,6 @@ internal static int GetMaxSpeciesOrigin(PKM pk)
|
|||
_ => -1,
|
||||
};
|
||||
|
||||
internal static int GetDebutGeneration(int species) => species switch
|
||||
{
|
||||
<= MaxSpeciesID_1 => 1,
|
||||
<= MaxSpeciesID_2 => 2,
|
||||
<= MaxSpeciesID_3 => 3,
|
||||
<= MaxSpeciesID_4 => 4,
|
||||
<= MaxSpeciesID_5 => 5,
|
||||
<= MaxSpeciesID_6 => 6,
|
||||
<= MaxSpeciesID_7b => 7,
|
||||
<= MaxSpeciesID_8a => 8,
|
||||
_ => -1,
|
||||
};
|
||||
|
||||
internal static int GetMaxLanguageID(int generation) => generation switch
|
||||
{
|
||||
1 => (int) LanguageID.Spanish, // 1-7 except 6
|
||||
|
|
@ -147,21 +100,19 @@ internal static int GetMaxSpeciesOrigin(PKM pk)
|
|||
/// <param name="pk">Entity to check</param>
|
||||
internal static bool IsOriginalMovesetDeleted(this PKM pk)
|
||||
{
|
||||
if (pk is PA8 {LA: false} or PB8 {BDSP: false})
|
||||
return true;
|
||||
if (pk.IsNative)
|
||||
{
|
||||
if (pk is PK8 {LA: true} or PK8 {BDSP: true})
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pk is IBattleVersion { BattleVersion: not 0 })
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return IsSideGameTransferDeletedMoveset(pk);
|
||||
return pk is IBattleVersion { BattleVersion: not 0 };
|
||||
}
|
||||
|
||||
private static bool IsSideGameTransferDeletedMoveset(PKM pk) => pk switch
|
||||
{
|
||||
PA8 pa8 => !pa8.LA,
|
||||
PB8 pb8 => !pb8.BDSP,
|
||||
PK8 pk8 => pk8.IsSideTransfer,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if PP Ups are available for use.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ internal static class EncounterEggGenerator2
|
|||
public static IEnumerable<EncounterEgg> GenerateEggs(PKM pk, bool all = false)
|
||||
{
|
||||
var table = EvolutionTree.Evolves2;
|
||||
int maxSpeciesOrigin = Legal.GetMaxSpeciesOrigin(2);
|
||||
const int maxSpeciesOrigin = Legal.MaxSpeciesID_2;
|
||||
var evos = table.GetValidPreEvolutions(pk, levelMax: 100, maxSpeciesOrigin: maxSpeciesOrigin, skipChecks: true);
|
||||
return GenerateEggs(pk, evos, all);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public static EvoCriteria[] GetValidPreEvolutions(PKM pk, int maxspeciesorigin =
|
|||
if (maxLevel < 0)
|
||||
maxLevel = pk.CurrentLevel;
|
||||
|
||||
if (maxspeciesorigin == -1 && pk.InhabitedGeneration(2) && pk.Format <= 2 && pk.Generation == 1)
|
||||
if (maxspeciesorigin == -1 && ParseSettings.AllowGen1Tradeback && pk.Format <= 2 && pk.Generation == 1)
|
||||
maxspeciesorigin = MaxSpeciesID_2;
|
||||
|
||||
var context = pk.Context;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ public static class MoveEgg
|
|||
{
|
||||
public static int[] GetEggMoves(int species, int form, GameVersion version, int generation)
|
||||
{
|
||||
if (species > GetMaxSpeciesOrigin(generation, version))
|
||||
return Array.Empty<int>();
|
||||
|
||||
if (!Breeding.CanGameGenerateEggs(version))
|
||||
return Array.Empty<int>();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static System.Buffers.Binary.BinaryPrimitives;
|
||||
|
||||
|
|
@ -155,6 +155,7 @@ public override void ResetMoves()
|
|||
this.SetMaximumPPCurrent(moves);
|
||||
}
|
||||
|
||||
public bool IsSideTransfer => Met_Location is Locations.HOME_SHSP or Locations.HOME_SWBD or Locations.HOME_SWLA;
|
||||
public override bool BDSP => Met_Location is Locations.HOME_SWBD or Locations.HOME_SHSP;
|
||||
public override bool LA => Met_Location is Locations.HOME_SWLA;
|
||||
public override bool HasOriginalMetLocation => base.HasOriginalMetLocation && !(BDSP || LA);
|
||||
|
|
|
|||
|
|
@ -326,7 +326,6 @@ public int Generation
|
|||
}
|
||||
}
|
||||
|
||||
public int DebutGeneration => Legal.GetDebutGeneration(Species);
|
||||
public bool PKRS_Infected { get => PKRS_Strain != 0; set => PKRS_Strain = value ? Math.Max(PKRS_Strain, 1) : 0; }
|
||||
|
||||
public bool PKRS_Cured
|
||||
|
|
@ -544,54 +543,6 @@ public virtual int HPType
|
|||
public virtual bool IsNative => Generation == Format;
|
||||
public bool IsOriginValid => Species <= MaxSpeciesID;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PKM"/> could inhabit a set of games.
|
||||
/// </summary>
|
||||
/// <param name="generation">Set of games.</param>
|
||||
/// <param name="species"></param>
|
||||
/// <returns>True if could inhabit, False if not.</returns>
|
||||
public bool InhabitedGeneration(int generation, int species = -1)
|
||||
{
|
||||
if (species < 0)
|
||||
species = Species;
|
||||
|
||||
var format = Format;
|
||||
if (format == generation)
|
||||
return true;
|
||||
|
||||
if (!IsOriginValid)
|
||||
return false;
|
||||
|
||||
// Sanity Check Species ID
|
||||
if (species > Legal.GetMaxSpeciesOrigin(generation) && !EvolutionLegality.GetFutureGenEvolutions(generation).Contains(species))
|
||||
return false;
|
||||
|
||||
// Trade generation 1 -> 2
|
||||
if (format == 2 && generation == 1 && !Korean)
|
||||
return true;
|
||||
|
||||
// Trade generation 2 -> 1
|
||||
if (format == 1 && generation == 2 && ParseSettings.AllowGen1Tradeback)
|
||||
return true;
|
||||
|
||||
if (format < generation)
|
||||
return false; // Future
|
||||
|
||||
int gen = Generation;
|
||||
return generation switch
|
||||
{
|
||||
1 => format == 1 || VC, // species compat checked via sanity above
|
||||
2 => format == 2 || VC,
|
||||
3 => Gen3,
|
||||
4 => gen is >= 3 and <= 4,
|
||||
5 => gen is >= 3 and <= 5,
|
||||
6 => gen is >= 3 and <= 6,
|
||||
7 => gen is >= 3 and <= 7 || VC,
|
||||
8 => gen is >= 3 and <= 8 || VC,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the PKM has its original met location.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user