From 5e32e64ac8fa7cfb5c588d5d1a49a49a15fc5457 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 29 Nov 2020 18:17:15 -0800 Subject: [PATCH] =?UTF-8?q?Handle=20MAN=C3=B4A=20and=20FALC=C3=A7N=20SPA->?= =?UTF-8?q?FRE=20Gen2=20Trades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Transporter remaps certain locale specific chars depending on the source ROM's version. Since VC can trade between languages, there are 2 Spanish in-game trades that have glyphs subject to remapping, if it's transferred from a French game. If the spanish trade is transferred from a french game, it must match the mutated string. ty @Lusamine & helpers :D --- .../EncounterTrade/EncounterTrade2.cs | 37 ++++++++++++++++-- .../Generator/EncounterGenerator12.cs | 7 +--- .../Legality/Verifiers/TrainerNameVerifier.cs | 4 +- .../100 - VOLTI - B086FE1296FC FALCçN.pk7 | Bin 0 -> 260 bytes .../213 - SHUCKI - 736B6898378B MANôA.pk7 | Bin 0 -> 260 bytes 5 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/100 - VOLTI - B086FE1296FC FALCçN.pk7 create mode 100644 Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/213 - SHUCKI - 736B6898378B MANôA.pk7 diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs index 5f06061fe..eddbb961c 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade2.cs @@ -1,4 +1,6 @@ -namespace PKHeX.Core +using static PKHeX.Core.Species; + +namespace PKHeX.Core { public sealed class EncounterTrade2 : EncounterTradeGB { @@ -52,15 +54,42 @@ private bool IsValidTradeOTName(PKM pkm) if (pkm.Korean) return GetOT((int)LanguageID.Korean) == OT; + var lang = GetInternationalLanguageID(OT); + if (pkm.Format < 7) + return lang != -1; + + switch (Species) + { + case (int)Voltorb when pkm.Language == (int)LanguageID.French: + if (lang == (int)LanguageID.Spanish) + return false; + if (lang != -1) + return true; + return OT == "FALCçN"; // FALCÁN + + case (int)Shuckle when pkm.Language == (int)LanguageID.French: + if (lang == (int)LanguageID.Spanish) + return false; + if (lang != -1) + return true; + return OT == "MANôA"; // MANÍA + + default: return lang != -1; + } + } + + private int GetInternationalLanguageID(string OT) + { const int start = (int)LanguageID.English; const int end = (int)LanguageID.Spanish; + var tr = TrainerNames; for (int i = start; i <= end; i++) { - if (TrainerNames[i] == OT) - return true; + if (tr[i] == OT) + return i; } - return false; + return -1; } } } diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs index 7d0ae4b41..a2d4a10b2 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterGenerator12.cs @@ -27,12 +27,7 @@ private static IEnumerable GenerateRawEncounters12(PKM pkm, Game var deferred = new List(); foreach (var t in EncounterTradeGenerator.GetValidEncounterTrades(pkm, chain, game)) { - // some OTs are longer than the keyboard entry; don't defer these - if (pkm.Format >= 7 && pkm.OT_Name.Length <= (pkm.Japanese || pkm.Korean ? 5 : 7)) - { - deferred.Add(t); - continue; - } + // Gen2 trades are strictly matched (OT/Nick), while Gen1 trades allow for deferral (shrug). if (t is EncounterTrade1 t1 && t1.IsMatchDeferred(pkm)) { deferred.Add(t); diff --git a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs index b5ece23ad..e97cb477d 100644 --- a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs @@ -128,7 +128,7 @@ private void VerifyG1OTWithinBounds(LegalityAnalysis data, string str) { if (StringConverter12.GetIsG1English(str)) { - if (str.Length > 7 && !(data.EncounterOriginal is EncounterTrade)) // OT already verified; GER shuckle has 8 chars + if (str.Length > 7 && !(data.EncounterOriginal is EncounterTradeGB)) // OT already verified; GER shuckle has 8 chars data.AddLine(GetInvalid(LOTLong)); } else if (StringConverter12.GetIsG1Japanese(str)) @@ -141,7 +141,7 @@ private void VerifyG1OTWithinBounds(LegalityAnalysis data, string str) if (str.Length > 5) data.AddLine(GetInvalid(LOTLong)); } - else + else if (!(data.EncounterOriginal is EncounterTrade2)) // OT already verified; SPA Shuckle/Voltorb transferred from French can yield 2 inaccessible chars { data.AddLine(GetInvalid(LG1CharOT)); } diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/100 - VOLTI - B086FE1296FC FALCçN.pk7 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/100 - VOLTI - B086FE1296FC FALCçN.pk7 new file mode 100644 index 0000000000000000000000000000000000000000..a98e4e7a60c33572b6c6e819c785f0b7beaf3658 GIT binary patch literal 260 zcmew}P3Rv3L)(TF1_lP!A_j(9Af3g+z_4Y8Z!QCnCIrG5{26>0LKr-O3X>R8k(4V! z*~&;_5N7?1FZ%-+ycs-z>LV~@85o&_kOkcs7+Kii0&WbBK>M5-o-_Et#UKnfIA4TY V7RYuiWnpE|G-PLFhD+dJ007~E69fPN literal 0 HcmV?d00001 diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/213 - SHUCKI - 736B6898378B MANôA.pk7 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 7 Transfer/213 - SHUCKI - 736B6898378B MANôA.pk7 new file mode 100644 index 0000000000000000000000000000000000000000..0facc6046f67ed88d1733d74179228e1089c1a79 GIT binary patch literal 260 zcmeA+pOL}9kX?M0fq{XIiGkrWI|D-<3j@QoPk--o0mTS`Uph|&wj7&nvf^H0qEF5qFUj|18KZY+r c5*@g~1w^=Ifo#W87JddzLv}`HxC9Oc07u&vZ~y=R literal 0 HcmV?d00001