diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters8Nest.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters8Nest.cs index eda374d00..e68d250da 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters8Nest.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters8Nest.cs @@ -1320,7 +1320,6 @@ internal static class Encounters8Nest new EncounterStatic8N(Nest91,0,1,1) { Species = 588, Ability = A3 }, // Karrablast new EncounterStatic8N(Nest91,1,2,2) { Species = 616, Ability = A3 }, // Shelmet new EncounterStatic8N(Nest91,4,4,4) { Species = 589, Ability = A4 }, // Escavalier - }; internal static readonly EncounterStatic8N[] Nest_SH = diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionLineage.cs b/PKHeX.Core/Legality/Evolutions/EvolutionLineage.cs index ac6a15a1b..018344d8d 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionLineage.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionLineage.cs @@ -25,7 +25,7 @@ public void Insert(EvolutionMethod entry) Chain.Insert(0, new List {entry}); } - public List GetExplicitLineage(PKM pkm, int maxLevel, bool skipChecks, int maxSpeciesTree, int maxSpeciesOrigin, int minLevel) + public List GetExplicitLineage(PKM pkm, int maxLevel, bool skipChecks, int maxSpeciesOrigin, int minLevel) { int lvl = maxLevel; var first = new EvoCriteria {Species = pkm.Species, Level = lvl, Form = pkm.AltForm}; diff --git a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs index 30a16f4d7..1f5ab898d 100644 --- a/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs +++ b/PKHeX.Core/Legality/Evolutions/EvolutionTree.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using static PKHeX.Core.GameVersion; namespace PKHeX.Core { @@ -27,15 +28,15 @@ static EvolutionTree() static byte[] get(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl"); static byte[][] unpack(string resource) => Data.UnpackMini(get(resource), resource); - Evolves1 = new EvolutionTree(new[] { get("rby") }, GameVersion.Gen1, PersonalTable.Y, Legal.MaxSpeciesID_1); - Evolves2 = new EvolutionTree(new[] { get("gsc") }, GameVersion.Gen2, PersonalTable.C, Legal.MaxSpeciesID_2); - Evolves3 = new EvolutionTree(new[] { get("g3") }, GameVersion.Gen3, PersonalTable.RS, Legal.MaxSpeciesID_3); - Evolves4 = new EvolutionTree(new[] { get("g4") }, GameVersion.Gen4, PersonalTable.DP, Legal.MaxSpeciesID_4); - Evolves5 = new EvolutionTree(new[] { get("g5") }, GameVersion.Gen5, PersonalTable.BW, Legal.MaxSpeciesID_5); - Evolves6 = new EvolutionTree(unpack("ao"), GameVersion.Gen6, PersonalTable.AO, Legal.MaxSpeciesID_6); - Evolves7 = new EvolutionTree(unpack("uu"), GameVersion.Gen7, PersonalTable.USUM, Legal.MaxSpeciesID_7_USUM); - Evolves7b = new EvolutionTree(unpack("gg"), GameVersion.Gen7, PersonalTable.GG, Legal.MaxSpeciesID_7b); - Evolves8 = new EvolutionTree(unpack("ss"), GameVersion.Gen8, PersonalTable.SWSH, Legal.MaxSpeciesID_8); + Evolves1 = new EvolutionTree(new[] { get("rby") }, Gen1, PersonalTable.Y, Legal.MaxSpeciesID_1); + Evolves2 = new EvolutionTree(new[] { get("gsc") }, Gen2, PersonalTable.C, Legal.MaxSpeciesID_2); + Evolves3 = new EvolutionTree(new[] { get("g3") }, Gen3, PersonalTable.RS, Legal.MaxSpeciesID_3); + Evolves4 = new EvolutionTree(new[] { get("g4") }, Gen4, PersonalTable.DP, Legal.MaxSpeciesID_4); + Evolves5 = new EvolutionTree(new[] { get("g5") }, Gen5, PersonalTable.BW, Legal.MaxSpeciesID_5); + Evolves6 = new EvolutionTree(unpack("ao"), Gen6, PersonalTable.AO, Legal.MaxSpeciesID_6); + Evolves7 = new EvolutionTree(unpack("uu"), Gen7, PersonalTable.USUM, Legal.MaxSpeciesID_7_USUM); + Evolves7b = new EvolutionTree(unpack("gg"), Gen7, PersonalTable.GG, Legal.MaxSpeciesID_7b); + Evolves8 = new EvolutionTree(unpack("ss"), Gen8, PersonalTable.SWSH, Legal.MaxSpeciesID_8); // There's always oddballs. Evolves7.FixEvoTreeSM(); @@ -91,14 +92,14 @@ private IReadOnlyList GetEntries(IReadOnlyList data) { return Game switch { - GameVersion.Gen1 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree), - GameVersion.Gen2 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree), - GameVersion.Gen3 => EvolutionSet3.GetArray(data[0]), - GameVersion.Gen4 => EvolutionSet4.GetArray(data[0]), - GameVersion.Gen5 => EvolutionSet5.GetArray(data[0]), - GameVersion.Gen6 => EvolutionSet6.GetArray(data), - GameVersion.Gen7 => EvolutionSet7.GetArray(data), - GameVersion.Gen8 => EvolutionSet7.GetArray(data), + Gen1 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree), + Gen2 => EvolutionSet1.GetArray(data[0], MaxSpeciesTree), + Gen3 => EvolutionSet3.GetArray(data[0]), + Gen4 => EvolutionSet4.GetArray(data[0]), + Gen5 => EvolutionSet5.GetArray(data[0]), + Gen6 => EvolutionSet6.GetArray(data), + Gen7 => EvolutionSet7.GetArray(data), + Gen8 => EvolutionSet7.GetArray(data), _ => throw new Exception() }; } @@ -108,7 +109,7 @@ private EvolutionLineage[] CreateTree() var lineage = new EvolutionLineage[Entries.Count]; for (int i = 0; i < Entries.Count; i++) lineage[i] = new EvolutionLineage(); - if (Game == GameVersion.Gen6) + if (Game == Gen6) Array.Resize(ref lineage, MaxSpeciesTree + 1); if (Game.GetGeneration() <= 6) @@ -119,13 +120,13 @@ private EvolutionLineage[] CreateTree() return lineage; } - private void GenerateEntriesSpeciesOnly(EvolutionLineage[] lineage) + private void GenerateEntriesSpeciesOnly(IReadOnlyList lineage) { - for (int species = 1; species < lineage.Length; species++) + for (int species = 1; species < lineage.Count; species++) CreateBranch(lineage, species, 0, species); } - private void GenerateEntriesSpeciesForm(EvolutionLineage[] lineage) + private void GenerateEntriesSpeciesForm(IReadOnlyList lineage) { for (int species = 1; species <= MaxSpeciesTree; species++) { @@ -264,9 +265,15 @@ public List GetValidPreEvolutions(PKM pkm, int maxLevel, int maxSpe int index = GetIndex(pkm); if (maxSpeciesOrigin <= 0) maxSpeciesOrigin = Legal.GetMaxSpeciesOrigin(pkm); - return Lineage[index].GetExplicitLineage(pkm, maxLevel, skipChecks, MaxSpeciesTree, maxSpeciesOrigin, minLevel); + return Lineage[index].GetExplicitLineage(pkm, maxLevel, skipChecks, maxSpeciesOrigin, minLevel); } + /// + /// Gets all species the - can evolve to & from. + /// + /// Species ID + /// Form ID + /// Enumerable of species IDs. public IEnumerable GetEvolutionsAndPreEvolutions(int species, int form) { foreach (var s in GetPreEvolutions(species, form)) diff --git a/PKHeX.Drawing/Sprites/SpriteUtil.cs b/PKHeX.Drawing/Sprites/SpriteUtil.cs index e507c91a1..591ac1a9a 100644 --- a/PKHeX.Drawing/Sprites/SpriteUtil.cs +++ b/PKHeX.Drawing/Sprites/SpriteUtil.cs @@ -98,12 +98,12 @@ private static Image GetSprite(PKM pk, bool isBoxBGRed = false) img = Spriter.GetSprite(Resources._249x, Lugia, pk.HeldItem, pk.IsEgg, pk.IsShiny, pk.Format, isBoxBGRed); GetSpriteGlow(pk, 75, 0, 130, out var pixels, out var baseSprite, true); var glowImg = ImageUtil.GetBitmap(pixels, baseSprite.Width, baseSprite.Height, baseSprite.PixelFormat); - img = ImageUtil.LayerImage(glowImg, img, 0, 0); + return ImageUtil.LayerImage(glowImg, img, 0, 0); } - else if (pk is IGigantamax g && g.CanGigantamax) + if (pk is IGigantamax g && g.CanGigantamax) { var gm = Resources.dyna; - img = ImageUtil.LayerImage(img, gm, (img.Width - gm.Width) / 2, 0); + return ImageUtil.LayerImage(img, gm, (img.Width - gm.Width) / 2, 0); } return img; }