2018-08-02 01:30:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-06-10 17:44:05 +00:00
|
|
|
|
using static PKHeX.Core.Legal;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
internal static class MoveEgg
|
|
|
|
|
{
|
|
|
|
|
internal static int[] GetEggMoves(PKM pkm, int species, int formnum, GameVersion version)
|
|
|
|
|
{
|
2018-06-13 01:46:31 +00:00
|
|
|
|
int gen = pkm.Format <= 2 || pkm.VC ? 2 : pkm.GenNumber;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
if (!pkm.InhabitedGeneration(gen, species) || (pkm.PersonalInfo.Gender == 255 && !FixedGenderFromBiGender.Contains(species)))
|
2018-08-02 01:30:51 +00:00
|
|
|
|
return Array.Empty<int>();
|
2018-11-20 21:38:05 +00:00
|
|
|
|
|
|
|
|
|
if (pkm.Version == 15 || pkm.GG)
|
|
|
|
|
return Array.Empty<int>();
|
|
|
|
|
|
2018-06-10 17:44:05 +00:00
|
|
|
|
if (version == GameVersion.Any)
|
|
|
|
|
version = (GameVersion)pkm.Version;
|
2018-06-13 01:46:31 +00:00
|
|
|
|
return GetEggMoves(gen, species, formnum, version);
|
2018-06-10 17:44:05 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2018-06-10 17:44:05 +00:00
|
|
|
|
private static int[] GetEggMoves(int gen, int species, int formnum, GameVersion version)
|
|
|
|
|
{
|
|
|
|
|
switch (gen)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
return (version == GameVersion.C ? EggMovesC : EggMovesGS)[species].Moves;
|
|
|
|
|
case 3:
|
|
|
|
|
return EggMovesRS[species].Moves;
|
|
|
|
|
case 4:
|
|
|
|
|
switch (version)
|
|
|
|
|
{
|
|
|
|
|
case GameVersion.HG:
|
|
|
|
|
case GameVersion.SS:
|
|
|
|
|
return EggMovesHGSS[species].Moves;
|
|
|
|
|
default:
|
|
|
|
|
return EggMovesDPPt[species].Moves;
|
|
|
|
|
}
|
|
|
|
|
case 5:
|
|
|
|
|
return EggMovesBW[species].Moves;
|
|
|
|
|
case 6: // entries per species
|
|
|
|
|
switch (version)
|
|
|
|
|
{
|
|
|
|
|
case GameVersion.OR:
|
|
|
|
|
case GameVersion.AS:
|
|
|
|
|
return EggMovesAO[species].Moves;
|
|
|
|
|
default:
|
|
|
|
|
return EggMovesXY[species].Moves;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 7: // entries per form if required
|
|
|
|
|
switch (version)
|
|
|
|
|
{
|
|
|
|
|
case GameVersion.US:
|
|
|
|
|
case GameVersion.UM:
|
|
|
|
|
return GetFormEggMoves(species, formnum, EggMovesUSUM);
|
|
|
|
|
default:
|
|
|
|
|
return GetFormEggMoves(species, formnum, EggMovesSM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2018-08-02 01:30:51 +00:00
|
|
|
|
return Array.Empty<int>();
|
2018-06-10 17:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int[] GetFormEggMoves(int species, int formnum, EggMoves[] table)
|
|
|
|
|
{
|
|
|
|
|
var entry = table[species];
|
|
|
|
|
if (formnum > 0 && AlolanOriginForms.Contains(species))
|
|
|
|
|
entry = table[entry.FormTableIndex + formnum - 1];
|
|
|
|
|
return entry.Moves;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static int[] GetRelearnLVLMoves(PKM pkm, int species, int lvl, int formnum, GameVersion version = GameVersion.Any)
|
|
|
|
|
{
|
|
|
|
|
if (version == GameVersion.Any)
|
|
|
|
|
version = (GameVersion)pkm.Version;
|
|
|
|
|
// A pkm can only have levelup relearn moves from the game it originated on
|
|
|
|
|
// eg Plusle/Minun have Charm/Fake Tears (respectively) only in OR/AS, not X/Y
|
|
|
|
|
switch (version)
|
|
|
|
|
{
|
|
|
|
|
case GameVersion.X:
|
|
|
|
|
case GameVersion.Y:
|
|
|
|
|
return getMoves(LevelUpXY, PersonalTable.XY);
|
|
|
|
|
case GameVersion.AS:
|
|
|
|
|
case GameVersion.OR:
|
|
|
|
|
return getMoves(LevelUpAO, PersonalTable.AO);
|
|
|
|
|
|
|
|
|
|
case GameVersion.SN:
|
|
|
|
|
case GameVersion.MN:
|
|
|
|
|
if (species > MaxSpeciesID_7)
|
|
|
|
|
break;
|
|
|
|
|
return getMoves(LevelUpSM, PersonalTable.SM);
|
|
|
|
|
case GameVersion.US:
|
|
|
|
|
case GameVersion.UM:
|
|
|
|
|
return getMoves(LevelUpUSUM, PersonalTable.USUM);
|
|
|
|
|
}
|
2018-08-02 01:30:51 +00:00
|
|
|
|
return Array.Empty<int>();
|
2018-06-10 17:44:05 +00:00
|
|
|
|
|
|
|
|
|
int[] getMoves(IReadOnlyList<Learnset> moves, PersonalTable table) => moves[table.GetFormeIndex(species, formnum)].GetMoves(lvl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|