diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index fb6a42376..11f74c889 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -168,6 +168,19 @@ private static EncounterArea[] addExtraTableSlots(EncounterArea[] GameSlots, Enc } return GameSlots; } + private static void ReduceAreasSize(ref EncounterArea[] Areas) + { + // Group areas by location id, the raw data have areas with different slots but the same location id + Areas = Areas.GroupBy(a => a.Location).Select(a => new EncounterArea + { + Location = a.First().Location, + Slots = a.SelectMany(m => m.Slots).ToArray() + }).ToArray(); + } + private static void MarkG2Slots(ref EncounterArea[] Areas) + { + ReduceAreasSize(ref Areas); + } private static void MarkG3Slots_FRLG(ref EncounterArea[] Areas) { // Remove slots for unown, those slots does not contains alt form info, it will be added manually in SlotsRFLGAlt @@ -180,12 +193,7 @@ private static void MarkG3Slots_FRLG(ref EncounterArea[] Areas) } private static void MarkG3Slots_RSE(ref EncounterArea[] Areas) { - // Group areas by location id, the raw data have areas with different slots but the same location id - Areas = Areas.GroupBy(a => a.Location).Select(a => new EncounterArea - { - Location = a.First().Location, - Slots = a.SelectMany(m => m.Slots).ToArray() - }).ToArray(); + ReduceAreasSize(ref Areas); } private static void MarkG4SwarmSlots(ref EncounterArea[] Areas, EncounterArea[] SwarmAreas) { @@ -206,14 +214,21 @@ private static void MarkG4SwarmSlots(ref EncounterArea[] Areas, EncounterArea[] Area.Slots = Area.Slots.Concat(OutputSlots).Where(a => a.Species > 0).ToArray(); } } + // Gen 4 raw encounter data does not contains info for alt slots + // Shellos and Gastrodom East Sea form should be modified + private static void MarkG4AltFormSlots(ref EncounterArea[] Areas, int Species, int form, int[] Locations) + { + foreach(EncounterArea Area in Areas.Where(a => Locations.Contains(a.Location))) + { + foreach (EncounterSlot Slot in Area.Slots.Where(s=>s.Species == Species)) + { + Slot.Form = form; + } + } + } private static void MarkG4Slots(ref EncounterArea[] Areas) { - // Group areas by location id, the raw data have areas with different slots but the same location id - Areas = Areas.GroupBy(a => a.Location).Select(a => new EncounterArea - { - Location = a.First().Location, - Slots = a.SelectMany(m => m.Slots).ToArray() - }).ToArray(); + ReduceAreasSize(ref Areas); } private static void MarkG5Slots(ref EncounterArea[] Areas) { @@ -245,12 +260,7 @@ private static void MarkG5Slots(ref EncounterArea[] Areas) } while (ctr != area.Slots.Length); area.Slots = area.Slots.Where(slot => slot.Species != 0).ToArray(); } - // Group areas by location id, the raw data have areas with different slots but the same location id - Areas = Areas.GroupBy(a => a.Location).Select(a => new EncounterArea - { - Location = a.First().Location, - Slots = a.SelectMany(m => m.Slots).ToArray() - }).ToArray(); + ReduceAreasSize(ref Areas); } private static void MarkG6XYSlots(ref EncounterArea[] Areas) { @@ -260,6 +270,7 @@ private static void MarkG6XYSlots(ref EncounterArea[] Areas) for (int i = slotct - 15; i < slotct; i++) area.Slots[i].Type = SlotType.Horde; } + ReduceAreasSize(ref Areas); } private static void MarkG6AOSlots(ref EncounterArea[] Areas) { @@ -274,11 +285,17 @@ private static void MarkG6AOSlots(ref EncounterArea[] Areas) for (int i = 0; i < slotct; i++) area.Slots[i].AllowDexNav = area.Slots[i].Type != SlotType.Rock_Smash; } + ReduceAreasSize(ref Areas); + } + private static void MarkG7REGSlots(ref EncounterArea[] Areas) + { + ReduceAreasSize(ref Areas); } private static void MarkG7SMSlots(ref EncounterArea[] Areas) { foreach (EncounterSlot s in Areas.SelectMany(area => area.Slots)) s.Type = SlotType.SOS; + ReduceAreasSize(ref Areas); } private static EncounterArea[] getTables1() { @@ -337,6 +354,7 @@ private static EncounterArea[] getTables2(GameVersion Version) { StaticRBY = getStaticEncounters(GameVersion.RBY); SlotsRBY = getTables1(); + // Gen 1 is the only gen where ReduceAreasSize is not needed Evolves1 = new EvolutionTree(new[] { Resources.evos_rby }, GameVersion.RBY, PersonalTable.Y, MaxSpeciesID_1); } // Gen 2 @@ -347,6 +365,9 @@ private static EncounterArea[] getTables2(GameVersion Version) SlotsGS = getTables2(GameVersion.GS); SlotsC = getTables2(GameVersion.C); SlotsGSC = getTables2(GameVersion.GSC); + MarkG2Slots(ref SlotsGS); + MarkG2Slots(ref SlotsC); + MarkG2Slots(ref SlotsGSC); Evolves2 = new EvolutionTree(new[] { Resources.evos_gsc }, GameVersion.GSC, PersonalTable.C, MaxSpeciesID_2); } // Gen3 @@ -413,6 +434,13 @@ private static EncounterArea[] getTables2(GameVersion Version) MarkG4SwarmSlots(ref HG_Slots, SlotsHG_Swarm); MarkG4SwarmSlots(ref SS_Slots, SlotsSS_Swarm); + MarkG4AltFormSlots(ref D_Slots, 422, 1, Shellos_EastSeaLocation_DP); + MarkG4AltFormSlots(ref D_Slots, 423, 1, Gastrodon_EastSeaLocation_DP); + MarkG4AltFormSlots(ref P_Slots, 422, 1, Shellos_EastSeaLocation_DP); + MarkG4AltFormSlots(ref P_Slots, 423, 1, Gastrodon_EastSeaLocation_DP); + MarkG4AltFormSlots(ref Pt_Slots, 422, 1, Shellos_EastSeaLocation_Pt); + MarkG4AltFormSlots(ref Pt_Slots, 423, 1, Gastrodon_EastSeaLocation_Pt); + MarkG4Slots(ref D_Slots); MarkG4Slots(ref P_Slots); MarkG4Slots(ref Pt_Slots); @@ -481,6 +509,8 @@ private static EncounterArea[] getTables2(GameVersion Version) var REG_MN = getEncounterTables(GameVersion.MN); var SOS_SN = getEncounterTables(Resources.encounter_sn_sos, "sm"); var SOS_MN = getEncounterTables(Resources.encounter_mn_sos, "sm"); + MarkG7REGSlots(ref REG_SN); + MarkG7REGSlots(ref REG_MN); MarkG7SMSlots(ref SOS_SN); MarkG7SMSlots(ref SOS_MN); SlotsSN = addExtraTableSlots(REG_SN, SOS_SN).Concat(Encounter_Pelago_SM).Concat(Encounter_Pelago_SN).ToArray(); diff --git a/PKHeX/Legality/Tables3.cs b/PKHeX/Legality/Tables3.cs index a6233fc62..688b2c14e 100644 --- a/PKHeX/Legality/Tables3.cs +++ b/PKHeX/Legality/Tables3.cs @@ -511,7 +511,7 @@ public static partial class Legal 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 055, 056, 057, 058, 059, 060, 061, 062, 063, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, - 081, 082, 083, 084, 085, 086, 087, + 081, 082, 083, 085, 086, 087, }; internal static readonly int[] ValidMet_FRLG = { diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index 313c439b0..f5cc9d437 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -538,6 +538,35 @@ public static partial class Legal }).ToArray() }; + private static readonly int[] Shellos_EastSeaLocation_DP = new[] + { + 28, // Route 213 + 34, // Route 224 + }; + + private static readonly int[] Shellos_EastSeaLocation_Pt = new[] + { + 11, // Pastoria City + 27, // Route 212 + 28, // Route 213 + }; + + private static readonly int[] Gastrodon_EastSeaLocation_DP = new[] + { + 37, // Route 222 + 39, // Route 224 + 45, // Route 230 + }; + + private static readonly int[] Gastrodon_EastSeaLocation_Pt = new[] + { + 11, // Pastoria City + 27, // Route 212 + 28, // Route 213 + 39, // Route 224 + 45, // Route 230 + }; + private static readonly int[] HoneyTreesLocation = new[] { 20, // Route 205