From 630d84c8b6c15ecbf1b7c8b64bcfea0ec5892a22 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 2 Feb 2021 15:39:56 -0800 Subject: [PATCH] Check encounter moves for gen1/2 (no relearner) --- .../Moveset/EncounterMovesetGenerator.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs index c80084b51..f61ae1d91 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Moveset/EncounterMovesetGenerator.cs @@ -207,7 +207,7 @@ private static IEnumerable GetPossibleOfType(PKM pk, IReadOnlyLi EncounterOrder.Egg => GetEggs(pk, needs, chain, version), EncounterOrder.Mystery => GetGifts(pk, needs, chain), EncounterOrder.Static => GetStatic(pk, needs, chain), - EncounterOrder.Trade => GetTrades(pk, needs, chain), + EncounterOrder.Trade => GetTrades(pk, needs, chain, version), EncounterOrder.Slot => GetSlots(pk, needs, chain, version), _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) }; @@ -240,8 +240,11 @@ private static IEnumerable GetEggs(PKM pk, IReadOnlyCollection em = MoveEgg.GetEggMoves(pk.PersonalInfo, egg.Species, egg.Form, egg.Version, egg.Generation); - if (Legal.LightBall.Contains(egg.Species) && needs.Contains((int)Move.VoltTackle)) + if (egg.Generation <= 2) + em = em.Concat(MoveLevelUp.GetEncounterMoves(egg.Species, 0, egg.Level, egg.Version)); + else if (Legal.LightBall.Contains(egg.Species) && needs.Contains((int)Move.VoltTackle)) em = em.Concat(new[] { (int)Move.VoltTackle }); + if (!needs.Except(em).Any()) yield return egg; } @@ -299,6 +302,9 @@ private static IEnumerable GetStatic(PKM pk, IReadOnlyCollectio IEnumerable em = enc.Moves; if (enc is IRelearn r) em = em.Concat(r.Relearn); + if (enc.Generation <= 2) + em = em.Concat(MoveLevelUp.GetEncounterMoves(enc.Species, 0, enc.Level, enc.Version)); + if (!needs.Except(em).Any()) yield return enc; } @@ -327,10 +333,11 @@ private static IEnumerable GetStatic(PKM pk, IReadOnlyCollectio /// Rough Pokémon data which contains the requested species, gender, and form. /// Moves which cannot be taught by the player. /// Origin possible evolution chain + /// Specific version to iterate for. /// A consumable list of possible encounters. - private static IEnumerable GetTrades(PKM pk, IReadOnlyCollection needs, IReadOnlyList chain) + private static IEnumerable GetTrades(PKM pk, IReadOnlyCollection needs, IReadOnlyList chain, GameVersion version) { - var trades = EncounterTradeGenerator.GetPossible(pk, chain); + var trades = EncounterTradeGenerator.GetPossible(pk, chain, version); foreach (var trade in trades) { if (needs.Count == 0) @@ -338,7 +345,9 @@ private static IEnumerable GetTrades(PKM pk, IReadOnlyCollection yield return trade; continue; } - var em = trade.Moves; + IEnumerable em = trade.Moves; + if (trade.Generation <= 2) + em = em.Concat(MoveLevelUp.GetEncounterMoves(trade.Species, 0, trade.Level, trade.Version)); if (!needs.Except(em).Any()) yield return trade; } @@ -368,8 +377,9 @@ private static IEnumerable GetSlots(PKM pk, IReadOnlyList ne if (slot is IMoveset m && !needs.Except(m.Moves).Any()) yield return slot; - - if (needs.Count == 1 && slot is EncounterSlot6AO {CanDexNav: true} dn && dn.CanBeDexNavMove(needs[0])) + else if (needs.Count == 1 && slot is EncounterSlot6AO {CanDexNav: true} dn && dn.CanBeDexNavMove(needs[0])) + yield return slot; + else if (slot.Generation <= 2 && !needs.Except(MoveLevelUp.GetEncounterMoves(slot.Species, 0, slot.LevelMin, slot.Version)).Any()) yield return slot; } }