2018-06-13 01:35:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
|
|
using static PKHeX.Core.Legal;
|
2018-06-13 05:15:06 +00:00
|
|
|
|
using static PKHeX.Core.GameVersion;
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2020-10-27 16:25:33 +00:00
|
|
|
|
public static class MoveLevelUp
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-11-12 06:49:17 +00:00
|
|
|
|
private static readonly LearnLookup
|
2020-12-22 01:17:56 +00:00
|
|
|
|
LearnSWSH = new(PersonalTable.SWSH, LevelUpSWSH, SWSH),
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnSM = new(PersonalTable.SM, LevelUpSM, SM),
|
2020-12-22 01:17:56 +00:00
|
|
|
|
LearnUSUM = new(PersonalTable.USUM, LevelUpUSUM, USUM),
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnGG = new(PersonalTable.GG, LevelUpGG, Gen7b),
|
|
|
|
|
LearnXY = new(PersonalTable.XY, LevelUpXY, XY),
|
|
|
|
|
LearnAO = new(PersonalTable.AO, LevelUpAO, ORAS),
|
|
|
|
|
LearnBW = new(PersonalTable.BW, LevelUpBW, BW),
|
2020-12-22 01:17:56 +00:00
|
|
|
|
LearnB2W2 = new(PersonalTable.B2W2, LevelUpB2W2, B2W2),
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnDP = new(PersonalTable.DP, LevelUpDP, DP),
|
|
|
|
|
LearnPt = new(PersonalTable.Pt, LevelUpPt, Pt),
|
2020-12-22 01:17:56 +00:00
|
|
|
|
LearnHGSS = new(PersonalTable.HGSS, LevelUpHGSS, HGSS),
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnRSE = new(PersonalTable.RS, LevelUpRS, RSE),
|
|
|
|
|
LearnFRLG = new(PersonalTable.LG, LevelUpLG, FRLG),
|
|
|
|
|
LearnGS = new(PersonalTable.GS, LevelUpGS, GS),
|
|
|
|
|
LearnC = new(PersonalTable.C, LevelUpC, C),
|
|
|
|
|
LearnRB = new(PersonalTable.RB, LevelUpRB, RB),
|
|
|
|
|
LearnY = new(PersonalTable.Y, LevelUpY, YW);
|
|
|
|
|
|
|
|
|
|
public static LearnVersion GetIsLevelUpMove(PKM pkm, int species, int form, int maxLevel, int generation, int move, int minlvlG1, int minlvlG2, GameVersion version = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2020-02-13 04:25:39 +00:00
|
|
|
|
if (pkm.IsMovesetRestricted(generation))
|
2018-06-14 05:03:58 +00:00
|
|
|
|
version = (GameVersion)pkm.Version;
|
2018-11-12 06:49:17 +00:00
|
|
|
|
|
2020-12-24 01:14:38 +00:00
|
|
|
|
return generation switch
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
1 => GetIsLevelUp1(species, form, move, maxLevel, minlvlG1, version),
|
2020-12-24 01:14:38 +00:00
|
|
|
|
2 when move > MaxMoveID_1 && pkm.LearnMovesNew2Disallowed() => LearnNONE,
|
2021-07-23 04:25:15 +00:00
|
|
|
|
2 => GetIsLevelUp2(species, form, move, maxLevel, minlvlG2, version, pkm.Korean),
|
|
|
|
|
3 => GetIsLevelUp3(species, form, move, maxLevel, version),
|
|
|
|
|
4 => GetIsLevelUp4(species, form, move, maxLevel, version),
|
|
|
|
|
5 => GetIsLevelUp5(species, form, move, maxLevel, version),
|
|
|
|
|
6 => GetIsLevelUp6(species, form, move, maxLevel, version),
|
|
|
|
|
7 => GetIsLevelUp7(species, form, move, version), // move reminder can give any move 1-100
|
|
|
|
|
8 => GetIsLevelUp8(species, form, move, maxLevel, version),
|
2020-12-24 01:14:38 +00:00
|
|
|
|
_ => LearnNONE
|
|
|
|
|
};
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
internal static LearnVersion GetIsLevelUp1(int species, int form, int move, int maxLevel, int minLevel, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (move > MaxMoveID_1)
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
|
2018-06-13 05:15:06 +00:00
|
|
|
|
switch (ver)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
case Any: case RBY:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var first = LearnRB.GetIsLevelUpG1(species, form, move, maxLevel, minLevel);
|
|
|
|
|
var second = LearnY.GetIsLevelUpG1(species, form, move, maxLevel, minLevel);
|
2018-06-19 04:56:30 +00:00
|
|
|
|
if (!first.IsLevelUp)
|
|
|
|
|
return second;
|
|
|
|
|
if (!second.IsLevelUp)
|
2018-06-13 05:15:06 +00:00
|
|
|
|
return first;
|
2018-06-19 04:56:30 +00:00
|
|
|
|
return first.Level > second.Level ? second : first;
|
2018-06-13 05:15:06 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case RD or BU or GN or RB:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnRB.GetIsLevelUpG1(species, form, move, maxLevel, minLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case YW:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnY.GetIsLevelUpG1(species, form, move, maxLevel, minLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp2(int species, int form, int move, int maxLevel, int minLevel, GameVersion ver = Any, bool korean = false)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
// No Korean Crystal
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
case Any: case GSC:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var first = LearnGS.GetIsLevelUpMin(species, move, maxLevel, minLevel, form);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (first.IsLevelUp || korean)
|
|
|
|
|
return first;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnC.GetIsLevelUpMin(species, move, maxLevel, minLevel, form);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case GD or SV or GS:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnGS.GetIsLevelUpMin(species, move, maxLevel, minLevel, form);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case C when !korean:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnC.GetIsLevelUpMin(species, move, maxLevel, minLevel, form);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp3(int species, int form, int move, int lvlLevel, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (species == (int)Species.Deoxys)
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return GetIsLevelUp3Deoxys(form, move, lvlLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
2018-06-13 05:15:06 +00:00
|
|
|
|
// Emerald level up tables are equal to R/S level up tables
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var first = LearnRSE.GetIsLevelUp(species, form, move, lvlLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (first.IsLevelUp)
|
|
|
|
|
return first;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnFRLG.GetIsLevelUp(species, form, move, lvlLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case R or S or E or RS or RSE:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnRSE.GetIsLevelUp(species, form, move, lvlLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case FR or LG or FRLG:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnFRLG.GetIsLevelUp(species, form, move, lvlLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp4(int species, int form, int move, int maxLevel, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
case Any: case DPPt:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var first = LearnDP.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (first.IsLevelUp)
|
|
|
|
|
return first;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var second = LearnPt.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (second.IsLevelUp)
|
|
|
|
|
return second;
|
|
|
|
|
if (ver == DPPt) // stop here
|
|
|
|
|
return LearnNONE;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnHGSS.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case D or P or DP:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnDP.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Pt:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnPt.GetIsLevelUp(species, form, move, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case HG or SS or HGSS:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnHGSS.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp5(int species, int form, int move, int maxLevel, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
switch (ver)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Any:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var first = LearnBW.GetIsLevelUp(species, form, move, maxLevel);
|
2018-08-04 17:05:47 +00:00
|
|
|
|
if (first.IsLevelUp && species != 646) // Kyurem moves are same for both versions, but forme movepool not present.
|
2018-06-13 05:15:06 +00:00
|
|
|
|
return first;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnB2W2.GetIsLevelUp(species, form, move, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case B or W or BW:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnBW.GetIsLevelUp(species, form, move, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case B2 or W2 or B2W2:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnB2W2.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp6(int species, int form, int move, int maxLevel, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Any:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var first = LearnXY.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (first.IsLevelUp)
|
|
|
|
|
return first;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnAO.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case X or Y or XY:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnXY.GetIsLevelUp(species, form, move, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case OR or AS or ORAS:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnAO.GetIsLevelUp(species, form, move, maxLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp7(int species, int form, int move, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case GP or GE or GG or GO:
|
2018-11-12 06:49:17 +00:00
|
|
|
|
return LearnGG.GetIsLevelUp(species, form, move);
|
|
|
|
|
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Any:
|
2020-06-28 03:44:14 +00:00
|
|
|
|
if (species > MaxSpeciesID_7_USUM)
|
2018-06-13 05:15:06 +00:00
|
|
|
|
return LearnNONE;
|
2020-06-28 03:44:14 +00:00
|
|
|
|
var first = LearnUSUM.GetIsLevelUp(species, form, move);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (first.IsLevelUp)
|
|
|
|
|
return first;
|
2020-06-28 03:44:14 +00:00
|
|
|
|
if (species > MaxSpeciesID_7)
|
2018-06-13 05:15:06 +00:00
|
|
|
|
return LearnNONE;
|
2020-06-28 03:44:14 +00:00
|
|
|
|
return LearnSM.GetIsLevelUp(species, form, move);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case SN or MN or SM:
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (species > MaxSpeciesID_7)
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
return LearnSM.GetIsLevelUp(species, form, move);
|
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case US or UM or USUM:
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (species > MaxSpeciesID_7_USUM)
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
return LearnUSUM.GetIsLevelUp(species, form, move);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp8(int species, int form, int move, int maxLevel, GameVersion ver = Any)
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any:
|
2020-11-19 05:34:40 +00:00
|
|
|
|
case GO:
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case SW or SH or SWSH:
|
2019-09-23 23:56:47 +00:00
|
|
|
|
if (species > MaxSpeciesID_8)
|
|
|
|
|
return LearnNONE;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnSWSH.GetIsLevelUp(species, form, move, maxLevel);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 03:10:41 +00:00
|
|
|
|
private static LearnVersion GetIsLevelUp3Deoxys(int form, int move, int lvl)
|
|
|
|
|
{
|
|
|
|
|
var moveset = GetDeoxysLearn3(form);
|
|
|
|
|
if (moveset == null)
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
var lv = moveset.GetLevelLearnMove(move);
|
|
|
|
|
if (lv >= 0 && lv <= lvl)
|
|
|
|
|
return new LearnVersion(lv, GetDeoxysGameVersion3(form));
|
|
|
|
|
return LearnNONE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 01:08:49 +00:00
|
|
|
|
private static GameVersion GetDeoxysGameVersion3(int form) => form switch
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
0 => RS,
|
|
|
|
|
1 => FR,
|
|
|
|
|
2 => LG,
|
|
|
|
|
3 => E,
|
|
|
|
|
_ => Invalid
|
|
|
|
|
};
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
private static Learnset? GetDeoxysLearn3(int form, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2019-06-01 17:22:49 +00:00
|
|
|
|
const int index = (int)Species.Deoxys;
|
2018-06-13 05:15:06 +00:00
|
|
|
|
if (ver == Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
return form switch
|
2018-08-03 03:11:42 +00:00
|
|
|
|
{
|
2019-10-08 01:40:09 +00:00
|
|
|
|
0 => LevelUpRS[index], // Normal
|
|
|
|
|
1 => LevelUpFR[index], // Attack
|
|
|
|
|
2 => LevelUpLG[index], // Defense
|
|
|
|
|
3 => LevelUpE[index], // Speed
|
|
|
|
|
_ => null,
|
|
|
|
|
};
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2018-06-13 01:35:56 +00:00
|
|
|
|
var gen = ver.GetGeneration();
|
|
|
|
|
if (gen != 3)
|
|
|
|
|
return GetDeoxysLearn3(form);
|
2019-06-01 17:22:49 +00:00
|
|
|
|
return GameData.GetLearnsets(ver)[index];
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
public static IEnumerable<int> GetMovesLevelUp(PKM pkm, int species, int form, int maxLevel, int minlvlG1, int minlvlG2, GameVersion version, bool MoveReminder, int generation)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2020-09-06 17:53:13 +00:00
|
|
|
|
if (pkm.IsMovesetRestricted(generation))
|
2018-06-14 05:03:58 +00:00
|
|
|
|
version = (GameVersion)pkm.Version;
|
2020-09-06 17:53:13 +00:00
|
|
|
|
return generation switch
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
1 => GetMovesLevelUp1(species, form, maxLevel, minlvlG1, version),
|
|
|
|
|
2 => GetMovesLevelUp2(species, form, maxLevel, minlvlG2, pkm.Korean, pkm.LearnMovesNew2Disallowed(), version),
|
|
|
|
|
3 => GetMovesLevelUp3(species, form, maxLevel, version),
|
|
|
|
|
4 => GetMovesLevelUp4(species, form, maxLevel, version),
|
|
|
|
|
5 => GetMovesLevelUp5(species, form, maxLevel, version),
|
|
|
|
|
6 => GetMovesLevelUp6(species, form, maxLevel, version),
|
|
|
|
|
7 => GetMovesLevelUp7(species, form, maxLevel, MoveReminder, version),
|
|
|
|
|
8 => GetMovesLevelUp8(species, form, maxLevel, version),
|
2020-01-07 01:50:18 +00:00
|
|
|
|
_ => Array.Empty<int>()
|
2019-10-08 01:40:09 +00:00
|
|
|
|
};
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-17 07:22:54 +00:00
|
|
|
|
private static bool LearnMovesNew2Disallowed(this PKM pkm) => pkm.Format == 1 || (pkm.Format >= 7 && pkm.VC1);
|
2018-06-15 01:52:43 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
internal static List<int> GetMovesLevelUp1(int species, int form, int maxLevel, int minLevel, GameVersion ver = Any)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp1(new List<int>(), ver, species, form, maxLevel, minLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp2(int species, int form, int maxLevel, int minLevel, bool korean, bool removeNewGSCMoves, GameVersion ver = Any)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
var moves = AddMovesLevelUp2(new List<int>(), ver, species, form, maxLevel, minLevel, korean);
|
2018-06-15 01:52:43 +00:00
|
|
|
|
if (removeNewGSCMoves)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
moves.RemoveAll(m => m > MaxMoveID_1);
|
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp3(int species, int form, int maxLevel, GameVersion ver = Any)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp3(new List<int>(), ver, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp4(int species, int form, int maxLevel, GameVersion ver = Any)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp4(new List<int>(), ver, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp5(int species, int form, int maxLevel, GameVersion ver = Any)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp5(new List<int>(), ver, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp6(int species, int form, int maxLevel, GameVersion ver = Any)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp6(new List<int>(), ver, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp7(int species, int form, int maxLevel, bool MoveReminder, GameVersion ver = Any)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp7(new List<int>(), ver, species, form, maxLevel, MoveReminder);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> GetMovesLevelUp8(int species, int form, int maxLevel, GameVersion ver = Any)
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return AddMovesLevelUp8(new List<int>(), ver, species, form, maxLevel);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-18 04:54:04 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp1(List<int> moves, GameVersion ver, int species, int form, int max, int min)
|
2018-06-14 05:03:58 +00:00
|
|
|
|
{
|
2018-06-13 01:35:56 +00:00
|
|
|
|
switch (ver)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Any: case RBY:
|
2018-06-18 04:54:04 +00:00
|
|
|
|
LearnRB.AddMoves1(moves, species, form, max, min);
|
|
|
|
|
return LearnY.AddMoves1(moves, species, form, max, min);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case RD or BU or GN or RB:
|
2018-06-18 04:54:04 +00:00
|
|
|
|
return LearnRB.AddMoves1(moves, species, form, max, min);
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case YW:
|
2018-06-18 04:54:04 +00:00
|
|
|
|
return LearnY.AddMoves1(moves, species, form, max, min);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2018-06-18 04:54:04 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp2(List<int> moves, GameVersion ver, int species, int form, int max, int min, bool korean)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any: case GSC:
|
2018-06-18 04:54:04 +00:00
|
|
|
|
LearnGS.AddMoves(moves, species, form, max, min);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (korean)
|
|
|
|
|
return moves;
|
2018-06-18 04:54:04 +00:00
|
|
|
|
return LearnC.AddMoves(moves, species, form, max, min);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case GD or SV or GS:
|
2018-06-18 04:54:04 +00:00
|
|
|
|
return LearnGS.AddMoves(moves, species, form, max, min);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
case C when !korean:
|
2018-06-18 04:54:04 +00:00
|
|
|
|
return LearnC.AddMoves(moves, species, form, max, min);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
|
|
|
|
return moves;
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp3(List<int> moves, GameVersion ver, int species, int form, int maxLevel)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2019-12-09 01:39:19 +00:00
|
|
|
|
if (species == (int)Species.Deoxys)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-13 01:35:56 +00:00
|
|
|
|
var learn = GetDeoxysLearn3(form, ver);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
if (learn != null)
|
2021-07-23 04:25:15 +00:00
|
|
|
|
moves.AddRange(learn.GetMoves(maxLevel));
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return moves;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-14 05:03:58 +00:00
|
|
|
|
// Emerald level up tables are equal to R/S level up tables
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnRSE.AddMoves(moves, species, form, maxLevel);
|
|
|
|
|
return LearnFRLG.AddMoves(moves, species, form, maxLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case R or S or E or RS or RSE:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnRSE.AddMoves(moves, species, form, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case FR or LG or FRLG:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnFRLG.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp4(List<int> moves, GameVersion ver, int species, int form, int maxLevel)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any: case DPPt:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnDP.AddMoves(moves, species, form, maxLevel);
|
|
|
|
|
LearnPt.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (ver == DPPt) // stop here
|
|
|
|
|
return moves;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnHGSS.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case D or P or DP:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnDP.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
case Pt:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnPt.AddMoves(moves, species, form, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case HG or SS or HGSS:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnHGSS.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp5(List<int> moves, GameVersion ver, int species, int form, int maxLevel)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
2018-06-14 05:03:58 +00:00
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any:
|
2018-08-03 14:46:53 +00:00
|
|
|
|
if (species != 646) // Kyurem moves are same for both versions, but forme movepool not present.
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnBW.AddMoves(moves, species, form, maxLevel);
|
|
|
|
|
return LearnB2W2.AddMoves(moves, species, form, maxLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case B or W or BW:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnBW.AddMoves(moves, species, form, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case B2 or W2 or B2W2:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnB2W2.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp6(List<int> moves, GameVersion ver, int species, int form, int maxLevel)
|
2018-06-09 03:10:41 +00:00
|
|
|
|
{
|
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Any:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnXY.AddMoves(moves, species, form, maxLevel);
|
|
|
|
|
return LearnAO.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case X or Y or XY:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnXY.AddMoves(moves, species, form, maxLevel);
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case AS or OR or ORAS:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnAO.AddMoves(moves, species, form, maxLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp7(List<int> moves, GameVersion ver, int species, int form, int maxLevel, bool reminder)
|
2018-06-13 01:35:56 +00:00
|
|
|
|
{
|
2021-07-23 04:25:15 +00:00
|
|
|
|
if (reminder)
|
|
|
|
|
maxLevel = 100; // Move reminder can teach any level in movepool now!
|
2018-06-09 03:10:41 +00:00
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case GP or GE or GG or GO:
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnGG.AddMoves(moves, species, form, maxLevel);
|
2018-11-12 06:49:17 +00:00
|
|
|
|
|
2018-06-13 05:15:06 +00:00
|
|
|
|
case Any:
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (species > MaxSpeciesID_7_USUM)
|
|
|
|
|
return moves;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnUSUM.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (species > MaxSpeciesID_7)
|
|
|
|
|
return moves;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnSM.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case SN or MN or SM:
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (species > MaxSpeciesID_7)
|
|
|
|
|
return moves;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnSM.AddMoves(moves, species, form, maxLevel);
|
2018-06-14 05:03:58 +00:00
|
|
|
|
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case US or UM or USUM:
|
2018-06-14 05:03:58 +00:00
|
|
|
|
if (species > MaxSpeciesID_7_USUM)
|
|
|
|
|
return moves;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
LearnUSUM.AddMoves(moves, species, form, maxLevel);
|
2018-06-09 03:10:41 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return moves;
|
|
|
|
|
}
|
2018-06-11 00:55:03 +00:00
|
|
|
|
|
2021-07-23 04:25:15 +00:00
|
|
|
|
private static List<int> AddMovesLevelUp8(List<int> moves, GameVersion ver, int species, int form, int maxLevel)
|
2019-09-23 23:56:47 +00:00
|
|
|
|
{
|
2019-11-16 01:34:18 +00:00
|
|
|
|
// Move reminder can NOT teach any level like Gen7
|
2019-09-23 23:56:47 +00:00
|
|
|
|
switch (ver)
|
|
|
|
|
{
|
|
|
|
|
case Any:
|
2020-11-19 05:34:40 +00:00
|
|
|
|
case GO:
|
2020-12-25 18:58:33 +00:00
|
|
|
|
case SW or SH or SWSH:
|
2019-09-23 23:56:47 +00:00
|
|
|
|
if (species > MaxSpeciesID_8)
|
|
|
|
|
return moves;
|
2021-07-23 04:25:15 +00:00
|
|
|
|
return LearnSWSH.AddMoves(moves, species, form, maxLevel);
|
2019-09-23 23:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
return moves;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-11 00:55:03 +00:00
|
|
|
|
public static int[] GetEncounterMoves(PKM pk, int level, GameVersion version)
|
|
|
|
|
{
|
2018-06-18 03:49:03 +00:00
|
|
|
|
if (version <= 0)
|
|
|
|
|
version = (GameVersion)pk.Version;
|
2020-12-11 04:42:30 +00:00
|
|
|
|
return GetEncounterMoves(pk.Species, pk.Form, level, version);
|
2018-06-11 00:55:03 +00:00
|
|
|
|
}
|
2018-06-13 01:35:56 +00:00
|
|
|
|
|
|
|
|
|
private static int[] GetEncounterMoves1(int species, int level, GameVersion version)
|
|
|
|
|
{
|
|
|
|
|
var learn = GameData.GetLearnsets(version);
|
|
|
|
|
var table = GameData.GetPersonal(version);
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var index = table.GetFormIndex(species, 0);
|
2018-06-13 01:35:56 +00:00
|
|
|
|
var lvl0 = (int[])((PersonalInfoG1) table[index]).Moves.Clone();
|
2021-01-16 20:47:02 +00:00
|
|
|
|
int start = Math.Max(0, Array.IndexOf(lvl0, 0));
|
2018-06-13 01:35:56 +00:00
|
|
|
|
|
|
|
|
|
return learn[index].GetEncounterMoves(level, lvl0, start);
|
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2018-06-19 02:57:32 +00:00
|
|
|
|
private static int[] GetEncounterMoves2(int species, int level, GameVersion version)
|
|
|
|
|
{
|
|
|
|
|
var learn = GameData.GetLearnsets(version);
|
|
|
|
|
var table = GameData.GetPersonal(version);
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var index = table.GetFormIndex(species, 0);
|
2018-06-19 02:57:32 +00:00
|
|
|
|
var lvl0 = learn[species].GetEncounterMoves(1);
|
2021-01-16 20:47:02 +00:00
|
|
|
|
int start = Math.Max(0, Array.IndexOf(lvl0, 0));
|
2018-06-19 02:57:32 +00:00
|
|
|
|
|
|
|
|
|
return learn[index].GetEncounterMoves(level, lvl0, start);
|
|
|
|
|
}
|
2018-06-13 01:35:56 +00:00
|
|
|
|
|
2018-06-11 00:55:03 +00:00
|
|
|
|
public static int[] GetEncounterMoves(int species, int form, int level, GameVersion version)
|
|
|
|
|
{
|
2018-06-19 02:57:32 +00:00
|
|
|
|
if (RBY.Contains(version))
|
|
|
|
|
return GetEncounterMoves1(species, level, version);
|
|
|
|
|
if (GSC.Contains(version))
|
|
|
|
|
return GetEncounterMoves2(species, level, version);
|
2018-06-11 00:55:03 +00:00
|
|
|
|
var learn = GameData.GetLearnsets(version);
|
|
|
|
|
var table = GameData.GetPersonal(version);
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var index = table.GetFormIndex(species, form);
|
2018-06-11 00:55:03 +00:00
|
|
|
|
return learn[index].GetEncounterMoves(level);
|
|
|
|
|
}
|
2018-06-09 03:10:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|