mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-26 14:45:36 -05:00
Handle g4 shedinja learn case too
change 291/292 to Shedinja/Ninjask for easy enum reference check
This commit is contained in:
@@ -112,27 +112,19 @@ internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, int form,
|
||||
return r.Distinct();
|
||||
}
|
||||
|
||||
internal static int[] GetShedinjaEvolveMoves(PKM pkm, int generation, int lvl = -1)
|
||||
internal static int[] GetShedinjaEvolveMoves(PKM pkm, int generation, int lvl)
|
||||
{
|
||||
if (lvl == -1)
|
||||
lvl = pkm.CurrentLevel;
|
||||
if (pkm.Species != 292 || lvl < 20)
|
||||
if (pkm.Species != (int)Species.Shedinja || lvl < 20)
|
||||
return Array.Empty<int>();
|
||||
|
||||
// If nincada evolves into Ninjask an learn in the evolution a move from ninjask learnset pool
|
||||
// Shedinja would appear with that move learned. Only one move above level 20 allowed, only in generations 3 and 4
|
||||
switch (generation)
|
||||
// If Nincada evolves into Ninjask and learns a move after evolution from Ninjask's LevelUp data, Shedinja would appear with that move.
|
||||
// Only one move above level 20 is allowed; check the count of Ninjask moves elsewhere.
|
||||
return generation switch
|
||||
{
|
||||
case 3: // Ninjask have the same learnset in every gen 3 games
|
||||
if (pkm.InhabitedGeneration(3))
|
||||
return LevelUpE[291].GetMoves(lvl, 20);
|
||||
break;
|
||||
case 4: // Ninjask have the same learnset in every gen 4 games
|
||||
if (pkm.InhabitedGeneration(4))
|
||||
return LevelUpPt[291].GetMoves(lvl, 20);
|
||||
break;
|
||||
}
|
||||
return Array.Empty<int>();
|
||||
3 when pkm.InhabitedGeneration(3) => LevelUpE[(int)Species.Ninjask].GetMoves(lvl, 20), // Same LevelUp data in all Gen3 games
|
||||
4 when pkm.InhabitedGeneration(4) => LevelUpPt[(int)Species.Ninjask].GetMoves(lvl, 20), // Same LevelUp data in all Gen4 games
|
||||
_ => Array.Empty<int>(),
|
||||
};
|
||||
}
|
||||
|
||||
internal static int GetShedinjaMoveLevel(int species, int move, int generation)
|
||||
|
||||
@@ -143,15 +143,17 @@ private static IEnumerable<int> GetMovesForGeneration(PKM pk, IReadOnlyList<EvoC
|
||||
// Any egg move can be obtained
|
||||
var evo = dl[dl.Count - 1];
|
||||
var shared = MoveEgg.GetEggMoves(pk, evo.Species, evo.Form, GameVersion.SW);
|
||||
moves = moves.Concat(shared);
|
||||
return moves.Concat(shared);
|
||||
}
|
||||
if (generation == 3 && dl[0].Species == (int)Species.Shedinja)
|
||||
if (dl[0].Species == (int)Species.Shedinja)
|
||||
{
|
||||
// Leveling up Nincada in Gen3 levels up, evolves to Ninjask, applies moves for Ninjask, then spawns Shedinja with the current moveset.
|
||||
// Leveling up Nincada in Gen3/4 levels up, evolves to Ninjask, applies moves for Ninjask, then spawns Shedinja with the current moveset.
|
||||
// Future games spawn the Shedinja before doing Ninjask moves, so this is a special case.
|
||||
// Can't get more than the evolved-at level move; >=2 special moves will get caught by the legality checker later.
|
||||
var ninjask = MoveLevelUp.GetMovesLevelUp(pk, (int)Species.Ninjask, 0, 0, 100, 0, GameVersion.Any, false, 3);
|
||||
moves = moves.Concat(ninjask);
|
||||
if (generation == 3)
|
||||
return moves.Concat(Legal.LevelUpE[(int)Species.Ninjask].GetMoves(100, 20));
|
||||
if (generation == 4)
|
||||
return moves.Concat(Legal.LevelUpPt[(int)Species.Ninjask].GetMoves(100, 20));
|
||||
}
|
||||
return moves;
|
||||
}
|
||||
|
||||
@@ -596,7 +596,8 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList<CheckMoveResult> res
|
||||
var ShedinjaEvoMovesLearned = new List<int>();
|
||||
for (int gen = Math.Min(pkm.Format, 4); gen >= 3; gen--)
|
||||
{
|
||||
var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, gen);
|
||||
var maxLevel = pkm.CurrentLevel;
|
||||
var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, gen, maxLevel);
|
||||
bool native = gen == pkm.Format;
|
||||
for (int m = 0; m < 4; m++)
|
||||
{
|
||||
@@ -625,7 +626,7 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList<CheckMoveResult> res
|
||||
// Double check that the Ninjask move level isn't less than any Nincada move level
|
||||
int move = ShedinjaEvoMovesLearned[0];
|
||||
int g = res[move].Generation;
|
||||
int levelJ = Legal.GetShedinjaMoveLevel(291, moves[move], g);
|
||||
int levelJ = Legal.GetShedinjaMoveLevel((int)Species.Ninjask, moves[move], g);
|
||||
|
||||
for (int m = 0; m < 4; m++)
|
||||
{
|
||||
@@ -633,13 +634,13 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList<CheckMoveResult> res
|
||||
continue;
|
||||
if (res[m].Source != LevelUp)
|
||||
continue;
|
||||
int levelS = Legal.GetShedinjaMoveLevel(292, moves[m], res[m].Generation);
|
||||
int levelS = Legal.GetShedinjaMoveLevel((int)Species.Shedinja, moves[m], res[m].Generation);
|
||||
if (levelS > 0)
|
||||
continue;
|
||||
|
||||
int levelN = Legal.GetShedinjaMoveLevel(290, moves[m], res[m].Generation);
|
||||
int levelN = Legal.GetShedinjaMoveLevel((int)Species.Nincada, moves[m], res[m].Generation);
|
||||
if (levelN > levelJ)
|
||||
res[m] = new CheckMoveResult(res[m], Invalid, string.Format(LMoveEvoFHigher, SpeciesStrings[290], SpeciesStrings[291]), Move);
|
||||
res[m] = new CheckMoveResult(res[m], Invalid, string.Format(LMoveEvoFHigher, SpeciesStrings[(int)Species.Nincada], SpeciesStrings[(int)Species.Ninjask]), Move);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user