From 2a4aa0b79dd5a49ca6d229723607d08bde3a7db6 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 1 Aug 2017 14:55:10 -0700 Subject: [PATCH] Refactoring fixes Fix misc refactoring errors Don't early abort gen4->5+ encounter generation (need to check ingame trades for abra/gengar). Can avoid by PID dictionary to check for trades first, but unimplemented. Closes #1377 , not fixing Pokewalker PID mismatch as algorithm needs to be ironed out separately. --- PKHeX.Core/Legality/Checks.cs | 6 +++++- PKHeX.Core/Legality/Encounters/Data/Encounters4.cs | 3 ++- PKHeX.Core/Legality/Encounters/EncounterGenerator.cs | 2 +- PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/Legality/Checks.cs b/PKHeX.Core/Legality/Checks.cs index 248c01e13..88a382bdf 100644 --- a/PKHeX.Core/Legality/Checks.cs +++ b/PKHeX.Core/Legality/Checks.cs @@ -1989,7 +1989,11 @@ private void VerifyForm() return; if (pkm.Format < 4) - return; + return; // no forms exist + + int count = pkm.PersonalInfo.FormeCount; + if (count == 1 && pkm.AltForm == 0) + return; // no forms to check if (pkm.AltForm > pkm.PersonalInfo.FormeCount) { diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs index 3386270ec..d3ace138c 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs @@ -1237,7 +1237,7 @@ private static void MarkHGSSEncounterTypeSlots(ref EncounterArea[] Areas) new EncounterSlot { Species = 406, LevelMin = 40, LevelMax = 40, Type = SlotType.Grass_Safari }, // Budew new EncounterSlot { Species = 443, LevelMin = 44, LevelMax = 44, Type = SlotType.Grass_Safari }, // Gible }; - private static EncounterSlot[] SAFARIZONE_WASTELAND = + private static readonly EncounterSlot[] SAFARIZONE_WASTELAND = { new EncounterSlot { Species = 022, LevelMin = 15, LevelMax = 17, Type = SlotType.Grass_Safari }, // Fearow new EncounterSlot { Species = 055, LevelMin = 45, LevelMax = 45, Type = SlotType.Grass_Safari }, // Golduck @@ -1339,6 +1339,7 @@ private static void MarkHGSSEncounterTypeSlots(ref EncounterArea[] Areas) }; private static readonly EncounterArea[] SlotsHGSSAlt = { + SlotsHGSS_BCC, new EncounterArea { Location = 209, // Ruins of Alph Slots = new int[25].Select((s, i) => new EncounterSlot { Species = 201, LevelMin = 5, LevelMax = 5, Type = SlotType.Grass, Form = i+1 }).ToArray() // B->?, Unown A is loaded from encounters raw file diff --git a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs index 9dc6e9ea3..f879b675d 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterGenerator.cs @@ -243,7 +243,7 @@ private static IEnumerable GenerateRawEncounters4(PKM pkm) // if (ctr != 0) yield break; foreach (var z in GetValidWildEncounters(pkm)) { yield return z; ++ctr; } - if (ctr != 0) yield break; + if (ctr != 0 && pkm.HasOriginalMetLocation) yield break; // EncounterTrade abra/gengar will match wild slots foreach (var z in GetValidEncounterTrades(pkm)) { yield return z; ++ctr; } if (ctr != 0) yield break; diff --git a/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs b/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs index ea6637021..b3ef0e2ff 100644 --- a/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs +++ b/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs @@ -90,7 +90,7 @@ private static CheckResult[] VerifyRelearnEggBase(PKM pkm, LegalInfo info, Encou // Obtain level1 moves var baseMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Game, 1); - int baseCt = Math.Max(4, baseMoves.Length); + int baseCt = Math.Min(4, baseMoves.Length); // Obtain Inherited moves var inheritMoves = Legal.GetValidRelearn(pkm, e.Species, inheritLvlMoves).ToList();