diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 4c37fa00c..d4ccad9d6 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -11,12 +11,17 @@ namespace PKHeX.Core public static MysteryGift[] MGDB_G6, MGDB_G7 = new MysteryGift[0]; // Gen 1 - private static readonly Learnset[] LevelUpRB = Learnset1.getArray(Resources.lvlmove_rb); - private static readonly Learnset[] LevelUpY = Learnset1.getArray(Resources.lvlmove_y); + private static readonly Learnset[] LevelUpRB = Learnset1.getArray(Resources.lvlmove_rb, MaxSpeciesID_1); + private static readonly Learnset[] LevelUpY = Learnset1.getArray(Resources.lvlmove_y, MaxSpeciesID_1); private static readonly EvolutionTree Evolves1; private static readonly EncounterArea[] SlotsRBY; private static readonly EncounterStatic[] StaticRBY; + // Gen 2 + private static readonly Learnset[] LevelUpGS = Learnset1.getArray(Resources.lvlmove_gs, MaxSpeciesID_2); + private static readonly Learnset[] LevelUpC = Learnset1.getArray(Resources.lvlmove_c, MaxSpeciesID_2); + private static readonly EvolutionTree Evolves2; + // Gen 6 private static readonly EggMoves[] EggMovesXY = EggMoves6.getArray(Data.unpackMini(Resources.eggmove_xy, "xy")); private static readonly Learnset[] LevelUpXY = Learnset6.getArray(Data.unpackMini(Resources.lvlmove_xy, "xy")); @@ -153,6 +158,10 @@ namespace PKHeX.Core SlotsRBY[SlotsRBY.Length - 1] = FishOldGood_RBY; StaticRBY = getStaticEncounters(GameVersion.RBY); } + // Gen 2 + { + Evolves2 = new EvolutionTree(new[] { Resources.evos_gsc }, GameVersion.GSC, PersonalTable.C, MaxSpeciesID_2); + } // Gen 6 { StaticX = getStaticEncounters(GameVersion.X); @@ -439,6 +448,8 @@ namespace PKHeX.Core { case 1: return Evolves1; + case 2: + return Evolves2; case 6: return Evolves6; diff --git a/PKHeX/Legality/Structures/EvolutionTree.cs b/PKHeX/Legality/Structures/EvolutionTree.cs index 8a834e352..02afdbb98 100644 --- a/PKHeX/Legality/Structures/EvolutionTree.cs +++ b/PKHeX/Legality/Structures/EvolutionTree.cs @@ -20,7 +20,10 @@ namespace PKHeX.Core switch (game) { case GameVersion.RBY: - Entries = EvolutionSet1.getArray(data[0]); + Entries = EvolutionSet1.getArray(data[0], maxSpeciesTree); + break; + case GameVersion.GSC: + Entries = EvolutionSet2.getArray(data[0], maxSpeciesTree); break; case GameVersion.ORAS: Entries.AddRange(data.Select(d => new EvolutionSet6(d))); @@ -174,7 +177,7 @@ namespace PKHeX.Core case 1: // Level var m1 = new EvolutionMethod { - Method = 1, // Use Item + Method = 1, // Level Up Level = data[offset + 1], Species = data[offset + 2] }; @@ -202,11 +205,11 @@ namespace PKHeX.Core } return null; } - public static List getArray(byte[] data) + public static List getArray(byte[] data, int maxSpecies) { var evos = new List(); int offset = 0; - for (int i = 0; i <= Legal.MaxSpeciesID_1; i++) + for (int i = 0; i <= maxSpecies; i++) { var m = new List(); while (data[offset] != 0) @@ -217,6 +220,42 @@ namespace PKHeX.Core return evos; } } + public class EvolutionSet2 : EvolutionSet + { + private static EvolutionMethod getMethod(byte[] data, ref int offset) + { + int method = data[offset]; + int arg = data[offset + 1]; + int species = data[offset + 2]; + offset += 3; + + switch (method) + { + case 1: /* Level Up */ return new EvolutionMethod { Method = 1, Species = species, Level = arg }; + case 2: /* Use Item */ return new EvolutionMethod { Method = 8, Species = species, Argument = arg }; + case 3: /* Trade */ return new EvolutionMethod { Method = 5, Species = species }; + case 4: /*Friendship*/ return new EvolutionMethod { Method = 1, Species = species }; + case 5: /* Stats */ + // species is currently stat ID, we don't care about evo type as stats can be changed after evo + return new EvolutionMethod { Method = 1, Species = data[offset++], Level = arg }; // Tyrogue stats + } + return null; + } + public static List getArray(byte[] data, int maxSpecies) + { + var evos = new List(); + int offset = 0; + for (int i = 0; i <= maxSpecies; i++) + { + var m = new List(); + while (data[offset] != 0) + m.Add(getMethod(data, ref offset)); + ++offset; + evos.Add(new EvolutionSet2 { PossibleEvolutions = m.ToArray() }); + } + return evos; + } + } public class EvolutionSet6 : EvolutionSet { private const int SIZE = 6; diff --git a/PKHeX/Legality/Structures/Learnset.cs b/PKHeX/Legality/Structures/Learnset.cs index e2979151e..4a973c7f0 100644 --- a/PKHeX/Legality/Structures/Learnset.cs +++ b/PKHeX/Legality/Structures/Learnset.cs @@ -36,9 +36,9 @@ namespace PKHeX.Core Levels = levels.ToArray(); Count = Moves.Length; } - public static Learnset[] getArray(byte[] input) + public static Learnset[] getArray(byte[] input, int maxSpecies) { - var data = new Learnset[Legal.MaxSpeciesID_1 + 1]; + var data = new Learnset[maxSpecies + 1]; int offset = 0; for (int s = 0; s < data.Length; s++) diff --git a/PKHeX/PKHeX.Core.csproj b/PKHeX/PKHeX.Core.csproj index 132316f70..a1c307766 100644 --- a/PKHeX/PKHeX.Core.csproj +++ b/PKHeX/PKHeX.Core.csproj @@ -270,12 +270,15 @@ + + + diff --git a/PKHeX/Properties/Resources.Designer.cs b/PKHeX/Properties/Resources.Designer.cs index a534e828a..75ac26f36 100644 --- a/PKHeX/Properties/Resources.Designer.cs +++ b/PKHeX/Properties/Resources.Designer.cs @@ -12324,14 +12324,15 @@ namespace PKHeX.Core.Properties { /// Looks up a localized string similar to PKHeX - By Kaphotics ///http://projectpokemon.org/pkhex /// - ///17/02/07 - New Update: + ///17/02/25 - New Update: /// - Legality: - /// - - Added: Legality indication for exported QR images (if legality check is available for origin). - /// - - Added: Legality indication for Box/Party pkm slots (^ + opt-in via Options->Set to SAV). + /// - - Added: Legality checking for RBY Pokémon as pk1 and pk7+. /// - - Fixed: More edge cases for legality checks. - /// - Added: More Generation 7 trainer stat record labels. Thanks skywalker25 & Holla! - /// - Added: G7TID -> TID/SID generator for Generation 7 Trainer Editor. Thanks RoC! - /// - [rest of string was truncated]";. + /// - Batch Editor: + /// - - Added: Nickname clearing to batch editor (via .IsNicknamed=False). + /// - - Added: Legality filtering and bulk suggestions for Met Location, Current Moves & Relearn Moves. + /// - - - Use $suggest to use suggested result from the legality analysis. + /// - - Changed: Properties are now sort [rest of string was truncated]";. /// public static string changelog { get { @@ -12591,6 +12592,16 @@ namespace PKHeX.Core.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] evos_gsc { + get { + object obj = ResourceManager.GetObject("evos_gsc", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -17823,6 +17834,26 @@ namespace PKHeX.Core.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] lvlmove_c { + get { + object obj = ResourceManager.GetObject("lvlmove_c", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + public static byte[] lvlmove_gs { + get { + object obj = ResourceManager.GetObject("lvlmove_gs", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Byte[]. /// @@ -18084,7 +18115,7 @@ namespace PKHeX.Core.Properties { } /// - /// Looks up a localized string similar to 20170207. + /// Looks up a localized string similar to 20170225. /// public static string ProgramVersion { get { @@ -34274,8 +34305,8 @@ namespace PKHeX.Core.Properties { ///小磁怪 ///三合一磁怪 ///大蔥鴨 - ///都都 - ///都都利 + ///嘟嘟 + ///嘟嘟利 ///小海獅 ///白海獅 ///臭泥 diff --git a/PKHeX/Properties/Resources.resx b/PKHeX/Properties/Resources.resx index e289d474b..77081cc35 100644 --- a/PKHeX/Properties/Resources.resx +++ b/PKHeX/Properties/Resources.resx @@ -7411,4 +7411,13 @@ ..\Resources\byte\personal_y;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\byte\evos_gsc.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\byte\lvlmove_c.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\byte\lvlmove_gs.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/PKHeX/Resources/byte/evos_gsc.pkl b/PKHeX/Resources/byte/evos_gsc.pkl new file mode 100644 index 000000000..40c6e9fdd Binary files /dev/null and b/PKHeX/Resources/byte/evos_gsc.pkl differ diff --git a/PKHeX/Resources/byte/lvlmove_c.pkl b/PKHeX/Resources/byte/lvlmove_c.pkl new file mode 100644 index 000000000..c3dfc6b1b Binary files /dev/null and b/PKHeX/Resources/byte/lvlmove_c.pkl differ diff --git a/PKHeX/Resources/byte/lvlmove_gs.pkl b/PKHeX/Resources/byte/lvlmove_gs.pkl new file mode 100644 index 000000000..b57f012ec Binary files /dev/null and b/PKHeX/Resources/byte/lvlmove_gs.pkl differ