PKHeX/PKHeX.Core/Legality/Moves/GameData.cs

109 lines
3.6 KiB
C#
Raw Normal View History

using System;
using static PKHeX.Core.GameVersion;
namespace PKHeX.Core
{
public static class GameData
{
public static Learnset[] GetLearnsets(GameVersion game) => Learnsets(game);
public static PersonalTable GetPersonal(GameVersion game) => Personal(game);
Add Breeding move ordering logic, and use in legality analysis (#3183) * Initial bred moveset validation logic Unpeel the inheritance via recursion and permitted moves * Volt tackle considerations * Optimize out empty slot skips * Add tests, fix off-by-one's * Require all base moves if empty slot in moveset * Add test to prove failure per Anubis' provided test * Tweak enum labels for easier debugging When two enums share the same underlying value, the ToString/name of the value may be either of the two (or the last defined one, in my debugging). Just give it a separate magic value. * Fix recursion oopsie Also check for scenario where no-base-moves but not enough moves to push base moves out * Add Crystal tutor checks * Add specialized gen2 verification method Game loops through father's moves and pushes in one iteration, rather than checking by type. * Add another case with returning base move * Add push-out requirement for re-added base moves * Minor tweaks Condense tests, fix another off-by-one noticed when creating tests * Disallow inherited parent levelup moves Disallow volt tackle on Gen2/R/S * Split MoveBreed into generation specific classes Gen2 behaves slightly different from Gen3/4, which behaves slightly different from Gen5... and Gen6 behaves differently too. Add some xmldoc as the api is starting to solidify * Add method overload that returns the parse Verify that the parse order is as expected * Add reordering suggestion logic Try sorting first, then go nuclear with rebuilding. * Return base moves if complete fail * Set base moves when generating eggs, only. * Use breed logic to check for egg ordering legality Don't bother helping for split-breed species
2021-04-05 01:30:01 +00:00
public static Learnset GetLearnset(GameVersion game, int species, int form)
{
var pt = Personal(game);
var index = pt.GetFormIndex(species, form);
var sets = Learnsets(game);
return sets[index];
}
private static Learnset[] Learnsets(GameVersion game) => game switch
{
RD or GN or BU or RB => Legal.LevelUpRB,
YW or RBY => Legal.LevelUpY,
GD or SV or GS => Legal.LevelUpGS,
C or GSC => Legal.LevelUpC,
R or S or RS or RSE => Legal.LevelUpRS,
E or COLO or XD or FRLG or CXD => Legal.LevelUpE,
FR => Legal.LevelUpFR,
LG => Legal.LevelUpLG,
D or P or DP => Legal.LevelUpDP,
Pt or DPPt => Legal.LevelUpPt,
HG or SS or HGSS => Legal.LevelUpHGSS,
B or W or BW => Legal.LevelUpBW,
B2 or W2 or B2W2 => Legal.LevelUpB2W2,
X or Y or XY => Legal.LevelUpXY,
AS or OR or ORAS => Legal.LevelUpAO,
SN or MN or SM => Legal.LevelUpSM,
US or UM or USUM => Legal.LevelUpUSUM,
GO or GP or GE or GG => Legal.LevelUpGG,
SW or SH or SWSH => Legal.LevelUpSWSH,
BD or SP or BDSP => Legal.LevelUpBDSP,
Gen1 => Legal.LevelUpY,
Gen2 => Legal.LevelUpC,
Gen3 => Legal.LevelUpE,
Gen4 => Legal.LevelUpHGSS,
Gen5 => Legal.LevelUpB2W2,
Gen6 => Legal.LevelUpAO,
Gen7 => Legal.LevelUpSM,
Gen7b => Legal.LevelUpGG,
Gen8 => Legal.LevelUpSWSH,
Stadium => Legal.LevelUpY,
Stadium2 => Legal.LevelUpGS,
2021-08-20 20:49:20 +00:00
_ => throw new ArgumentOutOfRangeException(nameof(game)),
};
2018-07-29 20:27:48 +00:00
private static PersonalTable Personal(GameVersion game) => game switch
{
RD or GN or BU or RB => PersonalTable.RB,
YW or RBY => PersonalTable.Y,
GD or SV or GS => PersonalTable.GS,
C or GSC => PersonalTable.C,
R or S or RS or RSE => PersonalTable.RS,
E or COLO or XD or FRLG or CXD => PersonalTable.E,
FR => PersonalTable.FR,
LG => PersonalTable.LG,
D or P or DP => PersonalTable.DP,
Pt or DPPt => PersonalTable.Pt,
HG or SS or HGSS => PersonalTable.HGSS,
B or W or BW => PersonalTable.BW,
B2 or W2 or B2W2 => PersonalTable.B2W2,
X or Y or XY => PersonalTable.XY,
AS or OR or ORAS => PersonalTable.AO,
SN or MN or SM => PersonalTable.SM,
US or UM or USUM => PersonalTable.USUM,
GO or GP or GE or GG => PersonalTable.GG,
SW or SH or SWSH => PersonalTable.SWSH,
BD or SP or BDSP => PersonalTable.BDSP,
Gen1 => PersonalTable.Y,
Gen2 => PersonalTable.C,
Gen3 => PersonalTable.E,
Gen4 => PersonalTable.HGSS,
Gen5 => PersonalTable.B2W2,
Gen6 => PersonalTable.AO,
Gen7 => PersonalTable.USUM,
Gen7b => PersonalTable.GG,
Gen8 => PersonalTable.SWSH,
Stadium => PersonalTable.Y,
Stadium2 => PersonalTable.GS,
2021-08-20 20:49:20 +00:00
_ => throw new ArgumentOutOfRangeException(nameof(game)),
};
}
}