diff --git a/PKHeX.Core/Legality/Verifiers/MovePPVerifier.cs b/PKHeX.Core/Legality/Verifiers/MovePPVerifier.cs index 2a3393558..697e967c6 100644 --- a/PKHeX.Core/Legality/Verifiers/MovePPVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/MovePPVerifier.cs @@ -166,11 +166,6 @@ private static MoveHealState HasLeftBoxAfterAcquisition(PKM pk, IEncounterTempla private static bool IsVirtualConsoleUntouched(PK7 pk, ReadOnlySpan moves, ReadOnlySpan pp) { - // Sanity check the language is a possible VC-transfer language. - var language = (LanguageID)pk.Language; - if (!VirtualConsolePP.IsSupportedLanguage(language)) - return false; - // Pre-check to ensure the moves are only available from the game they were transferred from. // Can't leave the box immediately after transfer (else PP would heal), but we don't prevent the Move Verifier from passing Gen3+ moves. // Maybe in a future update we can add more strict interlocks. @@ -185,7 +180,7 @@ private static bool IsVirtualConsoleUntouched(PK7 pk, ReadOnlySpan moves return false; // RSE+ moves } - return VirtualConsolePP.IsMatch(language, moves, pp); + return VirtualConsolePP.IsMatchAnyLanguage(pk.NicknameTrash, moves, pp, pk.Species); } } diff --git a/PKHeX.Core/Moves/VirtualConsolePP.cs b/PKHeX.Core/Moves/VirtualConsolePP.cs index c758851e2..a998eb3b0 100644 --- a/PKHeX.Core/Moves/VirtualConsolePP.cs +++ b/PKHeX.Core/Moves/VirtualConsolePP.cs @@ -4,7 +4,7 @@ namespace PKHeX.Core; /// -/// Transfers from Gen1/2=>Gen7 don't set PP correctly (ignoring PP Ups and bad range fetch). +/// Transfers from Gen1/2=>Gen7 don't set PP correctly (ignoring PP Ups and bad range fetch). Transporter app language determines which table (not ROM of source or destination). /// This class contains the expected PP values for each move in each language, as well as methods to check if a given set of moves and PP values match the expected values. /// public static class VirtualConsolePP @@ -25,10 +25,13 @@ public static class VirtualConsolePP /// /// Sanity check the languages possible. /// - /// Language ID to check. + /// Language ID of the Transporter application to check. /// True if the language is supported for VC PP table; false otherwise. public static bool IsSupportedLanguage(LanguageID language) => language is (>= Japanese and <= ChineseT) and not UNUSED_6; + /// + /// Gets the VC PP table for the specified Transporter application language. + /// public static ReadOnlySpan GetTable(LanguageID language) => language switch { English => TableENG, @@ -95,4 +98,30 @@ public static bool IsMatch(LanguageID language, ReadOnlySpan moves, Read } return true; } + + /// + /// Checks the moves against all supported Transfer application languages to see if any match their stored PP values. + /// + public static bool IsMatchAnyLanguage(ReadOnlySpan trash, ReadOnlySpan moves, ReadOnlySpan pp, ushort species) + { + for (var language = Japanese; language <= ChineseT; language++) + { + if (language == UNUSED_6) + continue; + if (!IsMatch(language, moves, pp)) + continue; + if (!IsTrashMatch(trash, species, language)) + continue; + return true; + } + return false; + } + + private static bool IsTrashMatch(ReadOnlySpan trash, ushort species, LanguageID language) + { + var expectName = SpeciesName.GetSpeciesName(species, (int)language); + var currentLength = TrashBytesUTF16.GetStringLength(trash) + 1; // terminator + var match = TrashBytesUTF16.IsUnderlayerPresent(expectName, trash, currentLength); + return !match.IsInvalid; + } } diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs index d25062098..d7ea566d8 100644 --- a/PKHeX.Core/PKM/PK7.cs +++ b/PKHeX.Core/PKM/PK7.cs @@ -550,11 +550,10 @@ internal void SetTransferPID(bool isShiny) } /// - /// Resets the PP of moves to match Bank's initial values. + /// Resets the PP of moves to match Transporter's initial values. /// - public void SetVirtualConsoleTransferPP() + public void SetVirtualConsoleTransferPP(LanguageID language) { - var language = (LanguageID)Language; if (!VirtualConsolePP.IsSupportedLanguage(language)) return; diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/0021 - Spearow - Hardy - 13.8.9.31.31.31 - アアアアア - 05397 - Poké - 4432DFD41B97 badPP diffLanguage.pk7 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/0021 - Spearow - Hardy - 13.8.9.31.31.31 - アアアアア - 05397 - Poké - 4432DFD41B97 badPP diffLanguage.pk7 new file mode 100644 index 000000000..5a42220b0 Binary files /dev/null and b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/0021 - Spearow - Hardy - 13.8.9.31.31.31 - アアアアア - 05397 - Poké - 4432DFD41B97 badPP diffLanguage.pk7 differ