mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 17:56:57 -05:00
Remove some reliance on GenNumber
This commit is contained in:
@@ -92,7 +92,7 @@ private void CheckClones()
|
||||
else
|
||||
Trackers.Add(tracker, cp);
|
||||
}
|
||||
else if (cp.GenNumber < 8)
|
||||
else if (ca.Info.Generation < 8)
|
||||
{
|
||||
AddLine(cp, "Missing tracker.", Encounter);
|
||||
}
|
||||
|
||||
@@ -337,17 +337,17 @@ public static IReadOnlyList<byte> GetPPTable(int format)
|
||||
};
|
||||
}
|
||||
|
||||
internal static ICollection<int> GetWildBalls(PKM pkm)
|
||||
internal static ICollection<int> GetWildBalls(int gen, GameVersion game)
|
||||
{
|
||||
return pkm.GenNumber switch
|
||||
return gen switch
|
||||
{
|
||||
1 => WildPokeBalls1,
|
||||
2 => WildPokeBalls2,
|
||||
3 => WildPokeBalls3,
|
||||
4 => (pkm.HGSS ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt),
|
||||
4 => GameVersion.HGSS.Contains(game) ? WildPokeBalls4_HGSS : WildPokeBalls4_DPPt,
|
||||
5 => WildPokeBalls5,
|
||||
6 => WildPokeballs6,
|
||||
7 => (pkm.GG ? WildPokeballs7b : WildPokeballs7),
|
||||
7 => GameVersion.GG.Contains(game) ? WildPokeballs7b : WildPokeballs7,
|
||||
8 => WildPokeballs8,
|
||||
_ => Array.Empty<int>()
|
||||
};
|
||||
|
||||
@@ -28,18 +28,12 @@ public EncounterEgg(int species, int form, int level, int gen, GameVersion game)
|
||||
Version = game;
|
||||
}
|
||||
|
||||
|
||||
public PKM ConvertToPKM(ITrainerInfo SAV) => ConvertToPKM(SAV, EncounterCriteria.Unrestricted);
|
||||
|
||||
public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria)
|
||||
{
|
||||
int gen = Version.GetGeneration();
|
||||
int gen = Generation;
|
||||
var version = Version;
|
||||
if (gen < 2)
|
||||
{
|
||||
gen = 2;
|
||||
version = GameVersion.C;
|
||||
}
|
||||
var pk = PKMConverter.GetBlank(gen, version);
|
||||
|
||||
SAV.ApplyToPKM(pk);
|
||||
@@ -48,26 +42,26 @@ public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria)
|
||||
pk.Nickname = SpeciesName.GetSpeciesNameGeneration(Species, SAV.Language, gen);
|
||||
pk.CurrentLevel = Level;
|
||||
pk.Version = (int)version;
|
||||
pk.Ball = 4;
|
||||
pk.Ball = (int)Ball.Poke;
|
||||
pk.OT_Friendship = pk.PersonalInfo.BaseFriendship;
|
||||
|
||||
int[] moves = SetEncounterMoves(pk, version);
|
||||
SetPINGA(pk, criteria);
|
||||
|
||||
if (pk.Format <= 2 && version != GameVersion.C)
|
||||
if (gen <= 2 && version != GameVersion.C)
|
||||
return pk;
|
||||
|
||||
SetMetData(pk);
|
||||
|
||||
if (pk.Format < 3)
|
||||
if (gen < 3)
|
||||
return pk;
|
||||
|
||||
if (pk.GenNumber >= 4)
|
||||
if (gen >= 4)
|
||||
pk.SetEggMetData(version, (GameVersion)SAV.Game);
|
||||
|
||||
if (pk.Format < 6)
|
||||
if (gen < 6)
|
||||
return pk;
|
||||
if (pk.Format == 6)
|
||||
if (gen == 6)
|
||||
pk.SetHatchMemory6();
|
||||
|
||||
SetAltForm(pk, SAV);
|
||||
|
||||
@@ -44,20 +44,23 @@ private static List<EvoCriteria>[] GetChainAll(PKM pkm, IEncounterable Encounter
|
||||
|
||||
int lvl = pkm.CurrentLevel;
|
||||
int maxLevel = lvl;
|
||||
int pkGen = pkm.GenNumber;
|
||||
int pkGen = Encounter.Generation;
|
||||
|
||||
// Iterate generations backwards
|
||||
// Maximum level of an earlier generation (GenX) will never be greater than a later generation (GenX+Y).
|
||||
int mingen = (pkm is PK2 || pkm.VC2) && !pkm.Gen2_NotTradeback ? 1 : pkGen;
|
||||
int mingen = pkGen >= 3 ? pkGen : pkm.Gen2_NotTradeback ? 2 : 1;
|
||||
bool noxfrDecremented = true;
|
||||
for (int g = GensEvoChains.Length - 1; g >= mingen; g--)
|
||||
{
|
||||
if (pkGen == 1 && pkm.Gen1_NotTradeback && g == 2)
|
||||
continue;
|
||||
if (pkGen <= 2 && 3 <= g && g <= 6)
|
||||
continue;
|
||||
if (pkGen <= 2)
|
||||
{
|
||||
if (3 <= g && g <= 6)
|
||||
continue;
|
||||
if (g == 2 && pkm.Gen1_NotTradeback)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (g <= 4 && 2 < pkm.Format && g < pkm.Format && !pkm.HasOriginalMetLocation && lvl > pkm.Met_Level)
|
||||
if (g <= 4 && pkm.Format > 2 && pkm.Format > g && !pkm.HasOriginalMetLocation && lvl > pkm.Met_Level)
|
||||
{
|
||||
// Met location was lost at this point but it also means the pokemon existed in generations 1 to 4 with maximum level equals to met level
|
||||
lvl = pkm.Met_Level;
|
||||
|
||||
@@ -71,7 +71,7 @@ private CheckResult VerifyBallStatic(LegalityAnalysis data, EncounterStatic s)
|
||||
{
|
||||
if (s.Location == 75 && s.Generation == 5) // Entree Forest (Dream World)
|
||||
return VerifyBallEquals(data, Legal.DreamWorldBalls);
|
||||
return VerifyBallEquals(data, Legal.GetWildBalls(data.pkm));
|
||||
return VerifyBallEquals(data, Legal.GetWildBalls(data.Info.Generation, data.Info.Game));
|
||||
}
|
||||
|
||||
private CheckResult VerifyBallWild(LegalityAnalysis data, EncounterSlot w)
|
||||
@@ -88,7 +88,7 @@ private CheckResult VerifyBallWild(LegalityAnalysis data, EncounterSlot w)
|
||||
return VerifyBallEquals(data, (int)Safari); // Safari Ball
|
||||
if (Info.Generation == 4 && w.Type == SlotType.BugContest)
|
||||
return VerifyBallEquals(data, (int)Sport); // Sport Ball
|
||||
return VerifyBallEquals(data, Legal.GetWildBalls(data.pkm));
|
||||
return VerifyBallEquals(data, Legal.GetWildBalls(data.Info.Generation, data.Info.Game));
|
||||
}
|
||||
|
||||
private CheckResult VerifyBallEgg(LegalityAnalysis data)
|
||||
|
||||
@@ -86,7 +86,7 @@ public static bool IsEdgeCaseLength(PKM pkm, IEncounterable e, string ot)
|
||||
bool eggEdge = pkm.IsEgg ? pkm.IsTradedEgg || pkm.Format == 3 : pkm.WasTradedEgg;
|
||||
if (!eggEdge)
|
||||
return false;
|
||||
var len = Legal.GetMaxLengthOT(pkm.GenNumber, LanguageID.English); // max case
|
||||
var len = Legal.GetMaxLengthOT(e.Generation, LanguageID.English); // max case
|
||||
return ot.Length <= len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user