From 9eb28533de44c9a30cdcfc55ef9071920b2dd1b1 Mon Sep 17 00:00:00 2001 From: Oliver Garcia Date: Tue, 10 May 2016 00:09:40 +0100 Subject: [PATCH] Checks for PKM Center memories --- Legality/Checks.cs | 14 ++++++++++++++ Legality/Tables.cs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/Legality/Checks.cs b/Legality/Checks.cs index 92e14ce37..ff74f0356 100644 --- a/Legality/Checks.cs +++ b/Legality/Checks.cs @@ -639,15 +639,18 @@ namespace PKHeX private LegalityCheck verifyCommonMemory(int handler) { int m = 0; + int t = 0; string resultPrefix = ""; switch (handler) { case 0: m = pk6.OT_Memory; + t = pk6.OT_TextVar; resultPrefix = "OT "; break; case 1: m = pk6.HT_Memory; + t = pk6.HT_TextVar; resultPrefix = "HT "; break; } @@ -656,6 +659,10 @@ namespace PKHeX { return new LegalityCheck(Severity.Invalid, resultPrefix + "Memory: Species cannot learn this move."); } + if (m == 6 && !Legal.LocationsWithPKCenter[0].Contains(t)) + { + return new LegalityCheck(Severity.Invalid, resultPrefix + "Memory: Location doesn't have a Pokemon Center."); + } return new LegalityCheck(Severity.Valid, resultPrefix + "Memory is valid."); } private LegalityCheck verifyOTMemory() @@ -678,6 +685,13 @@ 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 6: // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}. + int matchingOriginGame = Array.IndexOf(Legal.LocationsWithPKCenter[0], pk6.OT_TextVar); + if (matchingOriginGame != -1) { + if ((Legal.LocationsWithPKCenter[1][matchingOriginGame] == 1 && pk6.XY) || ((Legal.LocationsWithPKCenter[1][matchingOriginGame] == 0 && pk6.AO))) + return new LegalityCheck(Severity.Invalid, "OT Memory: Location doesn't exist on Origin Game region."); + } + return verifyCommonMemory(0); 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."); diff --git a/Legality/Tables.cs b/Legality/Tables.cs index e6ab0baac..8cdad0b5e 100644 --- a/Legality/Tables.cs +++ b/Legality/Tables.cs @@ -914,6 +914,44 @@ }, new[] { 57, 19, 70, 15, 249, 127, 291}, // Move IDs }; + internal static readonly int[][] LocationsWithPKCenter = + { + new[] { + // Kalos locations with a PKMN CENTER + 18, // Santalune City + 22, // Lumiose City + 30, // Camphrier Town + 40, // Cyllage City + 44, // Ambrette Town + 52, // Geosenge Towny + 58, // Shalour City + 64, // Coumarine City + 70, // Laverre City + 76, // Dendemille Town + 86, // Anistar City + 90, // Couriway Town + 94, // Snowbelle City + 106, // Pokémon League (X/Y) + // Hoenn locations with a PKMN CENTER + 172, // Oldale Town + 174, // Dewford Town + 176, // Lavaridge Town + 178, // Fallarbor Town + 180, // Verdanturf Town + 182, // Pacifidlog Town + 184, // Petalburg City + 186, // Slateport City + 188, // Mauville City + 190, // Rustboro City + 192, // Fortree City + 194, // Lilycove City + 196, // Mossdeep City + 198, // Sootopolis City + 200, // Ever Grande City + 202, // Pokémon League (OR/AS) + }, + new[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Region matching + }; #endregion } }