Add tradeback wipe of Gen2 initial moves

This commit is contained in:
Kurt 2024-04-20 13:59:24 -05:00
parent e1b964ad64
commit 54525da20b
6 changed files with 22 additions and 3 deletions

View file

@ -70,7 +70,7 @@ public static class EncounterDate
/// </summary>
public static bool IsValidDateSwitch(DateOnly date)
{
if (date.Year is < 2000 or > 2050)
if (date.Year is < 2000 or > 2060)
return false;
return true;
}

View file

@ -38,7 +38,25 @@ public sealed class LearnGroup2 : ILearnGroup
if (enc is EncounterEgg { Generation: Generation } egg)
CheckEncounterMoves(result, current, egg);
return MoveResult.AllParsed(result);
bool vc1 = pk.VC1;
if (!vc1 && MoveResult.AllParsed(result))
return true;
// Uh-oh, not all moves are verified yet.
// To visit Gen1, we need to invalidate moves that can't be learned in Gen1 or re-learned in Gen2.
for (int i = 0; i < result.Length; i++)
{
if (current[i] <= Legal.MaxMoveID_1)
continue;
var move = result[i];
if (!move.IsParsed)
continue;
var method = move.Info.Method;
if ((vc1 && move.Generation == 2) || method is LearnMethod.Initial || method.IsEggSource())
result[i] = MoveResult.Unobtainable();
}
return false;
}
private static void CheckEncounterMoves(PKM pk, Span<MoveResult> result, ReadOnlySpan<ushort> current, IEncounterTemplate enc)

View file

@ -32,7 +32,8 @@ internal static class LearnVerifierHistory
MarkRelearnMoves(result, current, pk);
// Knock off initial moves if available.
MarkSpecialMoves(result, current, enc, pk);
if (enc.Generation != 2) // Handle trade-backs in Gen2 separately.
MarkSpecialMoves(result, current, enc, pk);
}
// Iterate games to identify move sources.