From 3a424c8b5b8784d502bc4fa262a904d49eb3b796 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Thu, 5 May 2016 20:35:18 -0700 Subject: [PATCH] Add memorycheck 14 (species can be captured) --- Legality/Checks.cs | 8 ++++++++ Legality/Core.cs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Legality/Checks.cs b/Legality/Checks.cs index ed248bbc6..d45b5e77c 100644 --- a/Legality/Checks.cs +++ b/Legality/Checks.cs @@ -648,6 +648,10 @@ namespace PKHeX { case 4: // {0} became {1}’s friend when it arrived via Link Trade at... {2}. {4} that {3}. return new LegalityCheck(Severity.Invalid, "OT Memory: Link Trade is not a valid first memory."); + case 14: + if (!Legal.getCanBeCaptured(pk6.OT_TextVar, pk6.Version)) + return new LegalityCheck(Severity.Invalid, "OT Memory: Captured Species can not be captured in game."); + return new LegalityCheck(Severity.Valid, "OT Memory: Captured Species can be captured in game."); } if (pk6.XY && Legal.Memory_NotXY.Contains(pk6.OT_Memory)) return new LegalityCheck(Severity.Invalid, "OT Memory: OR/AS exclusive memory on X/Y origin."); @@ -667,6 +671,10 @@ namespace PKHeX return new LegalityCheck(Severity.Invalid, "HT Memory: Handling Trainer did not capture this."); case 2: // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}. return new LegalityCheck(Severity.Invalid, "HT Memory: Handling Trainer did not hatch this."); + case 14: + if (!Legal.getCanBeCaptured(pk6.HT_TextVar)) + return new LegalityCheck(Severity.Invalid, "HT Memory: Captured Species can not be captured in game."); + return new LegalityCheck(Severity.Valid, "HT Memory: Captured Species can be captured in game."); } return new LegalityCheck(Severity.Valid, "HT Memory is valid."); } diff --git a/Legality/Core.cs b/Legality/Core.cs index 59af8d825..2fc5fe603 100644 --- a/Legality/Core.cs +++ b/Legality/Core.cs @@ -353,6 +353,43 @@ namespace PKHeX return res.Distinct(); } + internal static bool getCanBeCaptured(int species, int version = -1) + { + if (version < 0 || version == (int)GameVersion.X) + { + if (SlotsX.Any(loc => loc.Slots.Any(slot => slot.Species == species))) + return true; + if (FriendSafari.Contains(species)) + return true; + if (StaticX.Any(enc => enc.Species == species && !enc.Gift)) + return true; + } + if (version < 0 || version == (int)GameVersion.Y) + { + if (SlotsY.Any(loc => loc.Slots.Any(slot => slot.Species == species))) + return true; + if (FriendSafari.Contains(species)) + return true; + if (StaticY.Any(enc => enc.Species == species && !enc.Gift)) + return true; + } + if (version < 0 || version == (int)GameVersion.AS) + { + if (SlotsA.Any(loc => loc.Slots.Any(slot => slot.Species == species))) + return true; + if (StaticA.Any(enc => enc.Species == species && !enc.Gift)) + return true; + } + if (version < 0 || version == (int)GameVersion.OR) + { + if (SlotsO.Any(loc => loc.Slots.Any(slot => slot.Species == species))) + return true; + if (StaticO.Any(enc => enc.Species == species && !enc.Gift)) + return true; + } + return false; + } + private static int getBaseSpecies(PK6 pk6, int skipOption = 0) { if (pk6.Species == 292)