From ed3699fbb45b71c723e443eb96b3df3f3cb42f0e Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 27 Oct 2018 16:06:06 -0700 Subject: [PATCH] Update Ho-Oh mattle check More languages than Italian have a rule-breaking name. Rework checks a bit Flag eggs more accurately Update force hatch to move Link Trade met location to Egg Location fix Ho-oh -> Ho-Oh text strings (correctness is key!) --- PKHeX.Core/Editing/CommonEdits.cs | 2 ++ PKHeX.Core/Legality/Core.cs | 12 +++++++++- .../Legality/Encounters/Data/Encounters6.cs | 2 +- .../Legality/Encounters/Data/EncountersWC3.cs | 6 ++--- .../Generator/MysteryGiftGenerator.cs | 11 +++++----- .../Legality/Verifiers/NicknameVerifier.cs | 2 +- .../Legality/Verifiers/TrainerNameVerifier.cs | 22 ++++++++++++++++--- PKHeX.Core/PKM/PKM.cs | 19 +++++++--------- .../Resources/text/script/flags_e_en.txt | 4 ++-- .../Resources/text/script/flags_frlg_en.txt | 6 ++--- PKHeX.Core/Saves/SAV3Colosseum.cs | 2 +- 11 files changed, 56 insertions(+), 32 deletions(-) diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs index 2da71f705..328029b8e 100644 --- a/PKHeX.Core/Editing/CommonEdits.cs +++ b/PKHeX.Core/Editing/CommonEdits.cs @@ -572,6 +572,8 @@ public static void ForceHatchPKM(this PKM pkm, bool reHatch = false) pkm.IsEgg = false; pkm.SetNickname(); pkm.CurrentFriendship = pkm.PersonalInfo.BaseFriendship; + if (pkm.IsTradedEgg) + pkm.Egg_Location = pkm.Met_Location; var loc = EncounterSuggestion.GetSuggestedEggMetLocation(pkm); if (loc >= 0) pkm.Met_Location = loc; diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index a03277270..7c9d19030 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -877,7 +877,17 @@ public static int GetGBStadiumOTID(bool jp, GameVersion s) return 2000; } - public static int GetNicknameOTMaxLength(int gen, LanguageID lang) + public static int GetMaxLengthOT(int gen, LanguageID lang) + { + switch (lang) + { + case LanguageID.Korean: + case LanguageID.Japanese: return gen >= 6 ? 6 : 5; + default: return gen >= 6 ? 12 : 7; + } + } + + public static int GetMaxLengthNickname(int gen, LanguageID lang) { switch (lang) { diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs index b584e60f0..e59d0d376 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs @@ -305,7 +305,7 @@ private static void MarkG6AOSlots(ref EncounterArea[] Areas) new EncounterStatic { Species = 486, Level = 50, Location = 306, IV3 = true }, // Regigigas new EncounterStatic { Species = 249, Level = 50, Location = 304, Version = GameVersion.AS, IV3 = true }, // Lugia - new EncounterStatic { Species = 250, Level = 50, Location = 304, Version = GameVersion.OR, IV3 = true }, // Ho-oh + new EncounterStatic { Species = 250, Level = 50, Location = 304, Version = GameVersion.OR, IV3 = true }, // Ho-Oh new EncounterStatic { Species = 483, Level = 50, Location = 348, Version = GameVersion.AS, IV3 = true }, // Dialga new EncounterStatic { Species = 484, Level = 50, Location = 348, Version = GameVersion.OR, IV3 = true }, // Palkia diff --git a/PKHeX.Core/Legality/Encounters/Data/EncountersWC3.cs b/PKHeX.Core/Legality/Encounters/Data/EncountersWC3.cs index 1a3259856..2a41788ff 100644 --- a/PKHeX.Core/Legality/Encounters/Data/EncountersWC3.cs +++ b/PKHeX.Core/Legality/Encounters/Data/EncountersWC3.cs @@ -22,14 +22,12 @@ internal static class EncountersWC3 new WC3 { Species = 025, Level = 10, TID = 31121, OT_Gender = 0, OT_Name = "COLOS", CardTitle = "Colosseum Pikachu", Method = PIDType.CXD, Shiny = Shiny.Never, Language = (int)LanguageID.English, NotDistributed = true }, }; - internal const string ColoHoOhItalian = "MONTE LOTT"; - private static IEnumerable GetIngameCXDData() { var langs = new[]{LanguageID.Japanese, LanguageID.English, LanguageID.French, LanguageID.Italian, LanguageID.German, LanguageID.Spanish}; var h = new[] {null, "ダニー", "HORDEL", "VOLKER", "ODINO", "HORAZ", null, "HORDEL"}; var d = new[] {null, "ギンザル", "DUKING", "DOKING", "RODRIGO", "GRAND", null, "GERMÁN"}; - var m = new[] {null, "バトルやま", "MATTLE", "MT BATA", ColoHoOhItalian, "DUELLBE", null, "ERNESTO"}; + var m = new[] {null, "バトルやま", "MATTLE", "MT BATAILL", "MONTE LOTT", "DUELLBERG", null, "ERNESTO"}; // truncated on ck3->pk3 transfer return langs.SelectMany(l => GetIngame((int)l)); IEnumerable GetIngame(int l) @@ -42,7 +40,7 @@ IEnumerable GetIngame(int l) new WC3 { Species = 213, Level = 20, Language = l, Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], Version = GameVersion.XD, CardTitle = $"Trade Surskit ({id})", Method = PIDType.CXD, Shiny = Shiny.Never, Moves = new[] { 092, 164, 188, 277 }, Fateful = true }, // Shuckle @ Pyrite Town new WC3 { Species = 246, Level = 20, Language = l, Location = 116, TID = 37149, SID = -1, OT_Gender = 0, OT_Name = d[l], Version = GameVersion.XD, CardTitle = $"Trade Wooper ({id})", Method = PIDType.CXD, Shiny = Shiny.Never, Moves = new[] { 201, 349, 044, 200 }, Fateful = true }, // Larvitar @ Pyrite Town new WC3 { Species = 311, Level = 13, Language = l, Location = 254, TID = 37149, SID = 0, OT_Gender = 0, OT_Name = d[l], Version = GameVersion.COLO, CardTitle = $"Special Gift ({id})", Method = PIDType.CXD, Shiny = Shiny.Never, Moves = new[] { 045, 086, 098, 270 } }, // Plusle @ Ingame Trade - new WC3 { Species = 250, Level = 70, Language = l, Location = 255, TID = 10048, SID = 0, OT_Gender = 0, OT_Name = m[l], Version = GameVersion.S, CardTitle = $"Mt. Battle Ho-oh ({id})", Method = PIDType.CXD, Shiny = Shiny.Never, Moves = new[] { 105, 126, 241, 129 } }, // Ho-oh @ Mt. Battle + new WC3 { Species = 250, Level = 70, Language = l, Location = 255, TID = 10048, SID = 0, OT_Gender = 0, OT_Name = m[l], Version = GameVersion.S, CardTitle = $"Mt. Battle Ho-Oh ({id})", Method = PIDType.CXD, Shiny = Shiny.Never, Moves = new[] { 105, 126, 241, 129 } }, // Ho-oh @ Mt. Battle }; } } diff --git a/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs index 979a226c1..d68cafef5 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/MysteryGiftGenerator.cs @@ -161,7 +161,7 @@ private static IEnumerable GetMatchingWC7(PKM pkm, IEnumerable DB) yield return z; } - private static bool GetIsValidOTItalianMattleHoOh(string wc, string ot, bool ck3) + private static bool GetIsValidOTMattleHoOh(string wc, string ot, bool ck3) { if (ck3 && ot.Length == 10) return wc == ot; @@ -180,14 +180,15 @@ private static bool GetIsMatchWC3(PKM pkm, WC3 wc) if (wc.SID != -1 && wc.SID != pkm.SID) return false; if (wc.TID != -1 && wc.TID != pkm.TID) return false; if (wc.OT_Gender < 3 && wc.OT_Gender != pkm.OT_Gender) return false; - if (wc.OT_Name != null) + var wcOT = wc.OT_Name; + if (wcOT != null) { - if (ReferenceEquals(EncountersWC3.ColoHoOhItalian, wc.OT_Name)) + if (wcOT.Length > 7) // Colosseum Mattle Ho-Oh { - if (!GetIsValidOTItalianMattleHoOh(wc.OT_Name, pkm.OT_Name, pkm is CK3)) + if (!GetIsValidOTMattleHoOh(wcOT, pkm.OT_Name, pkm is CK3)) return false; } - else if (wc.OT_Name != pkm.OT_Name) + else if (wcOT != pkm.OT_Name) { return false; } diff --git a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs index 972f6ad98..02d7b7a92 100644 --- a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs @@ -80,7 +80,7 @@ private bool VerifyUnNicknamedEncounter(LegalityAnalysis data, PKM pkm, string n data.AddLine(GetInvalid(LNickInvalidChar)); return true; } - if (nickname.Length > Legal.GetNicknameOTMaxLength(data.Info.Generation, (LanguageID)pkm.Language)) + if (nickname.Length > Legal.GetMaxLengthNickname(data.Info.Generation, (LanguageID)pkm.Language)) { data.AddLine(Get(LNickLengthLong, data.EncounterOriginal.EggEncounter ? Severity.Fishy : Severity.Invalid)); return true; diff --git a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs index 4e458152c..5a2e649dc 100644 --- a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs @@ -60,10 +60,10 @@ public override void Verify(LegalityAnalysis data) { VerifyOTG1(data); } - else if (ot.Length > Legal.GetNicknameOTMaxLength(data.Info.Generation, (LanguageID)pkm.Language)) + else if (ot.Length > Legal.GetMaxLengthOT(data.Info.Generation, (LanguageID)pkm.Language)) { - if (!pkm.IsEgg) // ignore eggs, on trade, OT is not updated if language is - data.AddLine(Get(LOTLong, data.EncounterOriginal.EggEncounter ? Severity.Fishy : Severity.Invalid)); + if (!IsEdgeCaseLength(pkm, data.EncounterOriginal, ot)) + data.AddLine(Get(LOTLong, Severity.Invalid)); } if (ParseSettings.CheckWordFilter) @@ -77,6 +77,22 @@ public override void Verify(LegalityAnalysis data) } } + public static bool IsEdgeCaseLength(PKM pkm, IEncounterable e, string ot) + { + if (e.EggEncounter) + { + bool eggEdge = pkm.IsEgg ? pkm.IsTradedEgg : pkm.WasTradedEgg; + if (!eggEdge) + return false; + var len = Legal.GetMaxLengthOT(pkm.GenNumber, LanguageID.English); // max case + return ot.Length <= len; + } + + if (e is MysteryGift mg && mg.OT_Name.Length == ot.Length) + return true; // Mattle Ho-Oh + return false; + } + public void VerifyOTG1(LegalityAnalysis data) { var pkm = data.pkm; diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 72f2b02ac..58e06a100 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -519,19 +519,16 @@ public virtual bool WasGiftEgg public virtual bool WasEvent => (Met_Location > 40000 && Met_Location < 50000) || FatefulEncounter; public virtual bool WasEventEgg => Gen4 ? WasEgg && Species == 490 : ((Egg_Location > 40000 && Egg_Location < 50000) || (FatefulEncounter && Egg_Location > 0)) && Met_Level == 1; - public bool WasTradedEgg + public bool WasTradedEgg => Egg_Location == GetTradedEggLocation(); + public bool IsTradedEgg => Met_Location == GetTradedEggLocation(); + + private int GetTradedEggLocation() { - get + switch (GenNumber) { - switch (GenNumber) - { - case 4: - return Egg_Location == 2002; - case 5: - return Egg_Location == 30003; - default: - return Egg_Location == 30002; - } + case 4: return 2002; + case 5: return 30003; + default: return 30002; } } diff --git a/PKHeX.Core/Resources/text/script/flags_e_en.txt b/PKHeX.Core/Resources/text/script/flags_e_en.txt index 02640d92e..62ee731f6 100644 --- a/PKHeX.Core/Resources/text/script/flags_e_en.txt +++ b/PKHeX.Core/Resources/text/script/flags_e_en.txt @@ -23,7 +23,7 @@ 0x1B0 Old Sea Map Used 0x091 Lugia Captured -0x092 Ho-oh Captured +0x092 Ho-Oh Captured 0x1AD Deoxys Captured 0x1BB Regirock Captured 0x1BC Regice Captured @@ -41,7 +41,7 @@ 0x30E Kyogre Overworld Hidden 0x30F Groundon Overworld Hidden 0x320 Lugia Overworld Hidden -0x321 Ho-oh Overworld Hidden +0x321 Ho-Oh Overworld Hidden 0x3A7 Regirock Overworld Hidden 0x3A8 Regice Overworld Hidden 0x3A9 Registeel Overworld Hidden diff --git a/PKHeX.Core/Resources/text/script/flags_frlg_en.txt b/PKHeX.Core/Resources/text/script/flags_frlg_en.txt index 5299c0ec4..1b435313c 100644 --- a/PKHeX.Core/Resources/text/script/flags_frlg_en.txt +++ b/PKHeX.Core/Resources/text/script/flags_frlg_en.txt @@ -19,16 +19,16 @@ 0x081 Mewtwo Captured 0x082 Articuno Captured 0x09B Lugia Overworld -0x09C Ho-oh Overworld +0x09C Ho-Oh Overworld 0x2E4 Deoxys Captured 0x2F2 Lugia Captured -0x2F3 Ho-oh Captured +0x2F3 Ho-Oh Captured 0x2BD Moltres Defeated 0x2BE Articuno Defeated 0x2BF Zapdos Defeated 0x2F5 Lugia Defeated -0x2F6 Ho-oh Defeated +0x2F6 Ho-Oh Defeated 0x2F7 Deoxys Defeated 0x09A Deoxys Triangle Hidden 0x085 VOLTORB Defeated 1 diff --git a/PKHeX.Core/Saves/SAV3Colosseum.cs b/PKHeX.Core/Saves/SAV3Colosseum.cs index ad5e1d647..dcfc28da0 100644 --- a/PKHeX.Core/Saves/SAV3Colosseum.cs +++ b/PKHeX.Core/Saves/SAV3Colosseum.cs @@ -158,7 +158,7 @@ public override SaveFile Clone() public override int MaxEV => 255; public override int Generation => 3; protected override int GiftCountMax => 1; - public override int OTLength => 10; // as evident by Mattle Ho-oh (Italian) + public override int OTLength => 10; // as evident by Mattle Ho-Oh public override int NickLength => 10; public override int MaxMoney => 999999;