mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
Allow downwards traversal for evo move check
https://projectpokemon.org/home/forums/topic/67681-move-evolution-pokemon-from-gen-4-gen-7-flagging-at-level-100/#findComment-299264
This commit is contained in:
parent
f2ffca749f
commit
571de117fb
|
|
@ -13,6 +13,13 @@ public sealed class LearnGroup8 : ILearnGroup
|
|||
public ushort MaxMoveID => Legal.MaxMoveID_8;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option)
|
||||
{
|
||||
if (option is LearnOption.AtAnyTimeChain)
|
||||
return LearnGroupHOME.Instance;
|
||||
return GoBackwards(pk, history, enc, option);
|
||||
}
|
||||
|
||||
internal static ILearnGroup? GoBackwards(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option)
|
||||
{
|
||||
if (enc.Generation >= Generation)
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public sealed class LearnGroup8a : ILearnGroup
|
|||
private const EntityContext Context = EntityContext.Gen8a;
|
||||
public ushort MaxMoveID => Legal.MaxMoveID_8a;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => option == LearnOption.AtAnyTimeChain ? LearnGroupHOME.Instance : null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedPLA;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<ushort> current, PKM pk, EvolutionHistory history,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public sealed class LearnGroup8b : ILearnGroup
|
|||
private const EntityContext Context = EntityContext.Gen8b;
|
||||
public ushort MaxMoveID => Legal.MaxMoveID_8b;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => option == LearnOption.AtAnyTimeChain ? LearnGroupHOME.Instance : null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedBDSP;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<ushort> current, PKM pk, EvolutionHistory history,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public sealed class LearnGroup9 : ILearnGroup
|
|||
private const EntityContext Context = EntityContext.Gen9;
|
||||
public ushort MaxMoveID => Legal.MaxMoveID_9;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => option == LearnOption.AtAnyTimeChain ? LearnGroupHOME.Instance : null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedGen9;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<ushort> current, PKM pk, EvolutionHistory history,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public sealed class LearnGroup9a : ILearnGroup
|
|||
private const EntityContext Context = EntityContext.Gen9a;
|
||||
public ushort MaxMoveID => Legal.MaxMoveID_9a;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => option == LearnOption.AtAnyTimeChain ? LearnGroupHOME.Instance : null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => history.HasVisitedZA;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<ushort> current, PKM pk, EvolutionHistory history,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ public sealed class LearnGroupHOME : ILearnGroup
|
|||
private const LearnOption Option = LearnOption.HOME;
|
||||
public ushort MaxMoveID => 0;
|
||||
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) => null;
|
||||
public ILearnGroup? GetPrevious(PKM pk, EvolutionHistory history, IEncounterTemplate enc, LearnOption option) =>
|
||||
option is LearnOption.AtAnyTimeChain ? LearnGroup8.GoBackwards(pk, history, enc, option) : null;
|
||||
public bool HasVisited(PKM pk, EvolutionHistory history) => pk is IHomeTrack { HasTracker: true } || !ParseSettings.IgnoreTransferIfNoTracker;
|
||||
|
||||
public bool Check(Span<MoveResult> result, ReadOnlySpan<ushort> current, PKM pk, EvolutionHistory history,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,14 @@ public enum LearnOption
|
|||
/// Required to be distinct in that the rules are different from the other two options. TR/TM flags aren't required if the move was learned via HOME.
|
||||
/// </remarks>
|
||||
HOME,
|
||||
|
||||
/// <summary>
|
||||
/// Check backwards of knowing moves within any game in the visitation chain.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Relevant for Evolution move sanity checks, where the move could have been picked up at any point in the game visitation chain.
|
||||
/// </remarks>
|
||||
AtAnyTimeChain,
|
||||
}
|
||||
|
||||
public static class LearnOptionExtensions
|
||||
|
|
@ -35,7 +43,7 @@ public static class LearnOptionExtensions
|
|||
extension(LearnOption option)
|
||||
{
|
||||
public bool IsCurrent() => option == LearnOption.Current;
|
||||
public bool IsPast() => option is LearnOption.AtAnyTime or LearnOption.HOME;
|
||||
public bool IsPast() => option is LearnOption.AtAnyTime or LearnOption.HOME or LearnOption.AtAnyTimeChain;
|
||||
public bool IsFlagCheckRequired() => option != LearnOption.HOME;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public static bool IsValidEvolutionWithMove(PKM pk, LegalInfo info)
|
|||
if (move is EEVEE)
|
||||
return IsValidEvolutionWithMoveAny(enc, EeveeFairyMoves, pruned, pk, head);
|
||||
|
||||
return MemoryPermissions.GetCanKnowMove(enc, move, pruned, pk, head);
|
||||
return MemoryPermissions.GetCanKnowMove(enc, move, pruned, pk, head, LearnOption.AtAnyTimeChain);
|
||||
}
|
||||
|
||||
private static bool IsMoveInRelearnSource(PKM pk, LegalInfo info, ushort move)
|
||||
|
|
@ -182,7 +182,7 @@ private static bool IsValidEvolutionWithMoveAny(IEncounterTemplate enc, ReadOnly
|
|||
{
|
||||
foreach (var move in any)
|
||||
{
|
||||
if (MemoryPermissions.GetCanKnowMove(enc, move, history, pk, head))
|
||||
if (MemoryPermissions.GetCanKnowMove(enc, move, history, pk, head, LearnOption.AtAnyTimeChain))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -161,11 +161,11 @@ private static bool GetCanKnowMove(PKM pk, ushort move, EntityContext context, E
|
|||
return GetCanKnowMove(enc, move, history, pk, game);
|
||||
}
|
||||
|
||||
public static bool GetCanKnowMove(IEncounterTemplate enc, ushort move, EvolutionHistory history, PKM pk, ILearnGroup game)
|
||||
public static bool GetCanKnowMove(IEncounterTemplate enc, ushort move, EvolutionHistory history, PKM pk, ILearnGroup game, LearnOption option = LearnOption.AtAnyTime)
|
||||
{
|
||||
Span<MoveResult> result = stackalloc MoveResult[1];
|
||||
Span<ushort> moves = [move];
|
||||
LearnVerifierHistory.MarkAndIterate(result, moves, enc, pk, history, game, MoveSourceType.All, LearnOption.AtAnyTime);
|
||||
LearnVerifierHistory.MarkAndIterate(result, moves, enc, pk, history, game, MoveSourceType.All, option);
|
||||
return result[0].Valid;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user