From b7acb7fa1dffe1b6da3252e0edc020833649b578 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 12 Oct 2018 17:45:52 -0700 Subject: [PATCH] Add memory rarity table --- PKHeX.Core/Game/GameUtil.cs | 7 ++ PKHeX.Core/Legality/Memories.cs | 98 ++++++++++++------- .../Legality/Verifiers/AbilityVerifier.cs | 1 - .../Legality/Verifiers/MemoryVerifier.cs | 8 +- 4 files changed, 71 insertions(+), 43 deletions(-) diff --git a/PKHeX.Core/Game/GameUtil.cs b/PKHeX.Core/Game/GameUtil.cs index c6f7446fd..48a19cce2 100644 --- a/PKHeX.Core/Game/GameUtil.cs +++ b/PKHeX.Core/Game/GameUtil.cs @@ -146,6 +146,13 @@ namespace PKHeX.Core return -1; } + /// + /// Checks if the version (or subset versions) is equivalent to . + /// + /// Version (set) + /// Individual version + public static bool Contains(this GameVersion g1, int g2) => g1.Contains((GameVersion) g2); + /// /// Checks if the version (or subset versions) is equivalent to . /// diff --git a/PKHeX.Core/Legality/Memories.cs b/PKHeX.Core/Legality/Memories.cs index f0177d221..fc154471e 100644 --- a/PKHeX.Core/Legality/Memories.cs +++ b/PKHeX.Core/Legality/Memories.cs @@ -59,46 +59,55 @@ namespace PKHeX.Core new[] { 57, 19, 70, 15, 249, 127, 291}, // Move IDs }; - internal static readonly int[][] LocationsWithPKCenter = + 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 + // 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) }; - internal static readonly byte[] MemoryMinIntensity = + internal static GameVersion GetGameVersionForPokeCenterIndex(int index) + { + return PokeCenterVersion[index] == 0 ? GameVersion.XY : GameVersion.ORAS; + } + + private static readonly int[] PokeCenterVersion = // Region matching + { + 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 + }; + + private static readonly byte[] MemoryMinIntensity = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, @@ -109,7 +118,20 @@ namespace PKHeX.Core 3, 3, 3, 3, 3, 2, 3, 4, 4, 2, }; - internal static readonly uint[] MemoryFeelings = + public static int GetMemoryRarity(int memory) => (uint) memory >= MemoryRandChance.Length ? -1 : MemoryRandChance[memory]; + + private static readonly byte[] MemoryRandChance = + { + 000, 100, 100, 100, 100, 005, 005, 005, 005, 005, + 005, 005, 005, 005, 010, 020, 010, 001, 050, 030, + 005, 005, 020, 005, 005, 005, 001, 050, 100, 050, + 050, 002, 002, 005, 005, 005, 005, 005, 005, 002, + 020, 020, 005, 010, 001, 001, 050, 030, 020, 020, + 010, 010, 001, 010, 001, 050, 030, 030, 030, 002, + 050, 020, 020, 020, 020, 010, 010, 050, 020, 005, + }; + + private static readonly uint[] MemoryFeelings = { 0x000000, 0x04CBFD, 0x004BFD, 0x04CBFD, 0x04CBFD, 0xFFFBFB, 0x84FFF9, 0x47FFFF, 0xBF7FFA, 0x7660B0, 0x80BDF9, 0x88FB7A, 0x083F79, 0x0001FE, 0xCFEFFF, 0x84EBAF, 0xB368B0, 0x091F7E, 0x0320A0, 0x080DDD, diff --git a/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs b/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs index 1a5b59b80..1707ea9d3 100644 --- a/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/AbilityVerifier.cs @@ -57,7 +57,6 @@ namespace PKHeX.Core var eabil = GetEncounterFixedAbilityNumber(EncounterMatch); if (eabil >= 0) { - if ((data.pkm.AbilityNumber == 4) != (eabil == 4)) return GetInvalid(LAbilityHiddenFail); if (eabil > 0) diff --git a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs index 97c3df824..9aca65090 100644 --- a/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MemoryVerifier.cs @@ -207,7 +207,7 @@ namespace PKHeX.Core switch (m) { - case 6 when !Memories.LocationsWithPKCenter[0].Contains(t): + case 6 when !Memories.LocationsWithPKCenter.Contains(t): return GetInvalid(string.Format(LMemoryArgBadPokecenter, tr)); // {0} saw {2} carrying {1} on its back. {4} that {3}. @@ -296,11 +296,11 @@ namespace PKHeX.Core return; 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(Memories.LocationsWithPKCenter[0], pkm.OT_TextVar); + int matchingOriginGame = Array.IndexOf(Memories.LocationsWithPKCenter, pkm.OT_TextVar); if (matchingOriginGame != -1) { - int gameID = Memories.LocationsWithPKCenter[1][matchingOriginGame]; - if ((pkm.XY && gameID != 0) || (pkm.AO && gameID != 1)) + var gameID = Memories.GetGameVersionForPokeCenterIndex(matchingOriginGame); + if (!gameID.Contains((GameVersion)pkm.Version)) data.AddLine(Severity.Invalid, string.Format(LMemoryArgBadLocation, L_XOT), CheckIdentifier.Memory); } data.AddLine(VerifyCommonMemory(pkm, 0));