Simplify shared egg move array get

This commit is contained in:
Kurt
2021-01-31 23:07:14 -08:00
parent a43f6aa71a
commit 7833d12f95
2 changed files with 10 additions and 6 deletions

View File

@@ -180,10 +180,7 @@ private static IEnumerable<int> GetMovesForGeneration(PKM pk, IReadOnlyList<EvoC
{
// Shared Egg Moves via daycare
// Any egg move can be obtained
var evo = chain[chain.Count - 1];
var shared = MoveEgg.GetEggMoves(8, evo.Species, evo.Form, GameVersion.SW);
if (shared.Length != 0)
moves = moves.Concat(shared);
moves = moves.Concat(MoveEgg.GetSharedEggMoves(pk, generation));
// TR moves -- default logic checks the TR flags, so we need to add all possible ones here.
moves = moves.Concat(MoveTechnicalMachine.GetAllPossibleRecords(pk.Species, pk.Form));

View File

@@ -69,12 +69,19 @@ public static bool GetIsSharedEggMove(PKM pkm, int gen, int move)
{
if (gen < 8 || pkm.IsEgg)
return false;
var egg = GetSharedEggMoves(pkm, gen);
return Array.IndexOf(egg, move) >= 0;
}
public static int[] GetSharedEggMoves(PKM pkm, int gen)
{
if (gen < 8 || pkm.IsEgg)
return Array.Empty<int>();
var table = PersonalTable.SWSH;
var entry = (PersonalInfoSWSH)table.GetFormEntry(pkm.Species, pkm.Form);
var baseSpecies = entry.HatchSpecies;
var baseForm = entry.HatchFormIndexEverstone;
var egg = GetEggMoves(8, baseSpecies, baseForm, SW);
return Array.Exists(egg, z => z == move);
return GetEggMoves(8, baseSpecies, baseForm, SW);
}
}
}