From 05d31ef5306b8607a9cd05f4735a52d44e9e2c1d Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 17:57:17 -0700 Subject: [PATCH 01/24] Update relearn check logic No functional change, just a little optimization and grouping of suggestion logic (can be more easily commented out if making a slimmer checker) --- PKHeX/Legality/Checks.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index abaa71c07..b61670d90 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -2275,24 +2275,11 @@ private CheckResult[] verifyRelearnEggBase(int[] RelearnMoves, int skipOption, G var inherited = RelearnMoves.Where(m => m != 0 && (!baseMoves.Contains(m) || inheritMoves.Contains(m))).ToList(); int inheritCt = inherited.Count; - // Get Move Window - var window = new List(); - window.AddRange(baseMoves); // initial moves (levelup for current level of egg) - window.AddRange(inherited); // nonstandard (egg or higher levelup moves) - // Get required amount of base moves int unique = baseMoves.Concat(inherited).Distinct().Count(); int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt; if (RelearnMoves.Where(m => m != 0).Count() < Math.Min(4, baseMoves.Count)) reqBase = Math.Min(4, unique); - - // Store the base moves suggestion. - string em = string.Join(", ", baseMoves.Select(m => m >= movelist.Length ? V190 : movelist[m])); - - // Store the suggested relearn moves. - int[] moves = window.Skip(baseCt + inheritCt - 4).Take(4).ToArray(); - Array.Resize(ref moves, 4); - RelearnBase = moves; // Check if the required amount of Base Egg Moves are present. for (int i = 0; i < reqBase; i++) @@ -2306,6 +2293,7 @@ private CheckResult[] verifyRelearnEggBase(int[] RelearnMoves, int skipOption, G res[z] = new CheckResult(Severity.Invalid, V180, CheckIdentifier.RelearnMove); // provide the list of suggested base moves for the last required slot + string em = string.Join(", ", baseMoves.Select(m => m >= movelist.Length ? V190 : movelist[m])); res[reqBase - 1].Comment += string.Format(Environment.NewLine + V181, em); break; } @@ -2326,6 +2314,14 @@ private CheckResult[] verifyRelearnEggBase(int[] RelearnMoves, int skipOption, G res[i] = new CheckResult(Severity.Invalid, V182, CheckIdentifier.RelearnMove); } + // Store the suggested relearn moves with a moving window. + var window = new List(); + window.AddRange(baseMoves); // initial moves (levelup for current level of egg) + window.AddRange(inherited.Where(m => !baseMoves.Contains(m))); // nonstandard (egg or higher levelup moves) + int[] moves = window.Skip(baseCt + inheritCt - 4).Take(4).ToArray(); + Array.Resize(ref moves, 4); + RelearnBase = moves; + return res; } From 6b25367be71856e4c19e1a41b420d51da0f8251a Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 18:07:15 -0700 Subject: [PATCH 02/24] Change vivillon check invalid->fishy compact the table for easier browsing --- PKHeX/Legality/Checks.cs | 12 ++--- PKHeX/Legality/VivillonTables.cs | 77 +++++++++++--------------------- 2 files changed, 31 insertions(+), 58 deletions(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index b61670d90..66080584a 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -1849,10 +1849,8 @@ private void verifyForm() AddLine(Severity.Invalid, V311, CheckIdentifier.Form); return; } - else if (!Legal.CheckVivillonPattern(pkm.AltForm,pkm.Country,pkm.Region)) - { - AddLine(Severity.Invalid, V312, CheckIdentifier.Form); - } + if (!Legal.CheckVivillonPattern(pkm.AltForm, pkm.Country, pkm.Region)) + AddLine(Severity.Fishy, V312, CheckIdentifier.Form); break; case 666: // Vivillon if (pkm.AltForm > 17) // Fancy & Pokéball @@ -1864,10 +1862,8 @@ private void verifyForm() return; } - else if (!Legal.CheckVivillonPattern(pkm.AltForm, pkm.Country, pkm.Region)) - { - AddLine(Severity.Invalid, V312, CheckIdentifier.Form); - } + if (!Legal.CheckVivillonPattern(pkm.AltForm, pkm.Country, pkm.Region)) + AddLine(Severity.Fishy, V312, CheckIdentifier.Form); break; case 670: // Floette if (pkm.AltForm == 5) // Eternal Flower -- Never Released diff --git a/PKHeX/Legality/VivillonTables.cs b/PKHeX/Legality/VivillonTables.cs index 72737fa31..76530886c 100644 --- a/PKHeX/Legality/VivillonTables.cs +++ b/PKHeX/Legality/VivillonTables.cs @@ -18,42 +18,24 @@ private class FormSubregionTable private static readonly int[][] VivillonCountryTable = { //missing ID 051,068,102,127,160,186 - // 0-Icy Snow - new[] { 018, 076, 096, 100, 107 }, - // 1-Polar - new[] { 010, 018, 020, 049, 076, 096, 100, 107 }, - // 2-Tundra - new[] { 001, 081, 096, }, - // 3-Continental - new[] { 010, 067, 073, 074, 075, 077, 078, 084, 087, 094, 096, 097, 100, 107, 136}, - // 4-Garden - new[] { 065, 082, 095, 097, 101, 110, 125}, - // 5-Elegant - new[] { 001 }, - // 6-Meadow - new[] { 066, 077, 078, 083, 086, 088, 105, 108, 122}, - // 7-Modern - new[] { 018, 049}, - // 8-Marine - new[] { 020, 064, 066, 070, 071, 073, 077, 078, 079, 080, 083, 089, 090, 091, 098, 099, 103, 105, 123, 124, 126, 184, 185}, - // 9-Archipelago - new[] { 008, 009, 011, 012, 013, 017, 021, 023, 024, 028, 029, 032, 034, 035, 036, 037, 038, 043, 044, 045, 047, 048, 049, 052, 085, 104,}, - // 10-High-Plains - new[] { 018, 036, 049, 100, 113}, - // 11-Sandstorm - new[] { 072, 109, 118, 119, 120, 121, 168, 174}, - // 12-River - new[] { 065, 069, 085, 093, 104, 105, 114, 115, 116, 117}, - // 13-Monsoon - new[] { 001, 128, 144, 169}, - // 14-Savanna - new[] { 010, 015, 016, 041, 042, 050}, - // 15-Sun - new[] { 036, 014, 019, 026, 030, 033, 036, 039, 065, 092, 106, 111, 112}, - // 16-Ocean - new[] { 049, 077}, - // 17-Jungle - new[] { 016, 021, 022, 025, 027, 031, 040, 046, 052, 169, 153, 156}, + /* 0 Icy Snow */ new[] { 018, 076, 096, 100, 107 }, + /* 1 Polar */ new[] { 010, 018, 020, 049, 076, 096, 100, 107 }, + /* 2 Tundra */ new[] { 001, 081, 096, }, + /* 3 Continental */ new[] { 010, 067, 073, 074, 075, 077, 078, 084, 087, 094, 096, 097, 100, 107, 136}, + /* 4 Garden */ new[] { 065, 082, 095, 097, 101, 110, 125}, + /* 5 Elegant */ new[] { 001 }, + /* 6 Meadow */ new[] { 066, 077, 078, 083, 086, 088, 105, 108, 122}, + /* 7 Modern */ new[] { 018, 049}, + /* 8 Marine */ new[] { 020, 064, 066, 070, 071, 073, 077, 078, 079, 080, 083, 089, 090, 091, 098, 099, 103, 105, 123, 124, 126, 184, 185}, + /* 9 Archipelago */ new[] { 008, 009, 011, 012, 013, 017, 021, 023, 024, 028, 029, 032, 034, 035, 036, 037, 038, 043, 044, 045, 047, 048, 049, 052, 085, 104,}, + /*10 High Plains */ new[] { 018, 036, 049, 100, 113}, + /*11 Sandstorm */ new[] { 072, 109, 118, 119, 120, 121, 168, 174}, + /*12 River */ new[] { 065, 069, 085, 093, 104, 105, 114, 115, 116, 117}, + /*13 Monsoon */ new[] { 001, 128, 144, 169}, + /*14-Savanna */ new[] { 010, 015, 016, 041, 042, 050}, + /*15 Sun */ new[] { 036, 014, 019, 026, 030, 033, 036, 039, 065, 092, 106, 111, 112}, + /*16 Ocean */ new[] { 049, 077}, + /*17 Jungle */ new[] { 016, 021, 022, 025, 027, 031, 040, 046, 052, 169, 153, 156}, }; private static readonly CountryTable[] RegionFormTable = { @@ -262,21 +244,16 @@ private class FormSubregionTable public static bool CheckVivillonPattern(int form, int pkmcountry, int pkmregion) { - if (VivillonCountryTable[form].Contains(pkmcountry)) - { - if (RegionFormTable.Any(ct => ct.countryID == pkmcountry)) - { - CountryTable ct = RegionFormTable.Where(t => t.countryID == pkmcountry).ToArray()[0]; - if (ct.mainform == form) - return !(ct.otherforms.SelectMany(e => e.region).Contains(pkmregion)); //true if Mainform not in other specific region - else - return ct.otherforms.Any(e => e.form == form && e.region.Contains(pkmregion)); - } - else - return true; // No subregion - } - else + if (!VivillonCountryTable[form].Contains(pkmcountry)) return false; // Country mismatch + if (RegionFormTable.All(c => c.countryID != pkmcountry)) + return true; // No subregion table + + CountryTable ct = RegionFormTable.Where(t => t.countryID == pkmcountry).ToArray()[0]; + if (ct.mainform == form) + return !ct.otherforms.SelectMany(e => e.region).Contains(pkmregion); //true if Mainform not in other specific region + + return ct.otherforms.Any(e => e.form == form && e.region.Contains(pkmregion)); } } } \ No newline at end of file From 121a821180c2891fc60f1262cf4a01a1bf4b98d6 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 18:10:14 -0700 Subject: [PATCH 03/24] Fix clickOT order of operations Closes #976 subregion was set first, but changing the country caused it to reset the subregion to 0/existing value. thus, load country first then subregion (why not move 3DSReg first :+1: ) --- PKHeX.WinForms/MainWindow/Main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 7e31b3d38..1ad982606 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -1963,9 +1963,9 @@ private void clickOT(object sender, EventArgs e) CB_Language.SelectedValue = SAV.Language; if (SAV.HasGeolocation) { - CB_SubRegion.SelectedValue = SAV.SubRegion; - CB_Country.SelectedValue = SAV.Country; CB_3DSReg.SelectedValue = SAV.ConsoleRegion; + CB_Country.SelectedValue = SAV.Country; + CB_SubRegion.SelectedValue = SAV.SubRegion; } updateNickname(null, null); } From e779498aaed779d3a9c3de0b0663dec57436502b Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 18:17:22 -0700 Subject: [PATCH 04/24] Cap gen6 boxes unlocked at 30 Closes #975 Doesn't hide the 31st box from the editor, only prevents adding&selecting 31 from the dropdown for unlocked count. --- .../Subforms/Save Editors/Gen6/SAV_BoxLayout.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs index b713157b7..fa7978d0d 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs @@ -68,9 +68,13 @@ public SAV_BoxLayout(int box) if (SAV.BoxesUnlocked > 0) { CB_Unlocked.Items.Clear(); - for (int i = 0; i <= SAV.BoxCount; i++) + int max = SAV.BoxCount; + if (SAV.Generation == 6) + max -= 1; // cover legendary captured unlocks final box, not governed by BoxesUnlocked + + for (int i = 0; i <= max; i++) CB_Unlocked.Items.Add(i); - CB_Unlocked.SelectedIndex = Math.Min(SAV.BoxCount, SAV.BoxesUnlocked); + CB_Unlocked.SelectedIndex = Math.Min(max, SAV.BoxesUnlocked); } else { From 7c05bf2aa981f6849d371d6775a2e81704f67587 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 18:38:31 -0700 Subject: [PATCH 05/24] Simplify addExtraTableSlots remove unnecessary ToArray() as the output of the method is always ToArray'd --- PKHeX/Legality/Core.cs | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 0f4809a4a..1244ab88d 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -159,14 +159,16 @@ private static EncounterArea[] getEncounterTables(byte[] mini, string ident) { return EncounterArea.getArray(Data.unpackMini(mini, ident)); } - private static IEnumerable addExtraTableSlots(IEnumerable GameSlots, IEnumerable SpecialSlots) + private static EncounterArea[] addExtraTableSlots(EncounterArea[] GameSlots, EncounterArea[] SpecialSlots) { foreach (EncounterArea g in GameSlots) { - foreach (var slots in SpecialSlots.Where(l => l.Location == g.Location)) - g.Slots = g.Slots.Concat(slots.Slots).ToArray(); + var tables = SpecialSlots.Where(l => l.Location == g.Location).ToList(); + if (tables.Any()) + g.Slots = g.Slots.Concat(tables.SelectMany(t => t.Slots)).ToArray(); } - return GameSlots.Concat(SpecialSlots.Where(s => !GameSlots.Any(g => g.Location == s.Location))).ToArray(); + var notInserted = SpecialSlots.Where(s => GameSlots.All(g => g.Location != s.Location)); + return GameSlots.Concat(notInserted).ToArray(); } private static void ReduceAreasSize(ref EncounterArea[] Areas) { @@ -348,7 +350,7 @@ private static EncounterArea[] getTables2(GameVersion Version) var h_g = EncounterArea.getArray2_H(Resources.encounter_gold_h); var h_s = EncounterArea.getArray2_H(Resources.encounter_silver_h); - Slots = addExtraTableSlots(addExtraTableSlots(addExtraTableSlots(addExtraTableSlots(g, s), h_g), h_s),f).ToArray(); + Slots = addExtraTableSlots(addExtraTableSlots(addExtraTableSlots(addExtraTableSlots(g, s), h_g), h_s),f); } if (Version == GameVersion.C || Version == GameVersion.GSC) { @@ -358,7 +360,7 @@ private static EncounterArea[] getTables2(GameVersion Version) var h_c = EncounterArea.getArray2_H(Resources.encounter_crystal_h); var extra = addExtraTableSlots(addExtraTableSlots(c, h_c),f); - return Version == GameVersion.C ? extra.ToArray() : addExtraTableSlots(Slots, extra).ToArray(); + return Version == GameVersion.C ? extra : addExtraTableSlots(Slots, extra); } return Slots; @@ -406,11 +408,11 @@ private static EncounterArea[] getTables2(GameVersion Version) MarkG3Slots_FRLG(ref FR_Slots); MarkG3Slots_FRLG(ref LG_Slots); - SlotsR = addExtraTableSlots(R_Slots, SlotsRSEAlt).ToArray(); - SlotsS = addExtraTableSlots(S_Slots, SlotsRSEAlt).ToArray(); - SlotsE = addExtraTableSlots(E_Slots, SlotsRSEAlt).ToArray(); - SlotsFR = addExtraTableSlots(FR_Slots, SlotsFRLGAlt).ToArray(); - SlotsLG = addExtraTableSlots(LG_Slots, SlotsFRLGAlt).ToArray(); + SlotsR = addExtraTableSlots(R_Slots, SlotsRSEAlt); + SlotsS = addExtraTableSlots(S_Slots, SlotsRSEAlt); + SlotsE = addExtraTableSlots(E_Slots, SlotsRSEAlt); + SlotsFR = addExtraTableSlots(FR_Slots, SlotsFRLGAlt); + SlotsLG = addExtraTableSlots(LG_Slots, SlotsFRLGAlt); Evolves3 = new EvolutionTree(new[] { Resources.evos_g3 }, GameVersion.RS, PersonalTable.RS, MaxSpeciesID_3); @@ -465,11 +467,11 @@ private static EncounterArea[] getTables2(GameVersion Version) MarkG4Slots(ref HG_Headbutt_Slots); MarkG4Slots(ref SS_Headbutt_Slots); - SlotsD = addExtraTableSlots(addExtraTableSlots(D_Slots, D_HoneyTrees_Slots), SlotsDPPPtAlt).ToArray(); - SlotsP = addExtraTableSlots(addExtraTableSlots(P_Slots, P_HoneyTrees_Slots), SlotsDPPPtAlt).ToArray(); - SlotsPt = addExtraTableSlots(addExtraTableSlots(Pt_Slots, Pt_HoneyTrees_Slots), SlotsDPPPtAlt).ToArray(); - SlotsHG = addExtraTableSlots(addExtraTableSlots(HG_Slots, HG_Headbutt_Slots), SlotsHGSSAlt).ToArray(); - SlotsSS = addExtraTableSlots(addExtraTableSlots(SS_Slots, SS_Headbutt_Slots), SlotsHGSSAlt).ToArray(); + SlotsD = addExtraTableSlots(addExtraTableSlots(D_Slots, D_HoneyTrees_Slots), SlotsDPPPtAlt); + SlotsP = addExtraTableSlots(addExtraTableSlots(P_Slots, P_HoneyTrees_Slots), SlotsDPPPtAlt); + SlotsPt = addExtraTableSlots(addExtraTableSlots(Pt_Slots, Pt_HoneyTrees_Slots), SlotsDPPPtAlt); + SlotsHG = addExtraTableSlots(addExtraTableSlots(HG_Slots, HG_Headbutt_Slots), SlotsHGSSAlt); + SlotsSS = addExtraTableSlots(addExtraTableSlots(SS_Slots, SS_Headbutt_Slots), SlotsHGSSAlt); Evolves4 = new EvolutionTree(new[] { Resources.evos_g4 }, GameVersion.DP, PersonalTable.DP, MaxSpeciesID_4); @@ -491,8 +493,8 @@ private static EncounterArea[] getTables2(GameVersion Version) MarkG5Slots(ref WSlots); MarkBWSwarmSlots(ref SlotsB_Swarm); MarkBWSwarmSlots(ref SlotsW_Swarm); - SlotsB = addExtraTableSlots(BSlots, SlotsB_Swarm).ToArray(); - SlotsW = addExtraTableSlots(WSlots, SlotsW_Swarm).ToArray(); + SlotsB = addExtraTableSlots(BSlots, SlotsB_Swarm); + SlotsW = addExtraTableSlots(WSlots, SlotsW_Swarm); var B2Slots = getEncounterTables(GameVersion.B2); var W2Slots = getEncounterTables(GameVersion.W2); @@ -518,8 +520,8 @@ private static EncounterArea[] getTables2(GameVersion Version) var YSlots = getEncounterTables(GameVersion.Y); MarkG6XYSlots(ref XSlots); MarkG6XYSlots(ref YSlots); - SlotsX = addExtraTableSlots(XSlots, SlotsXYAlt).ToArray(); - SlotsY = addExtraTableSlots(YSlots, SlotsXYAlt).ToArray(); + SlotsX = addExtraTableSlots(XSlots, SlotsXYAlt); + SlotsY = addExtraTableSlots(YSlots, SlotsXYAlt); SlotsA = getEncounterTables(GameVersion.AS); SlotsO = getEncounterTables(GameVersion.OR); From cb24ba2857fbfa85669d6b22a28d0e8247a7c1cf Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 19:47:53 -0700 Subject: [PATCH 06/24] Add PID-nature/gender checks for 3-4(5) nature is no longer associated on gen5 split up medals check and some encounter checks --- PKHeX/Legality/Analysis.cs | 2 +- PKHeX/Legality/CheckStrings.cs | 4 + PKHeX/Legality/Checks.cs | 275 +++++++++++++++++++-------------- 3 files changed, 162 insertions(+), 119 deletions(-) diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index bd6cbeb0d..1d496f825 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -220,11 +220,11 @@ private void updateChecks() verifyHyperTraining(); verifyMedals(); verifyRegion(); + verifyVersionEvolution(); } if (pkm.GenNumber < 5) verifyEggMoves(); - verifyVersionEvolution(); // SecondaryChecked = true; } private string getLegalityReport() diff --git a/PKHeX/Legality/CheckStrings.cs b/PKHeX/Legality/CheckStrings.cs index 761b8ae31..b934f439f 100644 --- a/PKHeX/Legality/CheckStrings.cs +++ b/PKHeX/Legality/CheckStrings.cs @@ -95,6 +95,10 @@ public static string[] getLocalization(string[] existingLines = null) #region Legality Check Result Strings + public static string V250 {get; set;} = "Gender matches PID."; + public static string V251 {get; set;} = "PID-Gender mismatch."; + public static string V252 {get; set;} = "Nature matches PID."; + public static string V253 {get; set;} = "PID-Nature mismatch."; public static string V203 {get; set;} = "Genderless Pokémon should not have a gender."; public static string V201 {get; set;} = "Encryption Constant is not set."; public static string V204 {get; set;} = "Held item is unreleased."; diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 66080584a..b132dbdfd 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -42,7 +42,8 @@ internal enum CheckIdentifier Training, Ability, Evolution, - Special + Special, + Nature } public class CheckResult { @@ -65,10 +66,28 @@ public partial class LegalityAnalysis private void verifyGender() { if (pkm.PersonalInfo.Gender == 255 && pkm.Gender != 2) - { AddLine(Severity.Invalid, V203, CheckIdentifier.Gender); - // return; - } + + // Check for PID relationship to Gender & Nature if applicable + int gen = pkm.GenNumber; + + bool PIDGender = 3 <= gen && gen <= 5; + if (!PIDGender) + return; + + if (pkm.getGenderIsValid()) + AddLine(Severity.Valid, V250, CheckIdentifier.Gender); + else + AddLine(Severity.Invalid, V251, CheckIdentifier.Gender); + + bool PIDNature = gen != 5; + if (!PIDNature) + return; + + if (pkm.PID % 25 == pkm.Nature) + AddLine(Severity.Valid, V252, CheckIdentifier.Nature); + else + AddLine(Severity.Invalid, V253, CheckIdentifier.Nature); } private void verifyItem() { @@ -145,6 +164,7 @@ private void verifyECPID() : V216, CheckIdentifier.ECPID); } } + private void verifyNickname() { // If the Pokémon is not nicknamed, it should match one of the language strings. @@ -185,72 +205,13 @@ private void verifyNickname() if (EncounterType == typeof(EncounterTrade)) { - string[] validOT = new string[0]; - int index = -1; - if (pkm.XY) - { - validOT = Legal.TradeXY[pkm.Language]; - index = Array.IndexOf(Legal.TradeGift_XY, EncounterMatch); - } - else if (pkm.AO) - { - validOT = Legal.TradeAO[pkm.Language]; - index = Array.IndexOf(Legal.TradeGift_AO, EncounterMatch); - } - else if (pkm.SM) - { - // TODO - AddLine(Severity.Valid, V194, CheckIdentifier.Nickname); - return; - } - else if (pkm.Format <= 2 || pkm.VC) - { - var et = EncounterOriginal as EncounterTrade; - if (et?.TID == 0) // Gen1 Trade - { - if (!Legal.getEncounterTrade1Valid(pkm)) - AddLine(Severity.Invalid, V10, CheckIdentifier.Trainer); - } - else // Gen2 - { - return; // already checked all relevant properties when fetching with getValidEncounterTradeVC2 - } - return; - } - - if (validOT.Length == 0) - { - AddLine(Severity.Indeterminate, V7, CheckIdentifier.Trainer); - return; - } - if (index == -1 || validOT.Length < index*2) - { - AddLine(Severity.Indeterminate, V8, CheckIdentifier.Trainer); - return; - } - - string nick = validOT[index]; - string OT = validOT[validOT.Length/2 + index]; - - if (nick != pkm.Nickname) - AddLine(Severity.Fishy, V9, CheckIdentifier.Nickname); - else if (OT != pkm.OT_Name) - AddLine(Severity.Invalid, V10, CheckIdentifier.Trainer); - else - AddLine(Severity.Valid, V11, CheckIdentifier.Nickname); - + verifyNicknameTrade(); return; } if (pkm.IsEgg) { - if (!pkm.IsNicknamed && (pkm.Format != 7)) - AddLine(Severity.Invalid, V12, CheckIdentifier.Egg); - else if (PKX.SpeciesLang[pkm.Language][0] != pkm.Nickname) - AddLine(Severity.Invalid, V13, CheckIdentifier.Egg); - else - AddLine(Severity.Valid, V14, CheckIdentifier.Egg); - + verifyNicknameEgg(); return; } @@ -293,6 +254,74 @@ private void verifyNickname() AddLine(Severity.Valid, V18, CheckIdentifier.Nickname); } } + private void verifyNicknameEgg() + { + if (!pkm.IsNicknamed && (pkm.Format != 7)) + AddLine(Severity.Invalid, V12, CheckIdentifier.Egg); + else if (PKX.SpeciesLang[pkm.Language][0] != pkm.Nickname) + AddLine(Severity.Invalid, V13, CheckIdentifier.Egg); + else + AddLine(Severity.Valid, V14, CheckIdentifier.Egg); + } + private void verifyNicknameTrade() + { + string[] validOT = new string[0]; + int index = -1; + if (pkm.XY) + { + validOT = Legal.TradeXY[pkm.Language]; + index = Array.IndexOf(Legal.TradeGift_XY, EncounterMatch); + } + else if (pkm.AO) + { + validOT = Legal.TradeAO[pkm.Language]; + index = Array.IndexOf(Legal.TradeGift_AO, EncounterMatch); + } + else if (pkm.SM) + { + // TODO + AddLine(Severity.Valid, V194, CheckIdentifier.Nickname); + return; + } + else if (pkm.Format <= 2 || pkm.VC) + { + var et = EncounterOriginal as EncounterTrade; + if (et?.TID == 0) // Gen1 Trade + { + if (!Legal.getEncounterTrade1Valid(pkm)) + AddLine(Severity.Invalid, V10, CheckIdentifier.Trainer); + } + else // Gen2 + { + return; // already checked all relevant properties when fetching with getValidEncounterTradeVC2 + } + return; + } + + if (validOT.Length == 0) + { + AddLine(Severity.Indeterminate, V7, CheckIdentifier.Trainer); + return; + } + if (index == -1 || validOT.Length < index * 2) + { + AddLine(Severity.Indeterminate, V8, CheckIdentifier.Trainer); + return; + } + + string nick = validOT[index]; + string OT = validOT[validOT.Length / 2 + index]; + + if (nick != pkm.Nickname) + AddLine(Severity.Fishy, V9, CheckIdentifier.Nickname); + else if (OT != pkm.OT_Name) + AddLine(Severity.Invalid, V10, CheckIdentifier.Trainer); + else + AddLine(Severity.Valid, V11, CheckIdentifier.Nickname); + + return; + } + private void verifyEVs() { var evs = pkm.EVs; @@ -448,9 +477,9 @@ private CheckResult verifyEncounterLink() private CheckResult verifyEncounterEvent() { MysteryGift MatchedGift = EncounterMatch as MysteryGift; - if (MatchedGift != null) - return new CheckResult(Severity.Valid, string.Format(V21, MatchedGift.CardID.ToString("0000"), MatchedGift.CardTitle), CheckIdentifier.Encounter); - return null; + if (MatchedGift == null) + return null; + return new CheckResult(Severity.Valid, string.Format(V21, MatchedGift.CardID.ToString("0000"), MatchedGift.CardTitle), CheckIdentifier.Encounter); } private CheckResult verifyEncounterEgg() @@ -475,41 +504,44 @@ private CheckResult verifyEncounterEgg() } private CheckResult verifyEncounterEgg3() { - if (pkm.Format == 3) + return pkm.Format == 3 ? verifyEncounterEgg3Native() : verifyEncounterEgg3Transfer(); + } + private CheckResult verifyEncounterEgg3Native() + { + if (pkm.Met_Level != 0) + return new CheckResult(Severity.Invalid, string.Format(V52, 0), CheckIdentifier.Encounter); + if (pkm.IsEgg) { - if (pkm.Met_Level != 0) - return new CheckResult(Severity.Invalid, string.Format(V52, 0), CheckIdentifier.Encounter); - if (pkm.IsEgg) - { - var loc = pkm.FRLG ? 146 /* Four Island */ : 32; /* RSE: Route 117 */ - if (pkm.Met_Location != loc) - return new CheckResult(Severity.Invalid, V55, CheckIdentifier.Encounter); - } - else - { - var locs = pkm.FRLG ? Legal.ValidMet_FRLG : pkm.E ? Legal.ValidMet_E : Legal.ValidMet_RS; - if (locs.Contains(pkm.Met_Location)) - return new CheckResult(Severity.Valid, V53, CheckIdentifier.Encounter); - if (Legal.ValidMet_FRLG.Contains(pkm.Met_Location) || Legal.ValidMet_E.Contains(pkm.Met_Location) || Legal.ValidMet_RS.Contains(pkm.Met_Location)) - return new CheckResult(Severity.Valid, V56, CheckIdentifier.Encounter); - return new CheckResult(Severity.Invalid, V54, CheckIdentifier.Encounter); - } + var loc = pkm.FRLG ? 146 /* Four Island */ : 32; /* RSE: Route 117 */ + if (pkm.Met_Location != loc) + return new CheckResult(Severity.Invalid, V55, CheckIdentifier.Encounter); } else { - if (pkm.IsEgg) - return new CheckResult(Severity.Invalid, V57, CheckIdentifier.Encounter); - if (pkm.Met_Level < 5) - return new CheckResult(Severity.Invalid, V58, CheckIdentifier.Encounter); - if (pkm.Egg_Location != 0) - return new CheckResult(Severity.Invalid, V59, CheckIdentifier.Encounter); - if (pkm.Format == 4 && pkm.Met_Location != 0x37) // Pal Park - return new CheckResult(Severity.Invalid, V60, CheckIdentifier.Encounter); - if (pkm.Format != 4 && pkm.Met_Location != 30001) - return new CheckResult(Severity.Invalid, V61, CheckIdentifier.Encounter); + var locs = pkm.FRLG ? Legal.ValidMet_FRLG : pkm.E ? Legal.ValidMet_E : Legal.ValidMet_RS; + if (locs.Contains(pkm.Met_Location)) + return new CheckResult(Severity.Valid, V53, CheckIdentifier.Encounter); + if (Legal.ValidMet_FRLG.Contains(pkm.Met_Location) || Legal.ValidMet_E.Contains(pkm.Met_Location) || Legal.ValidMet_RS.Contains(pkm.Met_Location)) + return new CheckResult(Severity.Valid, V56, CheckIdentifier.Encounter); + return new CheckResult(Severity.Invalid, V54, CheckIdentifier.Encounter); } return new CheckResult(Severity.Valid, V53, CheckIdentifier.Encounter); } + private CheckResult verifyEncounterEgg3Transfer() + { + if (pkm.IsEgg) + return new CheckResult(Severity.Invalid, V57, CheckIdentifier.Encounter); + if (pkm.Met_Level < 5) + return new CheckResult(Severity.Invalid, V58, CheckIdentifier.Encounter); + if (pkm.Egg_Location != 0) + return new CheckResult(Severity.Invalid, V59, CheckIdentifier.Encounter); + if (pkm.Format == 4 && pkm.Met_Location != 0x37) // Pal Park + return new CheckResult(Severity.Invalid, V60, CheckIdentifier.Encounter); + if (pkm.Format != 4 && pkm.Met_Location != 30001) + return new CheckResult(Severity.Invalid, V61, CheckIdentifier.Encounter); + + return new CheckResult(Severity.Valid, V53, CheckIdentifier.Encounter); + } private CheckResult verifyEncounterEgg4() { if (pkm.Format == 4) @@ -588,7 +620,6 @@ private CheckResult verifyEncounterSafari() return new CheckResult(Severity.Valid, V66, CheckIdentifier.Encounter); } - private CheckResult verifyEncounterWild() { EncounterSlot[] enc = (EncounterSlot[])EncounterMatch; @@ -657,25 +688,27 @@ private CheckResult verifyEncounterG12() Console.WriteLine($"Gen1 encounter fallthrough: {pkm.FileName}"); return new CheckResult(Severity.Invalid, V80, CheckIdentifier.Encounter); } + private CheckResult verifyEncounterVC() + { + int baseSpecies = Legal.getBaseSpecies(pkm); + bool g1 = pkm.VC1 || pkm.Format == 1; + + if ((g1 && baseSpecies > Legal.MaxSpeciesID_1) || (baseSpecies > Legal.MaxSpeciesID_2)) + return new CheckResult(Severity.Invalid, V77, CheckIdentifier.Encounter); + + // Get EncounterMatch prior to parsing transporter legality + var result = verifyEncounterG12(); + EncounterOriginal = EncounterMatch; + + if (pkm.Format > 2) // transported to 7+ + AddLine(verifyVCEncounter(baseSpecies)); + + return result; + } private CheckResult verifyEncounter() { if (pkm.VC || pkm.Format < 3) - { - int baseSpecies = Legal.getBaseSpecies(pkm); - bool g1 = pkm.VC1 || pkm.Format == 1; - - if ((g1 && baseSpecies > Legal.MaxSpeciesID_1) || (baseSpecies > Legal.MaxSpeciesID_2)) - return new CheckResult(Severity.Invalid, V77, CheckIdentifier.Encounter); - - // Get EncounterMatch prior to parsing transporter legality - var result = verifyEncounterG12(); - EncounterOriginal = EncounterMatch; - - if (pkm.Format > 2) // transported to 7+ - AddLine(verifyVCEncounter(baseSpecies)); - - return result; - } + return verifyEncounterVC(); if (pkm.WasLink) return verifyEncounterLink(); @@ -781,12 +814,17 @@ private void verifyLevel() else AddLine(Severity.Valid, V88, CheckIdentifier.Level); } + private void verifyMedals() { if (pkm.Format < 6) return; - - // Training Medals + + verifyMedalsRegular(); + verifyMedalsEvent(); + } + private void verifyMedalsRegular() + { var TrainNames = ReflectUtil.getPropertiesStartWithPrefix(pkm.GetType(), "SuperTrain").ToArray(); var TrainCount = TrainNames.Count(MissionName => ReflectUtil.GetValue(pkm, MissionName) as bool? == true); if (pkm.IsEgg && TrainCount > 0) @@ -808,8 +846,9 @@ private void verifyMedals() { AddLine(Severity.Invalid, V93, CheckIdentifier.Training); } } } - - // Distribution Training Medals + } + private void verifyMedalsEvent() + { var DistNames = ReflectUtil.getPropertiesStartWithPrefix(pkm.GetType(), "DistSuperTrain"); var DistCount = DistNames.Count(MissionName => ReflectUtil.GetValue(pkm, MissionName) as bool? == true); if (pkm.IsEgg && DistCount > 0) @@ -819,6 +858,7 @@ private void verifyMedals() else if (DistCount > 0) { AddLine(Severity.Fishy, V94, CheckIdentifier.Training); } } + private void verifyRibbons() { if (!Encounter.Valid) @@ -1363,7 +1403,6 @@ private void verifyBallEggGen7() return; } - if (ball >= 27) { AddLine(Severity.Invalid, V126, CheckIdentifier.Ball); From a922bda342e766d11197550bca5f250b43ae689c Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 20:05:13 -0700 Subject: [PATCH 07/24] Fix relearnmove suggestion for eggs Closes #979 Forgot that the window deal was initially programmed to check the order of the base moves as well, but inheritance allowed them to be shuffled in. suggestion is always count=4 due to earlier padding, no need to Take(4). --mud; --- PKHeX/Legality/Analysis.cs | 8 ++------ PKHeX/Legality/Checks.cs | 9 +-------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index 1d496f825..773228603 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -293,14 +293,10 @@ public int[] getSuggestedRelearn() return RelearnBase; List window = new List(RelearnBase); - - for (int i = 0; i < 4; i++) - if (!vMoves[i].Valid || vMoves[i].Flag) - window.Add(pkm.Moves[i]); - + window.AddRange(pkm.Moves.Where((v, i) => !vMoves[i].Valid || vMoves[i].Flag)); if (window.Count < 4) window.AddRange(new int[4 - window.Count]); - return window.Skip(window.Count - 4).Take(4).ToArray(); + return window.Skip(window.Count - 4).ToArray(); } public int[] getSuggestedMoves(bool tm, bool tutor, bool reminder) { diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index b132dbdfd..87da39a66 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -2349,14 +2349,7 @@ private CheckResult[] verifyRelearnEggBase(int[] RelearnMoves, int skipOption, G res[i] = new CheckResult(Severity.Invalid, V182, CheckIdentifier.RelearnMove); } - // Store the suggested relearn moves with a moving window. - var window = new List(); - window.AddRange(baseMoves); // initial moves (levelup for current level of egg) - window.AddRange(inherited.Where(m => !baseMoves.Contains(m))); // nonstandard (egg or higher levelup moves) - int[] moves = window.Skip(baseCt + inheritCt - 4).Take(4).ToArray(); - Array.Resize(ref moves, 4); - RelearnBase = moves; - + RelearnBase = baseMoves.ToArray(); return res; } From f59d62161eb5bd2d8164235ba454f2f88121e016 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Thu, 23 Mar 2017 21:26:57 -0700 Subject: [PATCH 08/24] Add gen5 Dream World table - Add a lengthy dream world table with special moves and levels (wonder if there is already a binary database). I guess location can be a good flag from PDW.( directly writing the location into table would be better?) - Fixed a minor typo at vivillontables. - Working on adding PGL Gift from Dream World --- PKHeX/Legality/Core.cs | 15 +- PKHeX/Legality/Tables5.cs | 278 ++++++++++++++++++++++++++++++- PKHeX/Legality/VivillonTables.cs | 2 +- 3 files changed, 288 insertions(+), 7 deletions(-) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 1244ab88d..740176a23 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -251,6 +251,11 @@ private static void MarkG5HiddenGrottoSlots(ref EncounterArea[] Areas) foreach (EncounterSlot s in Areas[0].Slots) //Only 1 area s.Type = SlotType.HiddenGrotto; } + private static void MarkG5DreamWorld(ref EncounterStatic[] t) + { + foreach (EncounterStatic s in t) + s.Location = 75; //Location can use a flag from dream world + } private static void MarkG5Slots(ref EncounterArea[] Areas) { foreach (var area in Areas) @@ -482,10 +487,12 @@ private static EncounterArea[] getTables2(GameVersion Version) } // Gen 5 { - StaticB = getStaticEncounters(GameVersion.B); - StaticW = getStaticEncounters(GameVersion.W); - StaticB2 = getStaticEncounters(GameVersion.B2); - StaticW2 = getStaticEncounters(GameVersion.W2); + MarkG5DreamWorld(ref BW_DreamWorld); + MarkG5DreamWorld(ref B2W2_DreamWorld); + StaticB = getStaticEncounters(GameVersion.B).Concat(BW_DreamWorld).ToArray(); + StaticW = getStaticEncounters(GameVersion.W).Concat(BW_DreamWorld).ToArray(); + StaticB2 = getStaticEncounters(GameVersion.B2).Concat(B2W2_DreamWorld).ToArray(); + StaticW2 = getStaticEncounters(GameVersion.W2).Concat(B2W2_DreamWorld).ToArray(); var BSlots = getEncounterTables(GameVersion.B); var WSlots = getEncounterTables(GameVersion.W); diff --git a/PKHeX/Legality/Tables5.cs b/PKHeX/Legality/Tables5.cs index 565776236..6b849c2fe 100644 --- a/PKHeX/Legality/Tables5.cs +++ b/PKHeX/Legality/Tables5.cs @@ -124,6 +124,280 @@ public static partial class Legal new[] { 388, 380, 270, 495, 478, 472, 180, 278, 271, 446, 200, 283, 214, 285, 289, } // Nacrene City }; + #region DreamWorld Encounter + internal static readonly EncounterStatic[] DreamWorld_Common = + { + // Pleasant forest + new EncounterStatic { Species=019, Level = 10, Moves = new[]{98, 382, 231}, }, //Rattata + new EncounterStatic { Species=043, Level = 10, Moves = new[]{230, 298, 202}, }, //Oddish + new EncounterStatic { Species=069, Level = 10, Moves = new[]{22, 235, 402}, }, //Bellsprout + new EncounterStatic { Species=077, Level = 10, Moves = new[]{33, 37, 257}, }, //Ponyta + new EncounterStatic { Species=083, Level = 10, Moves = new[]{210, 355, 348}, }, //Farfetch'd + new EncounterStatic { Species=084, Level = 10, Moves = new[]{45, 175, 355}, }, //Doduo + new EncounterStatic { Species=102, Level = 10, Moves = new[]{140, 235, 202}, }, //Exeggcute + new EncounterStatic { Species=108, Level = 10, Moves = new[]{122, 214, 431}, }, //Lickitung + new EncounterStatic { Species=114, Level = 10, Moves = new[]{79, 73, 402}, }, //Tangela + new EncounterStatic { Species=115, Level = 10, Moves = new[]{252, 68, 409}, }, //Kangaskhan + new EncounterStatic { Species=161, Level = 10, Moves = new[]{10, 203, 343}, }, //Sentret + new EncounterStatic { Species=179, Level = 10, Moves = new[]{84, 115, 351}, }, //Mareep + new EncounterStatic { Species=191, Level = 10, Moves = new[]{72, 230, 414}, }, //Sunkern + new EncounterStatic { Species=234, Level = 10, Moves = new[]{33, 50, 285}, }, //Stantler + new EncounterStatic { Species=261, Level = 10, Moves = new[]{336, 305, 399}, }, //Poochyena + new EncounterStatic { Species=283, Level = 10, Moves = new[]{145, 56, 202}, }, //Surskit + new EncounterStatic { Species=399, Level = 10, Moves = new[]{33, 401, 290}, }, //Bidoof + new EncounterStatic { Species=403, Level = 10, Moves = new[]{268, 393, 400}, }, //Shinx + new EncounterStatic { Species=431, Level = 10, Moves = new[]{252, 372, 290}, }, //Glameow + new EncounterStatic { Species=054, Level = 10, Moves = new[]{346, 227, 362}, }, //Psyduck + new EncounterStatic { Species=058, Level = 10, Moves = new[]{44, 34, 203}, }, //Growlithe + new EncounterStatic { Species=123, Level = 10, Moves = new[]{98, 226, 366}, }, //Scyther + new EncounterStatic { Species=128, Level = 10, Moves = new[]{99, 231, 431}, }, //Tauros + new EncounterStatic { Species=183, Level = 10, Moves = new[]{111, 453, 8}, }, //Marill + new EncounterStatic { Species=185, Level = 10, Moves = new[]{175, 205, 272}, }, //Sudowoodo + new EncounterStatic { Species=203, Level = 10, Moves = new[]{93, 243, 285}, }, //Girafarig + new EncounterStatic { Species=241, Level = 10, Moves = new[]{111, 174, 231}, }, //Miltank + new EncounterStatic { Species=263, Level = 10, Moves = new[]{33, 271, 387}, }, //Zigzagoon + new EncounterStatic { Species=427, Level = 10, Moves = new[]{193, 252, 409}, }, //Buneary + new EncounterStatic { Species=037, Level = 10, Moves = new[]{46, 257, 399}, }, //Vulpix + new EncounterStatic { Species=060, Level = 10, Moves = new[]{95, 54, 214}, }, //Poliwag + new EncounterStatic { Species=177, Level = 10, Moves = new[]{101, 297, 202}, }, //Natu + new EncounterStatic { Species=239, Level = 10, Moves = new[]{84, 238, 393}, }, //Elekid + new EncounterStatic { Species=300, Level = 10, Moves = new[]{193, 321, 445}, }, //Skitty + // Windskept Sky + new EncounterStatic { Species=016, Level = 10, Moves = new[]{16, 211, 290}, }, //Pidgey + new EncounterStatic { Species=021, Level = 10, Moves = new[]{64, 185, 211}, }, //Spearow + new EncounterStatic { Species=041, Level = 10, Moves = new[]{48, 95, 162}, }, //Zubat + new EncounterStatic { Species=142, Level = 10, Moves = new[]{44, 372, 446}, }, //Aerodactyl + new EncounterStatic { Species=165, Level = 10, Moves = new[]{4, 450, 9}, }, //Ledyba + new EncounterStatic { Species=187, Level = 10, Moves = new[]{235, 227, 340}, }, //Hoppip + new EncounterStatic { Species=193, Level = 10, Moves = new[]{98, 364, 202}, }, //Yanma + new EncounterStatic { Species=198, Level = 10, Moves = new[]{64, 109, 355}, }, //Murkrow + new EncounterStatic { Species=207, Level = 10, Moves = new[]{28, 364, 366}, }, //Gligar + new EncounterStatic { Species=225, Level = 10, Moves = new[]{217, 420, 264}, }, //Delibird + new EncounterStatic { Species=276, Level = 10, Moves = new[]{64, 203, 413}, }, //Taillow + new EncounterStatic { Species=397, Level = 14, Moves = new[]{17, 297, 366}, }, //Staravia + new EncounterStatic { Species=227, Level = 10, Moves = new[]{64, 65, 355}, }, //Skarmory + new EncounterStatic { Species=357, Level = 10, Moves = new[]{16, 73, 318}, }, //Tropius + // Sprakling Sea + new EncounterStatic { Species=086, Level = 10, Moves = new[]{29, 333, 214}, }, //Seel + new EncounterStatic { Species=090, Level = 10, Moves = new[]{110, 112, 196}, }, //Shellder + new EncounterStatic { Species=116, Level = 10, Moves = new[]{145, 190, 362}, }, //Horsea + new EncounterStatic { Species=118, Level = 10, Moves = new[]{64, 60, 352}, }, //Goldeen + new EncounterStatic { Species=129, Level = 10, Moves = new[]{150, 175, 340}, }, //Magikarp + new EncounterStatic { Species=138, Level = 10, Moves = new[]{44, 330, 196}, }, //Omanyte + new EncounterStatic { Species=140, Level = 10, Moves = new[]{71, 175, 446}, }, //Kabuto + new EncounterStatic { Species=170, Level = 10, Moves = new[]{86, 133, 351}, }, //Chinchou + new EncounterStatic { Species=194, Level = 10, Moves = new[]{55, 34, 401}, }, //Wooper + new EncounterStatic { Species=211, Level = 10, Moves = new[]{40, 453, 290}, }, //Qwilfish + new EncounterStatic { Species=223, Level = 10, Moves = new[]{199, 350, 362}, }, //Remoraid + new EncounterStatic { Species=226, Level = 10, Moves = new[]{48, 243, 314}, }, //Mantine + new EncounterStatic { Species=320, Level = 10, Moves = new[]{55, 214, 340}, }, //Wailmer + new EncounterStatic { Species=339, Level = 10, Moves = new[]{189, 214, 209}, }, //Barboach + new EncounterStatic { Species=366, Level = 10, Moves = new[]{250, 445, 392}, }, //Clamperl + new EncounterStatic { Species=369, Level = 10, Moves = new[]{55, 214, 414}, }, //Relicanth + new EncounterStatic { Species=370, Level = 10, Moves = new[]{204, 300, 196}, }, //Luvdisc + new EncounterStatic { Species=418, Level = 10, Moves = new[]{346, 163, 352}, }, //Buizel + new EncounterStatic { Species=456, Level = 10, Moves = new[]{213, 186, 352}, }, //Finneon + new EncounterStatic { Species=072, Level = 10, Moves = new[]{48, 367, 202}, }, //Tentacool + new EncounterStatic { Species=318, Level = 10, Moves = new[]{44, 37, 399}, }, //Carvanha + new EncounterStatic { Species=341, Level = 10, Moves = new[]{106, 232, 283}, }, //Corphish + new EncounterStatic { Species=345, Level = 10, Moves = new[]{51, 243, 202}, }, //Lileep + new EncounterStatic { Species=347, Level = 10, Moves = new[]{10, 446, 440}, }, //Anorith + new EncounterStatic { Species=349, Level = 10, Moves = new[]{150, 445, 243}, }, //Feebas + new EncounterStatic { Species=131, Level = 10, Moves = new[]{109, 32, 196}, }, //Lapras + new EncounterStatic { Species=147, Level = 10, Moves = new[]{86, 352, 225}, }, //Dratini + // Spooky Mannor + new EncounterStatic { Species=092, Level = 10, Moves = new[]{95, 50, 482}, }, //Gastly + new EncounterStatic { Species=096, Level = 10, Moves = new[]{95, 427, 409}, }, //Drowzee + new EncounterStatic { Species=122, Level = 10, Moves = new[]{112, 298, 285}, }, //Mr. Mime + new EncounterStatic { Species=167, Level = 10, Moves = new[]{40, 527, 450}, }, //Spinarak + new EncounterStatic { Species=200, Level = 10, Moves = new[]{149, 194, 517}, }, //Misdreavus + new EncounterStatic { Species=228, Level = 10, Moves = new[]{336, 364, 399}, }, //Houndour + new EncounterStatic { Species=325, Level = 10, Moves = new[]{149, 285, 278}, }, //Spoink + new EncounterStatic { Species=353, Level = 10, Moves = new[]{101, 194, 220}, }, //Shuppet + new EncounterStatic { Species=355, Level = 10, Moves = new[]{50, 220, 271}, }, //Duskull + new EncounterStatic { Species=358, Level = 10, Moves = new[]{35, 95, 304}, }, //Chimecho + new EncounterStatic { Species=434, Level = 10, Moves = new[]{103, 492, 389}, }, //Stunky + new EncounterStatic { Species=209, Level = 10, Moves = new[]{204, 370, 38}, }, //Snubbull + new EncounterStatic { Species=235, Level = 10, Moves = new[]{166, 445, 214}, }, //Smeargle + new EncounterStatic { Species=313, Level = 10, Moves = new[]{148, 271, 366}, }, //Volbeat + new EncounterStatic { Species=314, Level = 10, Moves = new[]{204, 313, 366}, }, //Illumise + new EncounterStatic { Species=063, Level = 10, Moves = new[]{100, 285, 356}, }, //Abra + //Rugged Mountain + new EncounterStatic { Species=066, Level = 10, Moves = new[]{67, 418, 270}, }, //Machop + new EncounterStatic { Species=081, Level = 10, Moves = new[]{319, 278, 356}, }, //Magnemite + new EncounterStatic { Species=109, Level = 10, Moves = new[]{123, 399, 482}, }, //Koffing + new EncounterStatic { Species=218, Level = 10, Moves = new[]{52, 517, 257}, }, //Slugma + new EncounterStatic { Species=246, Level = 10, Moves = new[]{44, 399, 446}, }, //Larvitar + new EncounterStatic { Species=324, Level = 10, Moves = new[]{52, 90, 446}, }, //Torkoal + new EncounterStatic { Species=328, Level = 10, Moves = new[]{44, 324, 202}, }, //Trapinch + new EncounterStatic { Species=331, Level = 10, Moves = new[]{71, 298, 9}, }, //Cacnea + new EncounterStatic { Species=412, Level = 10, Moves = new[]{182, 450, 173}, }, //Burmy + new EncounterStatic { Species=449, Level = 10, Moves = new[]{44, 254, 276}, }, //Hippopotas + new EncounterStatic { Species=240, Level = 10, Moves = new[]{52, 9, 257}, }, //Magby + new EncounterStatic { Species=322, Level = 10, Moves = new[]{52, 34, 257}, }, //Numel + new EncounterStatic { Species=359, Level = 10, Moves = new[]{364, 224, 276}, }, //Absol + new EncounterStatic { Species=453, Level = 10, Moves = new[]{40, 409, 441}, }, //Croagunk + new EncounterStatic { Species=236, Level = 10, Moves = new[]{252, 364, 183}, }, //Tyrogue + new EncounterStatic { Species=371, Level = 10, Moves = new[]{44, 349, 200}, }, //Bagon + // Icy Cave + new EncounterStatic { Species=027, Level = 10, Moves = new[]{28, 68, 162}, }, //Sandshrew + new EncounterStatic { Species=074, Level = 10, Moves = new[]{111, 446, 431}, }, //Geodude + new EncounterStatic { Species=095, Level = 10, Moves = new[]{20, 446, 431}, }, //Onix + new EncounterStatic { Species=100, Level = 10, Moves = new[]{268, 324, 363}, }, //Voltorb + new EncounterStatic { Species=104, Level = 10, Moves = new[]{125, 195, 67}, }, //Cubone + new EncounterStatic { Species=293, Level = 10, Moves = new[]{253, 283, 428}, }, //Whismur + new EncounterStatic { Species=304, Level = 10, Moves = new[]{106, 283, 457}, }, //Aron + new EncounterStatic { Species=337, Level = 10, Moves = new[]{93, 414, 236}, }, //Lunatone + new EncounterStatic { Species=338, Level = 10, Moves = new[]{93, 428, 234}, }, //Solrock + new EncounterStatic { Species=343, Level = 10, Moves = new[]{229, 356, 428}, }, //Baltoy + new EncounterStatic { Species=459, Level = 10, Moves = new[]{75, 419, 202}, }, //Snover + new EncounterStatic { Species=050, Level = 10, Moves = new[]{28, 251, 446}, }, //Diglett + new EncounterStatic { Species=215, Level = 10, Moves = new[]{269, 8, 67}, }, //Sneasel + new EncounterStatic { Species=361, Level = 10, Moves = new[]{181, 311, 352}, }, //Snorunt + new EncounterStatic { Species=220, Level = 10, Moves = new[]{316, 246, 333}, }, //Swinub + new EncounterStatic { Species=443, Level = 10, Moves = new[]{82, 200, 203}, }, //Gible + // Dream Park + new EncounterStatic { Species=046, Level = 10, Moves = new[]{78, 440, 235}, }, //Paras + new EncounterStatic { Species=204, Level = 10, Moves = new[]{120, 390, 356}, }, //Pineco + new EncounterStatic { Species=265, Level = 10, Moves = new[]{40, 450, 173}, }, //Wurmple + new EncounterStatic { Species=273, Level = 10, Moves = new[]{74, 331, 492}, }, //Seedot + new EncounterStatic { Species=287, Level = 10, Moves = new[]{281, 400, 389}, }, //Slakoth + new EncounterStatic { Species=290, Level = 10, Moves = new[]{141, 203, 400}, }, //Nincada + new EncounterStatic { Species=311, Level = 10, Moves = new[]{86, 435, 324}, }, //Plusle + new EncounterStatic { Species=312, Level = 10, Moves = new[]{86, 435, 324}, }, //Minun + new EncounterStatic { Species=316, Level = 10, Moves = new[]{139, 151, 202}, }, //Gulpin + new EncounterStatic { Species=352, Level = 10, Moves = new[]{185, 285, 513}, }, //Kecleon + new EncounterStatic { Species=401, Level = 10, Moves = new[]{522, 283, 253}, }, //Kricketot + new EncounterStatic { Species=420, Level = 10, Moves = new[]{73, 505, 331}, }, //Cherubi + new EncounterStatic { Species=455, Level = 10, Moves = new[]{44, 476, 380}, }, //Carnivine + new EncounterStatic { Species=023, Level = 10, Moves = new[]{40, 251, 399}, }, //Ekans + new EncounterStatic { Species=175, Level = 10, Moves = new[]{118, 381, 253}, }, //Togepi + new EncounterStatic { Species=190, Level = 10, Moves = new[]{10, 252, 7}, }, //Aipom + new EncounterStatic { Species=285, Level = 10, Moves = new[]{78, 331, 264}, }, //Shroomish + new EncounterStatic { Species=315, Level = 10, Moves = new[]{74, 79, 129}, }, //Roselia + new EncounterStatic { Species=113, Level = 10, Moves = new[]{45, 68, 270}, }, //Chansey + new EncounterStatic { Species=127, Level = 10, Moves = new[]{11, 370, 382}, }, //Pinsir + new EncounterStatic { Species=133, Level = 10, Moves = new[]{28, 204, 129}, }, //Eevee + new EncounterStatic { Species=143, Level = 10, Moves = new[]{133, 7, 278}, }, //Snorlax + new EncounterStatic { Species=214, Level = 10, Moves = new[]{30, 175, 264}, }, //Heracross + // Pokémon Café Forest + new EncounterStatic { Species=061, Level = 25, Moves = new[]{240, 114, 352}, }, //Poliwhirl + new EncounterStatic { Species=133, Level = 10, Moves = new[]{270, 204, 129}, }, //Eevee + new EncounterStatic { Species=235, Level = 10, Moves = new[]{166, 445, 214}, }, //Smeargle + new EncounterStatic { Species=412, Level = 10, Moves = new[]{182, 450, 173}, }, //Burmy + }; + + internal static readonly EncounterStatic[] BW_DreamWorld = DreamWorld_Common.Concat(new[] + { + new EncounterStatic { Species=029, Level = 10, Moves = new[]{10, 389, 162}, }, //Nidoran (F) + new EncounterStatic { Species=032, Level = 10, Moves = new[]{64, 68, 162}, }, //Nidoran (M) + new EncounterStatic { Species=174, Level = 10, Moves = new[]{47, 313, 270}, }, //Igglybuff + new EncounterStatic { Species=187, Level = 10, Moves = new[]{235, 270, 331}, }, //Hoppip + new EncounterStatic { Species=270, Level = 10, Moves = new[]{71, 73, 352}, }, //Lotad + new EncounterStatic { Species=276, Level = 10, Moves = new[]{64, 119, 366}, }, //Taillow + new EncounterStatic { Species=309, Level = 10, Moves = new[]{86, 423, 324}, }, //Electrike + new EncounterStatic { Species=351, Level = 10, Moves = new[]{52, 466, 352}, }, //Castform + new EncounterStatic { Species=417, Level = 10, Moves = new[]{98, 343, 351}, }, //Pachirisu + + new EncounterStatic { Species=012, Level = 10, Moves = new[]{93, 355, 314}, }, //Butterfree + new EncounterStatic { Species=163, Level = 10, Moves = new[]{193, 101, 278}, }, //Hoothoot + new EncounterStatic { Species=278, Level = 10, Moves = new[]{55, 239, 351}, }, //Wingull + new EncounterStatic { Species=333, Level = 10, Moves = new[]{64, 297, 355}, }, //Swablu + new EncounterStatic { Species=425, Level = 10, Moves = new[]{107, 95, 285}, }, //Drifloon + new EncounterStatic { Species=441, Level = 10, Moves = new[]{119, 417, 272}, }, //Chatot + + new EncounterStatic { Species=079, Level = 10, Moves = new[]{281, 335, 362}, }, //Slowpoke + new EncounterStatic { Species=098, Level = 10, Moves = new[]{11, 133, 290}, }, //Krabby + new EncounterStatic { Species=119, Level = 33, Moves = new[]{352, 214, 203}, }, //Seaking + new EncounterStatic { Species=120, Level = 10, Moves = new[]{55, 278, 196}, }, //Staryu + new EncounterStatic { Species=222, Level = 10, Moves = new[]{145, 109, 446}, }, //Corsola + new EncounterStatic { Species=422, Level = 10, Moves = new[]{189, 281, 290}, Form = 0 }, //Shellos + new EncounterStatic { Species=422, Level = 10, Moves = new[]{189, 281, 290}, Form = 1 }, + + new EncounterStatic { Species=202, Level = 15, Moves = new[]{243, 204, 227}, }, //Wobbuffet + new EncounterStatic { Species=238, Level = 10, Moves = new[]{186, 445, 285}, }, //Smoochum + new EncounterStatic { Species=303, Level = 10, Moves = new[]{313, 424, 8}, }, //Mawile + new EncounterStatic { Species=307, Level = 10, Moves = new[]{96, 409, 203}, }, //Meditite + new EncounterStatic { Species=436, Level = 10, Moves = new[]{95, 285, 356}, }, //Bronzor + new EncounterStatic { Species=052, Level = 10, Moves = new[]{10, 95, 290}, }, //Meowth + new EncounterStatic { Species=479, Level = 10, Moves = new[]{86, 351, 324}, }, //Rotom + new EncounterStatic { Species=280, Level = 10, Moves = new[]{93, 194, 270}, }, //Ralts + new EncounterStatic { Species=302, Level = 10, Moves = new[]{193, 389, 180}, }, //Sableye + new EncounterStatic { Species=442, Level = 10, Moves = new[]{180, 220, 196}, }, //Spiritomb + + new EncounterStatic { Species=056, Level = 10, Moves = new[]{67, 179, 9}, }, //Mankey + new EncounterStatic { Species=111, Level = 10, Moves = new[]{30, 68, 38}, }, //Rhyhorn + new EncounterStatic { Species=231, Level = 10, Moves = new[]{175, 484, 402}, }, //Phanpy + new EncounterStatic { Species=451, Level = 10, Moves = new[]{44, 97, 401}, }, //Skorupi + new EncounterStatic { Species=216, Level = 10, Moves = new[]{313, 242, 264}, }, //Teddiursa + new EncounterStatic { Species=296, Level = 10, Moves = new[]{292, 270, 8}, }, //Makuhita + new EncounterStatic { Species=327, Level = 10, Moves = new[]{383, 252, 276}, }, //Spinda + new EncounterStatic { Species=374, Level = 10, Moves = new[]{36, 428, 442}, }, //Beldum + new EncounterStatic { Species=447, Level = 10, Moves = new[]{203, 418, 264}, }, //Riolu + + new EncounterStatic { Species=173, Level = 10, Moves = new[]{227, 312, 214}, }, //Cleffa + new EncounterStatic { Species=213, Level = 10, Moves = new[]{227, 270, 504}, }, //Shuckle + new EncounterStatic { Species=299, Level = 10, Moves = new[]{33, 446, 246}, }, //Nosepass + new EncounterStatic { Species=363, Level = 10, Moves = new[]{181, 90, 401}, }, //Spheal + new EncounterStatic { Species=408, Level = 10, Moves = new[]{29, 442, 7}, }, //Cranidos + new EncounterStatic { Species=206, Level = 10, Moves = new[]{111, 277, 446}, }, //Dunsparce + new EncounterStatic { Species=410, Level = 10, Moves = new[]{182, 68, 90}, }, //Shieldon + + new EncounterStatic { Species=048, Level = 10, Moves = new[]{50, 226, 285}, }, //Venonat + new EncounterStatic { Species=088, Level = 10, Moves = new[]{139, 114, 425}, }, //Grimer + new EncounterStatic { Species=415, Level = 10, Moves = new[]{16, 366, 314}, }, //Combee + new EncounterStatic { Species=015, Level = 10, Moves = new[]{31, 314, 210}, }, //Beedrill + new EncounterStatic { Species=335, Level = 10, Moves = new[]{98, 458, 67}, }, //Zangoose + new EncounterStatic { Species=336, Level = 10, Moves = new[]{44, 34, 401}, }, //Seviper + }).ToArray(); + + internal static readonly EncounterStatic[] B2W2_DreamWorld = DreamWorld_Common.Concat(new[] + { + new EncounterStatic { Species=535, Level = 10, Moves = new[]{496, 414, 352}, }, //Tympole + new EncounterStatic { Species=546, Level = 10, Moves = new[]{73, 227, 388}, }, //Cottonee + new EncounterStatic { Species=548, Level = 10, Moves = new[]{79, 204, 230}, }, //Petilil + new EncounterStatic { Species=588, Level = 10, Moves = new[]{203, 224, 450}, }, //Karrablast + new EncounterStatic { Species=616, Level = 10, Moves = new[]{51, 226, 227}, }, //Shelmet + new EncounterStatic { Species=545, Level = 30, Moves = new[]{342, 390, 276}, }, //Scolipede + + new EncounterStatic { Species=519, Level = 10, Moves = new[]{16, 95, 234}, }, //Pidove + new EncounterStatic { Species=561, Level = 10, Moves = new[]{95, 500, 257}, }, //Sigilyph + new EncounterStatic { Species=580, Level = 10, Moves = new[]{432, 362, 382}, }, //Ducklett + new EncounterStatic { Species=587, Level = 10, Moves = new[]{98, 403, 204}, }, //Emolga + + new EncounterStatic { Species=550, Level = 10, Moves = new[]{29, 97, 428}, Form = 0 }, //Basculin + new EncounterStatic { Species=550, Level = 10, Moves = new[]{29, 97, 428}, Form = 1 }, + new EncounterStatic { Species=594, Level = 10, Moves = new[]{392, 243, 220}, }, //Alomomola + new EncounterStatic { Species=618, Level = 10, Moves = new[]{189, 174, 281}, }, //Stunfisk + new EncounterStatic { Species=564, Level = 10, Moves = new[]{205, 175, 334}, }, //Tirtouga + + new EncounterStatic { Species=605, Level = 10, Moves = new[]{377, 112, 417}, }, //Elgyem + new EncounterStatic { Species=624, Level = 10, Moves = new[]{210, 427, 389}, }, //Pawniard + new EncounterStatic { Species=596, Level = 36, Moves = new[]{486, 50, 228}, }, //Galvantula + new EncounterStatic { Species=578, Level = 32, Moves = new[]{105, 286, 271}, }, //Duosion + new EncounterStatic { Species=622, Level = 10, Moves = new[]{205, 7, 9}, }, //Golett + + new EncounterStatic { Species=631, Level = 10, Moves = new[]{510, 257, 202}, }, //Heatmor + new EncounterStatic { Species=632, Level = 10, Moves = new[]{210, 203, 422}, }, //Durant + new EncounterStatic { Species=556, Level = 10, Moves = new[]{42, 73, 191}, }, //Maractus + new EncounterStatic { Species=558, Level = 34, Moves = new[]{157, 68, 400}, }, //Crustle + new EncounterStatic { Species=553, Level = 40, Moves = new[]{242, 68, 212}, }, //Krookodile + + new EncounterStatic { Species=529, Level = 10, Moves = new[]{229, 319, 431}, }, //Drilbur + new EncounterStatic { Species=621, Level = 10, Moves = new[]{44, 424, 389}, }, //Druddigon + new EncounterStatic { Species=525, Level = 25, Moves = new[]{479, 174, 484}, }, //Boldore + new EncounterStatic { Species=583, Level = 35, Moves = new[]{429, 420, 286}, }, //Vanillish + new EncounterStatic { Species=600, Level = 38, Moves = new[]{451, 356, 393}, }, //Klang + new EncounterStatic { Species=610, Level = 10, Moves = new[]{82, 68, 400}, }, //Axew + + new EncounterStatic { Species=531, Level = 10, Moves = new[]{270, 227, 281}, }, //Audino + new EncounterStatic { Species=538, Level = 10, Moves = new[]{20, 8, 276}, }, //Throh + new EncounterStatic { Species=539, Level = 10, Moves = new[]{249, 9, 530}, }, //Sawk + new EncounterStatic { Species=559, Level = 10, Moves = new[]{67, 252, 409}, }, //Scraggy + new EncounterStatic { Species=533, Level = 25, Moves = new[]{67, 183, 409}, }, //Gurdurr + }).ToArray(); + #endregion + internal static readonly int[] Roaming_MetLocation_BW = { 25,26,27,28, // Route 12,13,14,15 Night latter half @@ -457,7 +731,7 @@ public static partial class Legal new EncounterSlot{Species = 196, LevelMin = 10, LevelMax = 60, }, new EncounterSlot{Species = 197, LevelMin = 10, LevelMax = 60, }, new EncounterSlot{Species = 470, LevelMin = 10, LevelMax = 60, }, - new EncounterSlot{Species = 471, LevelMin = 10, LevelMax = 60, }, + new EncounterSlot{Species = 471, LevelMin = 10, LevelMax = 60, }, }; private static readonly EncounterArea[] SlotsB2_HiddenGrotto = { @@ -492,7 +766,7 @@ public static partial class Legal 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, 095, 096, 097, 098, 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - + }; internal static readonly int[] ValidMet_B2W2 = { diff --git a/PKHeX/Legality/VivillonTables.cs b/PKHeX/Legality/VivillonTables.cs index 76530886c..99cfd4228 100644 --- a/PKHeX/Legality/VivillonTables.cs +++ b/PKHeX/Legality/VivillonTables.cs @@ -63,7 +63,7 @@ private class FormSubregionTable mainform = 01, // Polar otherforms = new[] { - new FormSubregionTable { form = 01, region = new[] {12,13,14} }, + new FormSubregionTable { form = 00, region = new[] {12,13,14} }, new FormSubregionTable { form = 07, region = new[] {05} }, new FormSubregionTable { form = 10, region = new[] {04} }, } From b6c4eab36bcea888fe2be059bbab2f01139dbe95 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 21:42:33 -0700 Subject: [PATCH 09/24] Misc legality fixes & improvements Recognize gen4/5 events check ability mismatch check nature mismatch --- PKHeX/Legality/Analysis.cs | 6 ++++-- PKHeX/Legality/Checks.cs | 14 ++++++++++++-- PKHeX/Legality/Core.cs | 6 +++--- PKHeX/PKM/PK4.cs | 1 + PKHeX/PKM/PK5.cs | 1 + PKHeX/PKM/PKM.cs | 7 ++++--- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index 773228603..2cf4ba21f 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -121,7 +121,8 @@ private void parsePK4(PKM pk) pkm = pk; if (!pkm.IsOriginValid) { AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; } - + + verifyPreRelearn(); updateEncounterChain(); updateMoveLegality(); updateEncounterInfo(); @@ -133,7 +134,8 @@ private void parsePK5(PKM pk) pkm = pk; if (!pkm.IsOriginValid) { AddLine(Severity.Invalid, V187, CheckIdentifier.None); return; } - + + verifyPreRelearn(); updateEncounterChain(); updateMoveLegality(); updateEncounterInfo(); diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 87da39a66..32a86c271 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -241,7 +241,7 @@ private void verifyNickname() { // Can't have another language name if it hasn't evolved or wasn't a language-traded egg. bool match = PKX.getSpeciesNameGeneration(pkm.Species, pkm.Language, pkm.Format) == nickname; - match |= (pkm.WasTradedEgg || Legal.getHasEvolved(pkm)) && PKX.getIsNicknamedAnyLanguage(pkm.Species, nickname, pkm.Format); + match |= (pkm.WasTradedEgg || Legal.getHasEvolved(pkm)) && !PKX.getIsNicknamedAnyLanguage(pkm.Species, nickname, pkm.Format); if (!match) { @@ -1107,7 +1107,7 @@ private void verifyAbility() if (3 <= pkm.Format && pkm.Format <= 5) // 3-5 { - if (pkm.Version != (int) GameVersion.CXD && abilities[0] != abilities[1] && pkm.PIDAbility != abilval) + if (pkm.Version != (int) GameVersion.CXD && abilities[0] != abilities[1] && pkm.AbilityNumber != 1 << abilval) { AddLine(Severity.Invalid, V113, CheckIdentifier.Ability); return; @@ -2149,6 +2149,16 @@ private static CheckResult[] parseMoves(int[] moves, int[] learn, int[] relearn, return res; } + private void verifyPreRelearn() + { + // For origins prior to relearn moves, need to try to match a mystery gift if applicable. + + if (pkm.WasEvent || pkm.WasEventEgg) + { + EventGiftMatch = new List(Legal.getValidGifts(pkm)); + EncounterMatch = EventGiftMatch.FirstOrDefault(); + } + } private CheckResult[] verifyRelearn() { RelearnBase = null; diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 1244ab88d..8c6bf56a9 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -1064,13 +1064,13 @@ private static IEnumerable getMatchingPGF(PKM pkm, IEnumerable 5 || Format > 5) return -1; - if (GenNumber == 5) - return (int)((PID >> 16) & 1); - return (int)(PID & 1); + + if (Version == (int) GameVersion.CXD) + return Array.IndexOf(PersonalInfo.Abilities, Ability); + return (int)((GenNumber == 5 ? PID >> 16 : PID) & 1); } } From cfa1b6d74444f7ac34f1267b2174839b3600f226 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Thu, 23 Mar 2017 22:31:49 -0700 Subject: [PATCH 10/24] Add gen5 pgl dream world gift - add ability to table --- PKHeX/Legality/Core.cs | 5 +++- PKHeX/Legality/Tables5.cs | 50 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 559b32356..a111486c0 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -254,7 +254,10 @@ private static void MarkG5HiddenGrottoSlots(ref EncounterArea[] Areas) private static void MarkG5DreamWorld(ref EncounterStatic[] t) { foreach (EncounterStatic s in t) - s.Location = 75; //Location can use a flag from dream world + { + s.Location = 75; //Entree Forest. Location can be a flag from dream world + s.Ability = 4; //What if 1=2=HA? + } } private static void MarkG5Slots(ref EncounterArea[] Areas) { diff --git a/PKHeX/Legality/Tables5.cs b/PKHeX/Legality/Tables5.cs index 6b849c2fe..5b9e101b0 100644 --- a/PKHeX/Legality/Tables5.cs +++ b/PKHeX/Legality/Tables5.cs @@ -285,6 +285,13 @@ public static partial class Legal new EncounterStatic { Species=133, Level = 10, Moves = new[]{270, 204, 129}, }, //Eevee new EncounterStatic { Species=235, Level = 10, Moves = new[]{166, 445, 214}, }, //Smeargle new EncounterStatic { Species=412, Level = 10, Moves = new[]{182, 450, 173}, }, //Burmy + //PGL + new EncounterStatic { Species=212, Level = 10, Moves = new[]{211}, Gender = 0, }, //Scizor + new EncounterStatic { Species=445, Level = 48, Gender = 0, }, //Garchomp + new EncounterStatic { Species=149, Level = 55, Moves = new[]{009}, Gender = 0, }, //Dragonite + new EncounterStatic { Species=248, Level = 55, Moves = new[]{069}, Gender = 0, }, //Tyranitar + new EncounterStatic { Species=149, Level = 55, Moves = new[]{245}, Gender = 0, }, //Dragonite + new EncounterStatic { Species=376, Level = 45, Moves = new[]{038}, Gender = 2, }, //Metagross }; internal static readonly EncounterStatic[] BW_DreamWorld = DreamWorld_Common.Concat(new[] @@ -348,7 +355,36 @@ public static partial class Legal new EncounterStatic { Species=415, Level = 10, Moves = new[]{16, 366, 314}, }, //Combee new EncounterStatic { Species=015, Level = 10, Moves = new[]{31, 314, 210}, }, //Beedrill new EncounterStatic { Species=335, Level = 10, Moves = new[]{98, 458, 67}, }, //Zangoose - new EncounterStatic { Species=336, Level = 10, Moves = new[]{44, 34, 401}, }, //Seviper + new EncounterStatic { Species=336, Level = 10, Moves = new[]{44, 34, 401}, }, //Seviper + //PGL + new EncounterStatic { Species=134, Level = 10, Gender = 0, }, //Vaporeon + new EncounterStatic { Species=135, Level = 10, Gender = 0, }, //Jolteon + new EncounterStatic { Species=136, Level = 10, Gender = 0, }, //Flareon + new EncounterStatic { Species=196, Level = 10, Gender = 0, }, //Espeon + new EncounterStatic { Species=197, Level = 10, Gender = 0, }, //Umbreon + new EncounterStatic { Species=470, Level = 10, Gender = 0, }, //Leafeon + new EncounterStatic { Species=471, Level = 10, Gender = 0, }, //Glaceon + new EncounterStatic { Species=001, Level = 10, Gender = 0, }, //Bulbasaur + new EncounterStatic { Species=004, Level = 10, Gender = 0, }, //Charmander + new EncounterStatic { Species=007, Level = 10, Gender = 0, }, //Squirtle + new EncounterStatic { Species=453, Level = 10, Gender = 0, }, //Croagunk + new EncounterStatic { Species=387, Level = 10, Gender = 0, }, //Turtwig + new EncounterStatic { Species=390, Level = 10, Gender = 0, }, //Chimchar + new EncounterStatic { Species=393, Level = 10, Gender = 0, }, //Piplup + new EncounterStatic { Species=493, Level = 100 }, //Arceus + new EncounterStatic { Species=252, Level = 10, Gender = 0, }, //Treecko + new EncounterStatic { Species=255, Level = 10, Gender = 0, }, //Torchic + new EncounterStatic { Species=258, Level = 10, Gender = 0, }, //Mudkip + new EncounterStatic { Species=468, Level = 10, Moves = new[]{217}, Gender = 0, }, //Togekiss + new EncounterStatic { Species=473, Level = 34, Gender = 0, }, //Mamoswine + new EncounterStatic { Species=137, Level = 10 }, //Porygon + new EncounterStatic { Species=384, Level = 50 }, //Rayquaza + new EncounterStatic { Species=354, Level = 37, Moves = new[]{538}, Gender = 1, }, //Banette + new EncounterStatic { Species=453, Level = 10, Moves = new[]{398}, Gender = 0, }, //Croagunk + new EncounterStatic { Species=334, Level = 35, Moves = new[]{206}, Gender = 0,}, //Altaria + new EncounterStatic { Species=242, Level = 10 }, //Blissey + new EncounterStatic { Species=448, Level = 10, Moves = new[]{418}, Gender = 0, }, //Lucario + new EncounterStatic { Species=189, Level = 27, Moves = new[]{206}, Gender = 0, }, //Jumpluff }).ToArray(); internal static readonly EncounterStatic[] B2W2_DreamWorld = DreamWorld_Common.Concat(new[] @@ -394,7 +430,17 @@ public static partial class Legal new EncounterStatic { Species=538, Level = 10, Moves = new[]{20, 8, 276}, }, //Throh new EncounterStatic { Species=539, Level = 10, Moves = new[]{249, 9, 530}, }, //Sawk new EncounterStatic { Species=559, Level = 10, Moves = new[]{67, 252, 409}, }, //Scraggy - new EncounterStatic { Species=533, Level = 25, Moves = new[]{67, 183, 409}, }, //Gurdurr + new EncounterStatic { Species=533, Level = 25, Moves = new[]{67, 183, 409}, }, //Gurdurr + //PGL + new EncounterStatic { Species=575, Level = 32, Moves = new[]{243}, Gender = 0, }, //Gothorita + new EncounterStatic { Species=025, Level = 10, Moves = new[]{029}, Gender = 0, }, //Pikachu + new EncounterStatic { Species=511, Level = 10, Moves = new[]{437}, Gender = 0, }, //Pansage + new EncounterStatic { Species=513, Level = 10, Moves = new[]{257}, Gender = 0, }, //Pansear + new EncounterStatic { Species=515, Level = 10, Moves = new[]{056}, Gender = 0, }, //Panpour + new EncounterStatic { Species=387, Level = 10, Moves = new[]{254}, Gender = 0, }, //Turtwig + new EncounterStatic { Species=390, Level = 10, Moves = new[]{252}, Gender = 0, }, //Chimchar + new EncounterStatic { Species=393, Level = 10, Moves = new[]{297}, Gender = 0, }, //Piplup + new EncounterStatic { Species=575, Level = 32, Moves = new[]{286}, Gender = 0, }, //Gothorita }).ToArray(); #endregion From d8dcb4725225dc183faff54fa6fdb0d37e4a86bf Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 23 Mar 2017 23:15:49 -0700 Subject: [PATCH 11/24] Add gen4 event recognition fixes ribbon fetch, unown form comparison, and improves exception handling (no more swallowing exceptions and yielding a vague message) properly generate manaphy egg on gen4 saves will have to iron out the legality checks for nicknames at a later point in time --- PKHeX/Legality/Analysis.cs | 10 +++++++++- PKHeX/Legality/Checks.cs | 11 +++++------ PKHeX/Legality/Core.cs | 23 ++++++++++++++++++++--- PKHeX/MysteryGifts/PGT.cs | 32 ++++++++++++++++++++++---------- PKHeX/PKM/PK4.cs | 2 +- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index 2cf4ba21f..02293ec4e 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -75,7 +75,15 @@ public LegalityAnalysis(PKM pk) else return; } - catch { Valid = false; } + catch (Exception e) + { + Console.WriteLine(e.Message); + Valid = false; + Parsed = true; + AddLine(Severity.Invalid, V190, CheckIdentifier.Misc); + AllSuggestedMoves = AllSuggestedRelearnMoves = AllSuggestedMovesAndRelearn = new int[0]; + return; + } AllSuggestedMoves = !pkm.IsOriginValid ? new int[4] : getSuggestedMoves(true, true, true); AllSuggestedRelearnMoves = !pkm.IsOriginValid ? new int[4] : Legal.getValidRelearn(pkm, -1).ToArray(); AllSuggestedMovesAndRelearn = AllSuggestedMoves.Concat(AllSuggestedRelearnMoves).ToArray(); diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 32a86c271..39d08d1b6 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -891,13 +891,13 @@ private void verifyRibbons() }; if (MatchedGift != null) // Wonder Card { - var mgRibbons = ReflectUtil.getPropertiesStartWithPrefix(MatchedGift.Content.GetType(), "Ribbon"); + var mgRibbons = MatchedGift.Format == 4 ? EventRib : ReflectUtil.getPropertiesStartWithPrefix(MatchedGift.Content.GetType(), "Ribbon"); var commonRibbons = mgRibbons.Intersect(RibbonData).ToArray(); foreach (string r in commonRibbons) { bool? pk = ReflectUtil.getBooleanState(pkm, r); - bool? mg = ReflectUtil.getBooleanState(MatchedGift, r); + bool? mg = ReflectUtil.getBooleanState(MatchedGift.Content, r); if (pk != mg) // Mismatch { if (pk ?? false) @@ -1798,13 +1798,12 @@ private void verifyForm() int species = pkm.Species; if (species == 201) // Unown { - if (pkm.GenNumber == 2 && pkm.AltForm < 26) // A-Z - valid = true; - else if (pkm.GenNumber >= 3 && pkm.AltForm >= 28) // A-Z?! + int maxCount = pkm.GenNumber == 2 ? 26 : 28; // A-Z : A-Z?! + if (pkm.AltForm < maxCount) valid = true; } if (species == 414 && pkm.AltForm < 3) // Wormadam base form kept - valid = true; + valid = true; if ((species == 664 || species == 665) && pkm.AltForm < 18) // Vivillon Pre-evolutions valid = true; diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 8c6bf56a9..1dc4383ba 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -1014,7 +1014,16 @@ private static IEnumerable getMatchingPCD(PKM pkm, IEnumerable().Where(wc => vs.Any(dl => dl.Species == wc.Species))) { @@ -1029,8 +1038,16 @@ private static IEnumerable getMatchingPCD(PKM pkm, IEnumerable !getCanFormChange(pkm, dl.Species))) continue; - if (wc.Met_Location != pkm.Met_Location) continue; - if (wc.Egg_Location != pkm.Egg_Location) continue; + + if (wc.IsEgg) + { + if (wc.Egg_Location + 3000 != pkm.Egg_Location) continue; + } + else + { + if (wc.Egg_Location + 3000 != pkm.Met_Location) continue; + } + if (wc.CurrentLevel != pkm.Met_Level) continue; if (wc.Ball != pkm.Ball) continue; if (wc.OT_Gender < 3 && wc.OT_Gender != pkm.OT_Gender) continue; diff --git a/PKHeX/MysteryGifts/PGT.cs b/PKHeX/MysteryGifts/PGT.cs index 99b783d60..1c9d90d91 100644 --- a/PKHeX/MysteryGifts/PGT.cs +++ b/PKHeX/MysteryGifts/PGT.cs @@ -72,7 +72,7 @@ public override string CardTitle } } - public override int Species { get { return Gift.Species; } set { Gift.Species = value; } } + public override int Species { get { return Gift.IsManaphyEgg ? 490 : Gift.Species; } set { Gift.Species = value; } } public override int[] Moves { get { return Gift.Moves; } set { Gift.Moves = value; } } public override int HeldItem { get { return Gift.HeldItem; } set { Gift.HeldItem = value; } } public override bool IsShiny => Gift.IsShiny; @@ -192,7 +192,7 @@ private byte[] Unknown public override bool IsItem { get { return PGTGiftType == GiftType.Item; } set { if (value) PGTGiftType = GiftType.Item; } } public override bool IsPokémon { get { return PGTGiftType == GiftType.Pokémon || PGTGiftType == GiftType.PokémonEgg || PGTGiftType == GiftType.ManaphyEgg; } set { } } - public override int Species { get { return PK.Species; } set { PK.Species = value; } } + public override int Species { get { return IsManaphyEgg ? 490 : PK.Species; } set { PK.Species = value; } } public override int[] Moves { get { return PK.Moves; } set { PK.Moves = value; } } public override int HeldItem { get { return PK.HeldItem; } set { PK.HeldItem = value; } } public override bool IsShiny => PK.IsShiny; @@ -209,6 +209,7 @@ public override PKM convertToPKM(SaveFile SAV) pk4.TID = SAV.TID; pk4.SID = SAV.SID; pk4.OT_Gender = SAV.Gender; + pk4.Language = SAV.Language; } if (IsManaphyEgg) { @@ -218,6 +219,7 @@ public override PKM convertToPKM(SaveFile SAV) pk4.Move1 = 294; pk4.Move2 = 145; pk4.Move3 = 346; + pk4.Ability = pk4.PersonalInfo.Abilities[0]; pk4.FatefulEncounter = true; pk4.Ball = 4; pk4.Version = 10; // Diamond @@ -228,7 +230,7 @@ public override PKM convertToPKM(SaveFile SAV) // Generate IV uint seed = Util.rnd32(); - if (pk4.PID == 1 || IsManaphyEgg) // Create Nonshiny + if (pk4.PID == 1) // Create Nonshiny { uint pid1 = PKX.LCRNG(ref seed) >> 16; uint pid2 = PKX.LCRNG(ref seed) >> 16; @@ -255,7 +257,7 @@ public override PKM convertToPKM(SaveFile SAV) } // Generate Met Info - if (!IsEgg) + if (!IsEgg && !IsManaphyEgg) { pk4.Met_Location = pk4.Egg_Location + 3000; pk4.Egg_Location = 0; @@ -264,15 +266,25 @@ public override PKM convertToPKM(SaveFile SAV) } else { - pk4.Egg_Location = pk4.Egg_Location + 3000; - pk4.MetDate = DateTime.Now; - pk4.IsEgg = false; - // Met Location is modified when transferred to pk5; don't worry about it. + if (SAV.Generation == 4) + { + pk4.IsEgg = true; + pk4.Met_Location = pk4.Egg_Location + 3000; + pk4.Egg_Location = 0; + pk4.IsNicknamed = true; + pk4.Nickname = PKX.getSpeciesName(0, pk4.Language).ToUpper(); + pk4.MetDate = DateTime.Now; + } + else + { + pk4.IsEgg = false; + // Met Location is modified when transferred to pk5; don't worry about it. + pk4.Egg_Location = pk4.Egg_Location + 3000; + pk4.EggMetDate = DateTime.Now; + } } if (pk4.Species == 201) // Never will be true; Unown was never distributed. pk4.AltForm = PKX.getUnownForm(pk4.PID); - if (IsEgg || IsManaphyEgg) - pk4.IsEgg = true; pk4.RefreshChecksum(); return pk4; diff --git a/PKHeX/PKM/PK4.cs b/PKHeX/PKM/PK4.cs index a89bfa843..7a7be8328 100644 --- a/PKHeX/PKM/PK4.cs +++ b/PKHeX/PKM/PK4.cs @@ -311,7 +311,7 @@ public override int Met_Location else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) { // Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place - BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x46); + BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46); BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x80); } else From ea7a9dcef058436a0fbc97a2e3f3e7e50a526759 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Fri, 24 Mar 2017 01:05:09 -0700 Subject: [PATCH 12/24] Fix gen3/4 encounterstatic table - add static encounters for gen4 (rotom/drifloon/electrode/spiky pichu) - fix Uxie/Azelf location (Lake -> Cavern) - fix ball for sinjoh ruins event (the player recieve the pkm without battle poke ball only) - fix ball for gen5 zorua (the player can choose ball) --- PKHeX/Legality/Tables4.cs | 18 +++++++++++++----- PKHeX/Legality/Tables5.cs | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/PKHeX/Legality/Tables4.cs b/PKHeX/Legality/Tables4.cs index 0474a7890..aae6f620d 100644 --- a/PKHeX/Legality/Tables4.cs +++ b/PKHeX/Legality/Tables4.cs @@ -243,12 +243,18 @@ public static partial class Legal new EncounterStatic { Gift = true, Species = 440, Level = 01, EggLocation = 2009, Version = GameVersion.DP,}, //Happiny Egg from Traveling Man new EncounterStatic { Gift = true, Species = 447, Level = 01, EggLocation = 2010,}, //Riolu Egg from Riley + //Stationary + new EncounterStatic { Species = 425, Level = 22, Location = 47, Version = GameVersion.DP, },// Drifloon @ Valley Windworks + new EncounterStatic { Species = 425, Level = 15, Location = 47, Version = GameVersion.Pt, },// Drifloon @ Valley Windworks + new EncounterStatic { Species = 479, Level = 15, Location = 70, Version = GameVersion.DP, },// Rotom @ Old Chateau + new EncounterStatic { Species = 479, Level = 20, Location = 70, Version = GameVersion.Pt, },// Rotom @ Old Chateau + //Stationary Lengerdary new EncounterStatic { Species = 377, Level = 30, Location = 125, Version = GameVersion.Pt,}, //Regirock @ Rock Peak Ruins new EncounterStatic { Species = 378, Level = 30, Location = 124, Version = GameVersion.Pt,}, //Regice @ Iceberg Ruins new EncounterStatic { Species = 379, Level = 30, Location = 123, Version = GameVersion.Pt,}, //Registeel @ Iron Ruins - new EncounterStatic { Species = 480, Level = 50, Location = 078,}, //Uxie @ Lake Acuity - new EncounterStatic { Species = 482, Level = 50, Location = 077,}, //Azelf @ Lake Valor + new EncounterStatic { Species = 480, Level = 50, Location = 089,}, //Uxie @ Acuity Cavern + new EncounterStatic { Species = 482, Level = 50, Location = 088,}, //Azelf @ Valor Cavern new EncounterStatic { Species = 483, Level = 47, Location = 051, Version = GameVersion.D,}, //Dialga @ Spear Pillar new EncounterStatic { Species = 483, Level = 70, Location = 051, Version = GameVersion.Pt,}, //Dialga @ Spear Pillar new EncounterStatic { Species = 484, Level = 47, Location = 051, Version = GameVersion.P,}, //Palkia @ Spear Pillar @@ -332,9 +338,11 @@ public static partial class Legal //Stationary new EncounterStatic { Species = 130, Level = 30, Location = 135, Shiny = true }, //Gyarados @ Lake of Rage new EncounterStatic { Species = 131, Level = 20, Location = 210, }, //Lapras @ Union Cave Friday Only + new EncounterStatic { Species = 101, Level = 23, Location = 213, }, //Electrode @ Team Rocket HQ new EncounterStatic { Species = 143, Level = 50, Location = 159, }, //Snorlax @ Route 11 new EncounterStatic { Species = 143, Level = 50, Location = 160, }, //Snorlax @ Route 12 new EncounterStatic { Species = 185, Level = 20, Location = 184, }, //Sudowoodo @ Route 36 + new EncounterStatic { Species = 172, Level = 30, Location = 214, Gender = 1, Form = 1, Moves = new[]{344,270,207,220} }, //Spiky-eared Pichu @ Ilex forest //Stationary Lengerdary new EncounterStatic { Species = 144, Level = 50, Location = 203, }, //Articuno @ Seafoam Islands @@ -352,9 +360,9 @@ public static partial class Legal new EncounterStatic { Species = 382, Level = 50, Location = 232, Version = GameVersion.HG, }, //Kyogre @ Embedded Tower new EncounterStatic { Species = 383, Level = 50, Location = 232, Version = GameVersion.SS, }, //Groudon @ Embedded Tower new EncounterStatic { Species = 384, Level = 50, Location = 232, }, //Rayquaza @ Embedded Tower - new EncounterStatic { Species = 483, Level = 01, Location = 231, }, //Dialga @ Sinjoh Ruins - new EncounterStatic { Species = 484, Level = 01, Location = 231, }, //Palkia @ Sinjoh Ruins - new EncounterStatic { Species = 487, Level = 01, Location = 231, Form = 1}, //Giratina @ Sinjoh Ruins + new EncounterStatic { Species = 483, Level = 01, Location = 231, Gift = true }, //Dialga @ Sinjoh Ruins + new EncounterStatic { Species = 484, Level = 01, Location = 231, Gift = true }, //Palkia @ Sinjoh Ruins + new EncounterStatic { Species = 487, Level = 01, Location = 231, Gift = true, Form = 1}, //Giratina @ Sinjoh Ruins }; internal static readonly EncounterStatic[] Encounter_HGSS = Encounter_HGSS_KantoRoam.SelectMany(e => e.Clone(Roaming_MetLocation_HGSS_Kanto)).Concat( diff --git a/PKHeX/Legality/Tables5.cs b/PKHeX/Legality/Tables5.cs index 5b9e101b0..4c554018c 100644 --- a/PKHeX/Legality/Tables5.cs +++ b/PKHeX/Legality/Tables5.cs @@ -504,7 +504,7 @@ public static partial class Legal //Event new EncounterStatic { Species = 494, Level = 15, Location = 62, Shiny = false}, // Victini @ Liberty Garden - new EncounterStatic { Species = 570, Level = 10, Location = 32, Gender = 0, Gift = true, }, // Zorua @ Castelia City + new EncounterStatic { Species = 570, Level = 10, Location = 32, Gender = 0, }, // Zorua @ Castelia City new EncounterStatic { Species = 571, Level = 25, Location = 72, Gender = 1, }, // Zoroark @ Lostlorn Forest }; From a176f387bcc5ab90b1c26ac45aa4c20171719c70 Mon Sep 17 00:00:00 2001 From: sora10pls Date: Fri, 24 Mar 2017 13:40:17 -0400 Subject: [PATCH 13/24] Fix invalid fishy check for Gen 4 Eggs (#982) * Fix invalid fishy check for Gen 4 Eggs Met Level should be 0, current Level should at least be 1; impossible to have a Lv. 0 Pokemon, therefore it is not fishy to have no EVs on a Lv. 1 Pokemon --- PKHeX/Legality/Checks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 39d08d1b6..0b01b7f14 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -328,7 +328,7 @@ private void verifyEVs() int sum = evs.Sum(); if (pkm.IsEgg && sum > 0) AddLine(Severity.Invalid, V22, CheckIdentifier.EVs); - else if (sum == 0 && pkm.Stat_Level - pkm.Met_Level > 0) + else if (sum == 0 && pkm.CurrentLevel - Math.Max(1, pkm.Met_Level) > 0) AddLine(Severity.Fishy, V23, CheckIdentifier.EVs); else if (sum == 508) AddLine(Severity.Fishy, V24, CheckIdentifier.EVs); From a80a2489a4d674371adc708f6a433c2348cc2120 Mon Sep 17 00:00:00 2001 From: Evan Dixon Date: Fri, 24 Mar 2017 12:59:45 -0500 Subject: [PATCH 14/24] Refactored implementation of #959 --- PKHeX.WinForms/MainWindow/Main.cs | 3 +- PKHeX/Game/GameInfo.cs | 7 -- PKHeX/Legality/Analysis.cs | 2 +- PKHeX/Legality/Checks.cs | 2 +- ...heckStrings.cs => LegalityCheckStrings.cs} | 51 +---------- PKHeX/PKHeX.Core.csproj | 6 +- PKHeX/Properties/Resources.Designer.cs | 74 ++++++++------- PKHeX/Properties/Resources.resx | 8 +- ...ity_en.txt => LegalityCheckStrings_en.txt} | 0 ...ity_zh.txt => LegalityCheckStrings_zh.txt} | 0 PKHeX/Util/DataUtil.cs | 91 ++++++++++++++++++- 11 files changed, 138 insertions(+), 106 deletions(-) rename PKHeX/Legality/{CheckStrings.cs => LegalityCheckStrings.cs} (92%) rename PKHeX/Resources/text/en/{legality_en.txt => LegalityCheckStrings_en.txt} (100%) rename PKHeX/Resources/text/zh/{legality_zh.txt => LegalityCheckStrings_zh.txt} (100%) diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 1ad982606..24ba6aed2 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -12,6 +12,7 @@ using PKHeX.Core; using PKHeX.Core.Properties; using System.Configuration; +using System.Threading.Tasks; namespace PKHeX.WinForms { @@ -1419,7 +1420,7 @@ private void InitializeStrings() // Update Legality Strings // Clipboard.SetText(string.Join(Environment.NewLine, CheckStrings.getLocalization())); - new Thread(() => { CheckStrings.setLocalization(GameInfo.getCheckStrings(l)); }).Start(); + Task.Run(() => Util.setLocalization(typeof(LegalityCheckStrings))); // Force an update to the met locations origintrack = GameVersion.Unknown; diff --git a/PKHeX/Game/GameInfo.cs b/PKHeX/Game/GameInfo.cs index 92162416e..8954de5f0 100644 --- a/PKHeX/Game/GameInfo.cs +++ b/PKHeX/Game/GameInfo.cs @@ -9,9 +9,7 @@ public static class GameInfo private static readonly string[] ptransp = { "ポケシフター", "Poké Transfer", "Poké Fret", "Pokétrasporto", "Poképorter", "Pokétransfer", "포케시프터", "宝可传送", "寶可傳送", "ポケシフター" }; public static readonly string[] lang_val = { "ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2", "pt" }; private const string DefaultLanguage = "en"; - private const string LegalityName = "legality_"; private static readonly GameStrings[] Languages = new GameStrings[lang_val.Length]; - private static readonly string[][] CheckStrings = new string[lang_val.Length][]; // Lazy fetch implementation private static int DefaultLanguageIndex => Array.IndexOf(lang_val, DefaultLanguage); @@ -25,11 +23,6 @@ public static GameStrings getStrings(string lang) int index = getLanguageIndex(lang); return Languages[index] ?? (Languages[index] = new GameStrings(lang_val[index])); } - public static IEnumerable getCheckStrings(string lang) - { - int index = getLanguageIndex(lang); - return CheckStrings[index] ?? (CheckStrings[index] = Util.getStringList(LegalityName + lang_val[index])); - } private static string getTransporterName(string lang) { int index = getLanguageIndex(lang); diff --git a/PKHeX/Legality/Analysis.cs b/PKHeX/Legality/Analysis.cs index 02293ec4e..1ea18e7fe 100644 --- a/PKHeX/Legality/Analysis.cs +++ b/PKHeX/Legality/Analysis.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using static PKHeX.Core.CheckStrings; +using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core { diff --git a/PKHeX/Legality/Checks.cs b/PKHeX/Legality/Checks.cs index 39d08d1b6..1f63c6c67 100644 --- a/PKHeX/Legality/Checks.cs +++ b/PKHeX/Legality/Checks.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using static PKHeX.Core.CheckStrings; +using static PKHeX.Core.LegalityCheckStrings; namespace PKHeX.Core { diff --git a/PKHeX/Legality/CheckStrings.cs b/PKHeX/Legality/LegalityCheckStrings.cs similarity index 92% rename from PKHeX/Legality/CheckStrings.cs rename to PKHeX/Legality/LegalityCheckStrings.cs index b934f439f..c91d46910 100644 --- a/PKHeX/Legality/CheckStrings.cs +++ b/PKHeX/Legality/LegalityCheckStrings.cs @@ -7,57 +7,8 @@ namespace PKHeX.Core { - public static class CheckStrings + public static class LegalityCheckStrings { - private const string splitter = " = "; - private static readonly Type t = typeof(CheckStrings); - private static string[] getProps(IEnumerable input) - { - return input.Select(l => l.Substring(0, l.IndexOf(splitter, StringComparison.Ordinal))).ToArray(); - } - private static IEnumerable DumpStrings() - { - var props = ReflectUtil.getPropertiesStartWithPrefix(t, "V"); - return props.Select(p => $"{p}{splitter}{ReflectUtil.GetValue(t, p).ToString()}"); - } - - public static void setLocalization(IEnumerable lines) - { - if (lines == null) - return; - foreach (var line in lines.Where(l => l != null)) - { - var index = line.IndexOf(splitter, StringComparison.Ordinal); - if (index < 0) - continue; - var prop = line.Substring(0, index); - var value = line.Substring(index + splitter.Length); - - try - { - ReflectUtil.SetValue(t, prop.ToUpper(), value); - } - catch - { - Console.WriteLine($"Property not present: {prop} || Value written: {value}"); - } - } - } - public static string[] getLocalization(string[] existingLines = null) - { - existingLines = existingLines ?? new string[0]; - var currentLines = DumpStrings().ToArray(); - var existing = getProps(existingLines); - var current = getProps(currentLines); - - var result = new string[currentLines.Length]; - for (int i = 0; i < current.Length; i++) - { - int index = Array.IndexOf(existing, current[i]); - result[i] = index < 0 ? currentLines[i] : existingLines[index]; - } - return result; - } #region General Strings diff --git a/PKHeX/PKHeX.Core.csproj b/PKHeX/PKHeX.Core.csproj index 855a7bc08..f39d07cb1 100644 --- a/PKHeX/PKHeX.Core.csproj +++ b/PKHeX/PKHeX.Core.csproj @@ -152,7 +152,7 @@ - + @@ -3521,8 +3521,8 @@ - - + +