Base egg moves are not only moves from hatched level ( 5 in gen 2 and 3, 1 in gen 4 and 5)

Included level up moves learned above hatched level that can be inherited from parents, unlike base egg moves this moves are optional
Added to eggs machine moves and crytal tutor moves, it can be inherited too
This commit is contained in:
javierhimura 2017-03-26 17:07:36 +02:00
parent ff6b6c5026
commit 62b6f2c98d
3 changed files with 153 additions and 21 deletions

View file

@ -2168,20 +2168,26 @@ namespace PKHeX.Core
{
for (int i = 0; i <= splitctr; i++)
{
var baseEggMoves = Legal.getBaseEggMoves(pkm, i, ver, 100)?.ToArray() ?? new int[0];
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 EggMoves = Legal.getEggMoves(pkm, ver)?.ToList() ?? new List<int>();
if(pkm.Format > 2 || SpecialMoves.Any())
var InheritedTutorMoves = (ver == GameVersion.C) ? Legal.getTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2) : new int[0];
// 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);
InheritedLvlMoves = InheritedLvlMoves.Except(baseEggMoves);
if (pkm.Format > 2 || SpecialMoves.Any())
{
// For gen 2 is not possible to difference normal eggs from event eggs
// If there is no special moves assume normal egg
res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, SpecialMoves, allowinherited, ver);
res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, InheritedLvlMoves, InheritedTMHMMoves, InheritedTutorMoves, SpecialMoves, allowinherited, ver);
if (res.All(r => r.Valid)) // moves is satisfactory
return res;
}
if(pkm.Format == 2)
{
// For gen 2 if does not match special egg check for normal egg too
res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, new int[0], true, ver);
res = verifyPreRelearnEggBase(Moves, baseEggMoves, EggMoves, InheritedLvlMoves, InheritedTMHMMoves, InheritedTutorMoves, new int[0], true, ver);
if (res.All(r => r.Valid)) // moves is satisfactory
return res;
}
@ -2620,33 +2626,32 @@ namespace PKHeX.Core
/* Similar to verifyRelearnEgg but in pre relearn generation is the moves what should match the expected order
but only if the pokemon is inside an egg */
private CheckResult[] verifyPreRelearnEggBase(int[] Moves, int[] baseMoves, List<int> eggmoves,int[] specialmoves, bool AllowInherited, GameVersion ver)
private CheckResult[] verifyPreRelearnEggBase(int[] Moves, List<int> baseMoves, List<int> eggmoves, IEnumerable<int> lvlmoves, IEnumerable<int> tmhmmoves, IEnumerable<int> tutormoves, int[] specialmoves, bool AllowInherited, GameVersion ver)
{
CheckResult[] res = new CheckResult[4];
// Obtain level1 moves
int baseCt = baseMoves.Length;
int baseCt = baseMoves.Count;
if (baseCt > 4) baseCt = 4;
// Obtain Inherited moves
var inherited = Moves.Where(m => m != 0 && (!baseMoves.Contains(m) || eggmoves.Contains(m))).ToList();
int inheritCt = inherited.Distinct().Count();
var inherited = Moves.Where(m => m != 0 && (!baseMoves.Contains(m) || specialmoves.Contains(m) || eggmoves.Contains(m) || lvlmoves.Contains(m) || tmhmmoves.Contains(m) || tutormoves.Contains(m))).ToList();
int inheritCt = inherited.Count;
// Get required amount of base moves
int unique = baseMoves.Concat(inherited).Distinct().Count();
int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt;
if (Moves.Where(m => m != 0).Count() < Math.Min(4, baseMoves.Length))
if (Moves.Where(m => m != 0).Count() < Math.Min(4, baseMoves.Count))
reqBase = Math.Min(4, unique);
reqBase = reqBase + specialmoves.Length > 4 ? reqBase - specialmoves.Length : reqBase;
var em = string.Empty;
var moveoffset = 0;
// Check if the required amount of Base Egg Moves are present.
for (int i = 0; i < reqBase; i++)
for (int i = moveoffset; i < reqBase; i++)
{
if (baseMoves.Contains(Moves[i]))
res[i] = new CheckResult(Severity.Valid, V179, CheckIdentifier.Move);
else if (specialmoves.Length > 0)
else if (specialmoves.Length == 0)
{
// mark remaining base egg moves missing
for (int z = i; z < reqBase; z++)
@ -2657,9 +2662,11 @@ namespace PKHeX.Core
break;
}
}
moveoffset += reqBase;
// Check also if the required amount of Special Egg Moves are present, ir are after base moves
for (int i = reqBase; i < specialmoves.Length; i++)
for (int i = moveoffset; i < moveoffset + specialmoves.Length; i++)
{
if (specialmoves.Contains(Moves[i]))
res[i] = new CheckResult(Severity.Valid, V333, CheckIdentifier.Move);
@ -2678,18 +2685,23 @@ namespace PKHeX.Core
if(!string.IsNullOrEmpty(em))
res[reqBase > 0 ? reqBase - 1 : 0].Comment += string.Format(Environment.NewLine + V343, em);
// Non-Base moves that can magically appear in the regular movepool
if (Legal.LightBall.Contains(pkm.Species))
if (pkm.GenNumber >=3 && Legal.LightBall.Contains(pkm.Species))
eggmoves.Add(344);
// Inherited moves appear after the required base moves.
var AllowInheritedSeverity = AllowInherited ? Severity.Valid : Severity.Invalid;
for (int i = reqBase + specialmoves.Length; i < 4; i++)
{
if (Moves[i] == 0) // empty
res[i] = new CheckResult(Severity.Valid, V167, CheckIdentifier.Move);
else if (AllowInherited && eggmoves.Contains(Moves[i])) // inherited
res[i] = new CheckResult(Severity.Valid, V171, CheckIdentifier.Move);
else if (!AllowInherited && eggmoves.Contains(Moves[i])) // inherited in event/gift pokemon
res[i] = new CheckResult(Severity.Invalid, V341, CheckIdentifier.Move);
else if (eggmoves.Contains(Moves[i])) // inherited egg move
res[i] = new CheckResult(AllowInheritedSeverity, AllowInherited ? V344 : V341, CheckIdentifier.Move);
else if (lvlmoves.Contains(Moves[i])) // inherited lvl moves
res[i] = new CheckResult(AllowInheritedSeverity, AllowInherited ? V345 : V347, CheckIdentifier.Move);
else if (tmhmmoves.Contains(Moves[i])) // inherited TMHM moves
res[i] = new CheckResult(AllowInheritedSeverity, AllowInherited ? V349 : V350, CheckIdentifier.Move);
else if (tutormoves.Contains(Moves[i])) // inherited tutor moves
res[i] = new CheckResult(AllowInheritedSeverity, AllowInherited ? V346 : V348, CheckIdentifier.Move);
else // not inheritable, flag
res[i] = new CheckResult(Severity.Invalid, V340, CheckIdentifier.Move);
}

View file

@ -2516,7 +2516,120 @@ namespace PKHeX.Core
return new List<int>();
}
}
private static IEnumerable<int> getTutorMoves(PKM pkm, int species, int form, bool specialTutors, int generation)
internal static IEnumerable<int> getTMHM(PKM pkm, int species, int form, int generation, GameVersion Version = GameVersion.Any, bool RemoveTransferHM = true)
{
List<int> moves = new List<int>();
int index;
switch (generation)
{
case 1:
index = PersonalTable.RB.getFormeIndex(species, 0);
if (index == 0)
return moves;
var pi_rb = (PersonalInfoG1)PersonalTable.RB[index];
var pi_y = (PersonalInfoG1)PersonalTable.Y[index];
moves.AddRange(TMHM_RBY.Where((t, m) => pi_rb.TMHM[m]));
moves.AddRange(TMHM_RBY.Where((t, m) => pi_y.TMHM[m]));
break;
case 2:
index = PersonalTable.C.getFormeIndex(species, 0);
if (index == 0)
return moves;
var pi_c = (PersonalInfoG2)PersonalTable.C[index];
moves.AddRange(TMHM_GSC.Where((t, m) => pi_c.TMHM[m]));
if (Version == GameVersion.Any)
goto case 1;
break;
case 3:
index = PersonalTable.E.getFormeIndex(species, 0);
var pi_e = PersonalTable.E[index];
moves.AddRange(TM_3.Where((t, m) => pi_e.TMHM[m]));
if (!RemoveTransferHM || pkm.Format == 3) // HM moves must be removed for 3->4, only give if current format.
moves.AddRange(HM_3.Where((t, m) => pi_e.TMHM[m + 50]));
break;
case 4:
index = PersonalTable.HGSS.getFormeIndex(species, 0);
if (index == 0)
return moves;
var pi_hgss = PersonalTable.HGSS[index];
var pi_dppt = PersonalTable.Pt[index];
moves.AddRange(TM_4.Where((t, m) => pi_hgss.TMHM[m]));
// The combination of both these moves is illegal, it should be checked that the pokemon only learn one
// except if it can learn any of these moves in gen 5 or later
if (Version == GameVersion.Any || Version == GameVersion.DP || Version == GameVersion.D || Version == GameVersion.P || Version == GameVersion.Pt)
{
if (RemoveTransferHM && pkm.Format > 4)
{
if (pi_dppt.TMHM[96])
moves.Add(432); // Defog
}
else
{
moves.AddRange(HM_DPPt.Where((t, m) => pi_dppt.TMHM[m + 92]));
}
}
if (Version == GameVersion.Any || Version == GameVersion.HGSS || Version == GameVersion.HG || Version == GameVersion.SS)
{
if (RemoveTransferHM && pkm.Format > 4)
{
if (pi_hgss.TMHM[96])
moves.Add(432); // Defog
}
else
{
moves.AddRange(HM_HGSS.Where((t, m) => pi_dppt.TMHM[m + 92]));
}
}
break;
case 5:
index = PersonalTable.B2W2.getFormeIndex(species, 0);
if (index == 0)
return moves;
var pi_bw = PersonalTable.B2W2[index];
moves.AddRange(TMHM_BW.Where((t, m) => pi_bw.TMHM[m]));
break;
case 6:
switch (Version)
{
case GameVersion.Any: // Start at the top, hit every table
case GameVersion.X:
case GameVersion.Y:
case GameVersion.XY:
{
index = PersonalTable.XY.getFormeIndex(species, form);
if (index == 0)
return moves;
PersonalInfo pi_xy = PersonalTable.XY[index];
moves.AddRange(TMHM_XY.Where((t, m) => pi_xy.TMHM[m]));
if (Version == GameVersion.Any) // Fall Through
goto case GameVersion.ORAS;
break;
}
case GameVersion.AS:
case GameVersion.OR:
case GameVersion.ORAS:
{
index = PersonalTable.AO.getFormeIndex(species, form);
if (index == 0)
return moves;
PersonalInfo pi_oras = PersonalTable.AO[index];
moves.AddRange(TMHM_AO.Where((t, m) => pi_oras.TMHM[m]));
break;
}
}
break;
case 7:
index = PersonalTable.SM.getFormeIndex(species, form);
PersonalInfo pi_sm = PersonalTable.SM.getFormeEntry(species, form);
moves.AddRange(TMHM_SM.Where((t, m) => pi_sm.TMHM[m]));
break;
}
return moves.Distinct();
}
internal static IEnumerable<int> getTutorMoves(PKM pkm, int species, int form, bool specialTutors, int generation)
{
List<int> moves = new List<int>();
PersonalInfo info;

View file

@ -52,6 +52,10 @@ namespace PKHeX.Core
public static string V331 { get; set; } = "Learned by TM/HM in generation {0}.";
public static string V332 { get; set; } = "Learned by Move Tutor in generation {0}.";
public static string V333 { get; set; } = "Event Egg Move.";
public static string V344 { get; set; } = "Inherited egg move.";
public static string V345 { get; set; } = "Inherited move learned by Level-up.";
public static string V346 { get; set; } = "Inherited tutor move.";
public static string V349 { get; set; } = "Inherited TM/HM move.";
#endregion
@ -329,6 +333,9 @@ namespace PKHeX.Core
public static string V341 {get; set;} = "Egg Move.Not expected in an event egg.";
public static string V342 {get; set;} = "Event egg move missing.";
public static string V343 {get; set;} = "Expected the following Moves: { 0}";
public static string V347 {get; set;} = "Inherited move learned by Level-up.Not expected in an event egg.";
public static string V348 {get; set;} = "Inherited tutor move. Not expected in an event egg.";
public static string V350 {get; set;} = "Inherited TM/HM move. Not expected in an event egg.";
#endregion
}