PKHeX/PKHeX.Core/Legality/MoveList.cs
Kurt 88830e0d00
Update from .NET Framework 4.6 to .NET 7 (#3729)
Updates from net46->net7, dropping support for mono in favor of using the latest runtime (along with the performance/API improvements). Releases will be posted as 64bit only for now.

Refactors a good amount of internal API methods to be more performant and more customizable for future updates & fixes.

Adds functionality for Batch Editor commands to `>`, `<` and <=/>=

TID/SID properties renamed to TID16/SID16 for clarity; other properties exposed for Gen7 / display variants.

Main window has a new layout to account for DPI scaling (8 point grid)

Fixed: Tatsugiri and Paldean Tauros now output Showdown form names as Showdown expects
Changed: Gen9 species now interact based on the confirmed National Dex IDs (closes #3724)
Fixed: Pokedex set all no longer clears species with unavailable non-base forms (closes #3720)
Changed: Hyper Training suggestions now apply for level 50 in SV. (closes #3714)
Fixed: B2/W2 hatched egg met locations exclusive to specific versions are now explicitly checked (closes #3691)
Added: Properties for ribbon/mark count (closes #3659)
Fixed: Traded SV eggs are now checked correctly (closes #3692)
2023-01-21 20:02:33 -08:00

84 lines
3.1 KiB
C#

using System;
using static PKHeX.Core.Legal;
using static PKHeX.Core.GameVersion;
namespace PKHeX.Core;
/// <summary>
/// Logic for obtaining a list of moves.
/// </summary>
internal static class MoveList
{
internal static void GetCurrentMoves(PKM pk, ushort species, byte form, GameVersion gameSource, int lvl, Span<ushort> moves) => _ = gameSource switch
{
GSC or GS => Get(moves, LevelUpGS, species, lvl, pk.Format),
C => Get(moves, LevelUpC, species, lvl, pk.Format),
R or S or RS => Get(moves, LevelUpRS, species, lvl),
E => Get(moves, LevelUpE, species, lvl),
FR or LG or FRLG => Get(moves, LevelUpFR, species, lvl),
D or P or DP => Get(moves, LevelUpDP, species, lvl),
Pt => Get(moves, LevelUpPt, species, lvl),
HG or SS or HGSS => Get(moves, LevelUpHGSS, species, lvl),
B or W or BW => Get(moves, LevelUpBW, species, lvl),
B2 or W2 or B2W2 => Get(moves, LevelUpB2W2, species, lvl),
X or Y or XY => Get(moves, LevelUpXY, species, lvl),
AS or OR or ORAS => Get(moves, LevelUpAO, species, lvl),
SN or MN or SM => Get(moves, LevelUpSM, PersonalTable.SM, species, form, lvl),
US or UM or USUM => Get(moves, LevelUpUSUM, PersonalTable.USUM, species, form, lvl),
SW or SH or SWSH => Get(moves, LevelUpSWSH, PersonalTable.SWSH, species, form, lvl),
BD or SP or BDSP => Get(moves, LevelUpBDSP, PersonalTable.BDSP, species, form, lvl),
PLA => Get(moves, LevelUpLA, PersonalTable.LA, species, form, lvl),
SL or VL or SV => Get(moves, LevelUpSV, PersonalTable.SV, species, form, lvl),
_ => moves,
};
private static Span<ushort> Get(Span<ushort> moves, Learnset[] source, ushort species, int lvl)
{
if (species >= source.Length)
return moves;
source[species].SetLevelUpMoves(1, lvl, moves);
return moves;
}
private static Span<ushort> Get<T>(Span<ushort> moves, Learnset[] source, T pt, ushort species, byte form, int lvl) where T : IPersonalTable
{
if (!pt.IsPresentInGame(species, form))
return moves;
int index = pt.GetFormIndex(species, form);
source[index].SetLevelUpMoves(1, lvl, moves);
return moves;
}
private static Span<ushort> Get(Span<ushort> moves, Learnset[] source, ushort species, int lvl, int format)
{
if (species > MaxSpeciesID_2)
return moves;
source[species].SetLevelUpMoves(1, lvl, moves);
if (format != 1)
return moves;
// If checking back-transfer specimen (GSC->RBY), remove moves that must be deleted prior to transfer
// Remove all values greater than MaxMoveID_1, and shift the remaining indexes down.
for (int i = 0; i < moves.Length; i++)
{
if (moves[i] <= MaxMoveID_1)
continue;
// Shift remaining indexes down, set last index to 0
for (int j = i; j < moves.Length - 1; j++)
moves[j] = moves[j + 1];
moves[^1] = 0;
}
return moves;
}
}