mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-08 12:05:35 -05:00
Update shedinja ninjask move checks
check level of source moves for any incompatibility in non-bred cases. Closes #1805
This commit is contained in:
@@ -436,16 +436,12 @@ internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, bool inhe
|
||||
r.AddRange(GetRelearnLVLMoves(pkm, species, 100, pkm.AltForm, version));
|
||||
return r.Distinct();
|
||||
}
|
||||
internal static List<int>[] GetShedinjaEvolveMoves(PKM pkm, int lvl = -1, int generation = 0)
|
||||
internal static IList<int> GetShedinjaEvolveMoves(PKM pkm, int lvl = -1, int generation = 0)
|
||||
{
|
||||
var size = pkm.Format > 3 ? 4 : 3;
|
||||
List<int>[] r = new List<int>[size + 1];
|
||||
for (int i = 1; i <= size; i++)
|
||||
r[i] = new List<int>();
|
||||
if (lvl == -1)
|
||||
lvl = pkm.CurrentLevel;
|
||||
if (pkm.Species != 292 || lvl < 20)
|
||||
return r;
|
||||
return new List<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
|
||||
@@ -454,17 +450,23 @@ internal static List<int>[] GetShedinjaEvolveMoves(PKM pkm, int lvl = -1, int ge
|
||||
case 0: // Default (both)
|
||||
case 3: // Ninjask have the same learnset in every gen 3 games
|
||||
if (pkm.InhabitedGeneration(3))
|
||||
r[3] = LevelUpE[291].GetMoves(lvl, 20).ToList();
|
||||
return LevelUpE[291].GetMoves(lvl, 20).ToList();
|
||||
|
||||
if (generation == 0)
|
||||
goto case 4;
|
||||
break;
|
||||
case 4: // Ninjask have the same learnset in every gen 4 games
|
||||
if (pkm.InhabitedGeneration(4))
|
||||
r[4] = LevelUpPt[291].GetMoves(lvl, 20).ToList();
|
||||
return LevelUpPt[291].GetMoves(lvl, 20);
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
return new List<int>();
|
||||
}
|
||||
internal static int GetShedinjaMoveLevel(int species, int move, int generation)
|
||||
{
|
||||
var src = generation == 4 ? LevelUpPt : LevelUpE;
|
||||
var moves = src[species];
|
||||
return moves.GetLevelLearnMove(move);
|
||||
}
|
||||
internal static int[] GetBaseEggMoves(PKM pkm, int species, GameVersion gameSource, int lvl)
|
||||
{
|
||||
|
||||
@@ -244,11 +244,12 @@ private static CheckMoveResult[] ParseMoves(PKM pkm, MoveParseSource source, Leg
|
||||
return res;
|
||||
}
|
||||
|
||||
if (pkm.Species == 292 && info.EncounterMatch.Species != 292)
|
||||
if (pkm.Species == 292 && info.EncounterMatch.Species != 292 && !(info.EncounterMatch is EncounterEgg))
|
||||
{
|
||||
// Ignore Shedinja if the Encounter was also a Shedinja, assume null Encounter as a Nincada egg
|
||||
// Check Shedinja evolved moves from Ninjask after egg moves
|
||||
// Those moves could also be inherited egg moves
|
||||
if (info.Generation <= 4) // 3 or 4
|
||||
ParseShedinjaEvolveMoves(pkm, res, source.CurrentMoves);
|
||||
}
|
||||
|
||||
@@ -545,17 +546,17 @@ private static void ParseEvolutionsIncompatibleMoves(PKM pkm, IList<CheckMoveRes
|
||||
}
|
||||
private static void ParseShedinjaEvolveMoves(PKM pkm, IList<CheckMoveResult> res, int[] moves)
|
||||
{
|
||||
List<int>[] ShedinjaEvoMoves = Legal.GetShedinjaEvolveMoves(pkm);
|
||||
var ShedinjaEvoMovesLearned = new List<int>();
|
||||
for (int gen = Math.Min(pkm.Format, 4); gen >= 3; gen--)
|
||||
{
|
||||
var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, generation: gen);
|
||||
bool native = gen == pkm.Format;
|
||||
for (int m = 0; m < 4; m++)
|
||||
{
|
||||
if (IsCheckValid(res[m])) // already validated
|
||||
continue;
|
||||
|
||||
if (!ShedinjaEvoMoves[gen].Contains(moves[m]))
|
||||
if (!ninjaskMoves.Contains(moves[m]))
|
||||
continue;
|
||||
|
||||
res[m] = new CheckMoveResult(MoveSource.ShedinjaEvo, gen, Severity.Valid, native ? V355 : string.Format(V356, gen), CheckIdentifier.Move);
|
||||
@@ -563,11 +564,33 @@ private static void ParseShedinjaEvolveMoves(PKM pkm, IList<CheckMoveResult> res
|
||||
}
|
||||
}
|
||||
|
||||
if (ShedinjaEvoMovesLearned.Count <= 1)
|
||||
if (ShedinjaEvoMovesLearned.Count > 1)
|
||||
{
|
||||
// Can't have more than one Ninjask exclusive move on Shedinja
|
||||
foreach (int m in ShedinjaEvoMovesLearned)
|
||||
res[m] = new CheckMoveResult(res[m], Severity.Invalid, V357, CheckIdentifier.Move);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (int m in ShedinjaEvoMovesLearned)
|
||||
res[m] = new CheckMoveResult(res[m], Severity.Invalid, V357, CheckIdentifier.Move);
|
||||
// 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);
|
||||
|
||||
for (int m = 0; m < 4; m++)
|
||||
{
|
||||
if (m == move)
|
||||
continue;
|
||||
if (res[m].Source != MoveSource.LevelUp)
|
||||
continue;
|
||||
int levelS = Legal.GetShedinjaMoveLevel(292, moves[m], res[m].Generation);
|
||||
if (levelS > 0)
|
||||
continue;
|
||||
|
||||
int levelN = Legal.GetShedinjaMoveLevel(290, moves[m], res[m].Generation);
|
||||
if (levelN > levelJ)
|
||||
res[m] = new CheckMoveResult(res[m], Severity.Invalid, string.Format(V366, SpeciesStrings[290], SpeciesStrings[291]), CheckIdentifier.Move);
|
||||
}
|
||||
}
|
||||
private static void ParseEvolutionLevelupMove(PKM pkm, IList<CheckMoveResult> res, int[] moves, List<int> IncenseMovesLearned, LegalInfo info)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user