Fix egg moves pre-gen 6 validation:

Add skipoption variable to getEggMoves function from pre-gen6 games, to verify egg moves from split breed species
Flag illegal combinations of base egg moves and special egg moves
Return crystal egg moves for gen2 pokemon that can be tradeback to gen 1 games
This commit is contained in:
javierhimura 2017-03-31 12:32:36 +02:00
parent 9c123da144
commit 4aa6accc7d
4 changed files with 25 additions and 16 deletions

View file

@ -2262,7 +2262,7 @@ namespace PKHeX.Core
else if (EventGiftMatch?.Count > 1) // Multiple possible Mystery Gifts matched, get the best match too
res = parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor);
else // Everything else
res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, new int[0], game);
res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, new int[0], 0, game);
// Duplicate Moves Check
verifyNoEmptyDuplicates(Moves, res);
@ -2344,7 +2344,7 @@ namespace PKHeX.Core
{
var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List<int>();
var InheritedLvlMoves = Legal.getBaseEggMoves(pkm, i, ver, 100)?.ToList() ?? new List<int>();
var EggMoves = Legal.getEggMoves(pkm, ver)?.ToList() ?? new List<int>();
var EggMoves = Legal.getEggMoves(pkm, i, ver)?.ToList() ?? new List<int>();
var InheritedTutorMoves = ver == GameVersion.C ? Legal.getTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2)?.ToList() : new List<int>();
// Only TM Hm moves from the source game of the egg, not any other games from the same generation
var InheritedTMHMMoves = Legal.getTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, ver, false)?.ToList();
@ -2378,7 +2378,7 @@ namespace PKHeX.Core
if (EventGiftMatch?.Count > 1) // Multiple possible Mystery Gifts matched, get the best match too
res = parseMovesGetGift(Moves, validLevelMoves, validTMHM, validTutor);
else // Everything else
res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, new int[0], GameVersion.Any);
res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, new int[0], 0, GameVersion.Any);
if (res.All(r => r.Valid)) // moves is satisfactory
return res;
}
@ -2407,7 +2407,7 @@ namespace PKHeX.Core
for (int i = 0; i <= splitctr; i++)
{
var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, 100)?.ToArray() ?? new int[0];
res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, baseEggMoves, ver);
res = parseMovesRegular(Moves, validLevelMoves, validTMHM, validTutor, baseEggMoves, i, ver);
if (res.All(r => r.Valid)) // moves is satisfactory
return res;
}
@ -2458,9 +2458,9 @@ namespace PKHeX.Core
// no Mystery Gifts matched
return parseMoves(Moves, validLevelMoves, RelearnMoves, validTMHM, validTutor, new int[0], new int[0], new int[0], new int[0]);
}
private CheckResult[] parseMovesRegular(int[] Moves, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor, int[] baseEggMoves, GameVersion game)
private CheckResult[] parseMovesRegular(int[] Moves, List<int>[] validLevelMoves, List<int>[] validTMHM, List<int>[] validTutor, int[] baseEggMoves, int SkipOption, GameVersion game)
{
int[] EggMoves = pkm.WasEgg ? Legal.getEggMoves(pkm, game).ToArray() : new int[0];
int[] EggMoves = pkm.WasEgg ? Legal.getEggMoves(pkm, SkipOption, game).ToArray() : new int[0];
int[] EventEggMoves = pkm.WasEgg ? Legal.getSpecialEggMoves(pkm, game).ToArray() : new int[0];
int[] RelearnMoves = pkm.RelearnMoves;
int[] SpecialMoves = (EncounterMatch as MysteryGift)?.Moves ??
@ -2555,10 +2555,11 @@ namespace PKHeX.Core
}
else
res[m] = new CheckResult(Severity.Valid, V345, CheckIdentifier.Move);
EggMovesLearned.Add(m);
}
}
// Check egg moves after all the generations and all the moves, every move that can be learned in another source should have preference
// Check egg moves after all the generations and all the moves, every move that can't be learned in another source should have preference
// the moves that can only be learned from egg moves should in the future check if the move combinations can be breed in gens 2 to 5
for (int m = 0; m < 4; m++)
{
@ -2568,7 +2569,7 @@ namespace PKHeX.Core
{
if (IsGen2Pkm && Gen1MovesLearned.Any() && moves[m] > Legal.MaxMoveID_1)
{
// To learn exclusive generation 1 moves the pokemon was tradeback, but it can be trade to generation 1
// To learn exclusive generation 1 moves the pokemon was tradeback, but it can't be trade to generation 1
// without removing moves above MaxMoveID_1, egg moves above MaxMoveID_1 and gen 1 moves are incompatible
res[m] = new CheckResult(Severity.Invalid, V334, CheckIdentifier.Move) { Flag = true };
MixedGen1NonTradebackGen2 = true;
@ -2588,7 +2589,7 @@ namespace PKHeX.Core
MixedGen1NonTradebackGen2 = true;
}
else
res[m] = new CheckResult(Severity.Valid, V33, CheckIdentifier.Move) { Flag = true };
res[m] = new CheckResult(Severity.Valid, V333, CheckIdentifier.Move) { Flag = true };
}
EventEggMovesLearned.Add(m);
}
@ -2603,10 +2604,15 @@ namespace PKHeX.Core
{
foreach(int m in IncompatibleEggMoves)
{
if (!EventEggMovesLearned.Contains(m) && !EggMovesLearned.Contains(m))
if (EventEggMovesLearned.Contains(m) && !EggMovesLearned.Contains(m))
res[m] = new CheckResult(Severity.Invalid, V337, CheckIdentifier.Move);
else if (!EventEggMovesLearned.Contains(m) && EggMovesLearned.Contains(m))
res[m] = new CheckResult(Severity.Invalid, V336, CheckIdentifier.Move);
{
if (egg.Contains(moves[m]))
res[m] = new CheckResult(Severity.Invalid, V336, CheckIdentifier.Move);
else // base egg move
res[m] = new CheckResult(Severity.Invalid, V358, CheckIdentifier.Move);
}
}
}
}

View file

@ -834,9 +834,9 @@ namespace PKHeX.Core
}
return null;
}
internal static IEnumerable<int> getEggMoves(PKM pkm, GameVersion Version)
internal static IEnumerable<int> getEggMoves(PKM pkm, int skipOption, GameVersion Version)
{
return getEggMoves(pkm, getBaseSpecies(pkm), 0, Version);
return getEggMoves(pkm, getBaseSpecies(pkm, skipOption), 0, Version);
}
internal static IEnumerable<int> getSpecialEggMoves(PKM pkm, GameVersion Version)
@ -2626,7 +2626,7 @@ namespace PKHeX.Core
return EggMovesC[species].Moves;
if (pkm.Species > 151 && !FutureEvolutionsGen1.Contains(pkm.Species))
return EggMovesGS[species].Moves;
return new List<int>();
return EggMovesC[species].Moves;
case 3:
return EggMovesRS[species].Moves;
case 4:

View file

@ -343,6 +343,7 @@ namespace PKHeX.Core
public static string V353 {get; set;} = "Non japanese Mew from Faraway Island. Unreleased event.";
public static string V354 {get; set;} = "Non Platinum Shaymin from Flower Paradise. Unreleased event.";
public static string V357 {get; set;} = "Only one Ninjask move allowed.";
public static string V358 {get; set;} = "Inherited move learned by Level-up. Incompatible with event egg moves.";
#endregion
}

View file

@ -278,3 +278,5 @@ V352 = Arceus from Hall of Origin. Unreleased event.
V353 = Non japanese Mew from Faraway Island. Unreleased event.
V354 = Non Platinum Shaymin from Flower Paradise. Unreleased event.
V357 = Only one Ninjask move allowed.
V358 = Inherited move learned by Level-up. Incompatible with event egg moves.