The last commit was reverted because the change should not apply to base moves from was egg pokemon, unlike egg moves base level moves are not equal among all generations.

Also for generation 2 check if pokemon have crystal location for the was egg base moves
This commit is contained in:
javierhimura 2017-03-26 18:42:20 +02:00
parent b950879065
commit 59750b8cfe

View file

@ -2100,29 +2100,37 @@ namespace PKHeX.Core
return res; return res;
} }
private GameVersion[] getBaseMovesIsEggGames() private GameVersion[] getBaseGamesWasEggGen2()
{
if (pkm.Format != 2)
return new[] { GameVersion.GS, GameVersion.C };
if (pkm.HasOriginalMetLocation)
return new[] { GameVersion.C };
if (pkm.Species > 151 && !Legal.FutureEvolutionsGen1.Contains(pkm.Species))
return new[] { GameVersion.GS };
return new[] { GameVersion.GS, GameVersion.C };
}
private GameVersion getBaseGamesWasEgg()
{ {
GameVersion[] Games = { };
switch (pkm.GenNumber) switch (pkm.GenNumber)
{ {
case 1: case 1:
case 2: case 2:
Games = new[] { GameVersion.GS, GameVersion.C }; // Every egg move from Gold/Silver is included in Crystal
break; return GameVersion.C;
case 3: case 3:
switch((GameVersion)pkm.Version) switch ((GameVersion)pkm.Version)
{ {
case GameVersion.R: case GameVersion.R:
case GameVersion.S: case GameVersion.S:
Games = new[] { GameVersion.RS}; return GameVersion.RS;
break;
case GameVersion.E: case GameVersion.E:
Games = new[] { GameVersion.E }; return GameVersion.E;
break;
case GameVersion.FR: case GameVersion.FR:
case GameVersion.LG: case GameVersion.LG:
Games = new[] { GameVersion.FRLG }; return GameVersion.FRLG;
break;
} }
break; break;
case 4: case 4:
@ -2130,15 +2138,12 @@ namespace PKHeX.Core
{ {
case GameVersion.D: case GameVersion.D:
case GameVersion.P: case GameVersion.P:
Games = new[] { GameVersion.DP }; return GameVersion.DP;
break;
case GameVersion.Pt: case GameVersion.Pt:
Games = new[] { GameVersion.Pt }; return GameVersion.Pt;
break;
case GameVersion.HG: case GameVersion.HG:
case GameVersion.SS: case GameVersion.SS:
Games = new[] { GameVersion.HGSS }; return GameVersion.HGSS;
break;
} }
break; break;
case 5: case 5:
@ -2146,54 +2151,46 @@ namespace PKHeX.Core
{ {
case GameVersion.B: case GameVersion.B:
case GameVersion.W: case GameVersion.W:
Games = new[] { GameVersion.BW }; return GameVersion.BW;
break;
case GameVersion.Pt:
Games = new[] { GameVersion.Pt };
break;
case GameVersion.B2: case GameVersion.B2:
case GameVersion.W2: case GameVersion.W2:
Games = new[] { GameVersion.B2W2 }; return GameVersion.B2W2;
break;
} }
break; break;
} }
return Games; return GameVersion.Any;
} }
private CheckResult[] verifyMovesIsEggPreRelearn(int[] Moves, int[] SpecialMoves, bool allowinherited) private CheckResult[] verifyMovesIsEggPreRelearn(int[] Moves, int[] SpecialMoves, bool allowinherited)
{ {
CheckResult[] res = new CheckResult[4]; CheckResult[] res = new CheckResult[4];
var ValidSpecialMoves = SpecialMoves.Where(m => m > 0); var ValidSpecialMoves = SpecialMoves.Where(m => m > 0);
// Some games can have different egg movepools. Have to check all situations. // Some games can have different egg movepools. Have to check all situations.
GameVersion[] Games = getBaseMovesIsEggGames(); GameVersion ver = getBaseGamesWasEgg();
int splitctr = Legal.getSplitBreedGeneration(pkm).Contains(pkm.Species) ? 1 : 0; int splitctr = Legal.getSplitBreedGeneration(pkm).Contains(pkm.Species) ? 1 : 0;
foreach (var ver in Games) for (int i = 0; i <= splitctr; i++)
{ {
for (int i = 0; i <= splitctr; i++) var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List<int>();
{ var InheritedLvlMoves = Legal.getBaseEggMoves(pkm, i, ver, 100) ?? new List<int>();
var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, pkm.GenNumber < 4 ? 5 : 1)?.ToList() ?? new List<int>(); var EggMoves = Legal.getEggMoves(pkm, ver)?.ToList() ?? new List<int>();
var InheritedLvlMoves = Legal.getBaseEggMoves(pkm, i, ver, 100) ?? new List<int>(); var InheritedTutorMoves = (ver == GameVersion.C) ? Legal.getTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2) : new int[0];
var EggMoves = Legal.getEggMoves(pkm, ver)?.ToList() ?? new List<int>(); // Only TM Hm moves from the source game of the egg, not any other games from the same generation
var InheritedTutorMoves = (ver == GameVersion.C) ? Legal.getTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2) : new int[0]; var InheritedTMHMMoves = Legal.getTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, ver, false);
// Only TM Hm moves from the source game of the egg, not any other games from the same generation InheritedLvlMoves = InheritedLvlMoves.Except(baseEggMoves);
var InheritedTMHMMoves = Legal.getTMHM(pkm, pkm.Species, pkm.AltForm, pkm.GenNumber, ver, false);
InheritedLvlMoves = InheritedLvlMoves.Except(baseEggMoves);
if (pkm.Format > 2 || SpecialMoves.Any()) if (pkm.Format > 2 || SpecialMoves.Any())
{ {
// For gen 2 is not possible to difference normal eggs from event eggs // For gen 2 is not possible to difference normal eggs from event eggs
// If there is no special moves assume normal egg // If there is no special moves assume normal egg
res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, InheritedLvlMoves, InheritedTMHMMoves, InheritedTutorMoves, ValidSpecialMoves, allowinherited, ver); res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, InheritedLvlMoves, InheritedTMHMMoves, InheritedTutorMoves, ValidSpecialMoves, allowinherited, ver);
if (res.All(r => r.Valid)) // moves is satisfactory if (res.All(r => r.Valid)) // moves is satisfactory
return res; return res;
} }
if(pkm.Format == 2) if(pkm.Format == 2)
{ {
// For gen 2 if does not match special egg check for normal egg too // For gen 2 if does not match special egg check for normal egg too
res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, InheritedLvlMoves, InheritedTMHMMoves, InheritedTutorMoves, new List<int>(), true, ver); res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, InheritedLvlMoves, InheritedTMHMMoves, InheritedTutorMoves, new List<int>(), true, ver);
if (res.All(r => r.Valid)) // moves is satisfactory if (res.All(r => r.Valid)) // moves is satisfactory
return res; return res;
}
} }
} }
return res; return res;
@ -2208,10 +2205,10 @@ namespace PKHeX.Core
{ {
case 1: case 1:
case 2: case 2:
Games = new[] { GameVersion.GS, GameVersion.C }; Games = getBaseGamesWasEggGen2();
break; break;
case 3: // Generation 3 does not overwrite source game after pokemon hatched case 3: // Generation 3 does not overwrite source game after pokemon hatched
Games = getBaseMovesIsEggGames(); Games = new[] { getBaseGamesWasEgg() };
break; break;
case 4: case 4:
Games = new[] { GameVersion.DP, GameVersion.Pt, GameVersion.HGSS }; Games = new[] { GameVersion.DP, GameVersion.Pt, GameVersion.HGSS };