private static int GetRequiredBaseMoveCount(int[] Moves, EggInfoSource infoset) { int baseCt = infoset.Base.Count; if (baseCt > 4) { baseCt = 4; } // Obtain Inherited moves var inherited = Moves.Where(m => m != 0 && infoset.IsInherited(m)).ToList(); int inheritCt = inherited.Count; // Get required amount of base moves int unique = infoset.Base.Union(inherited).Count(); int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt; if (Moves.Count(m => m != 0) < Math.Min(4, infoset.Base.Count)) { reqBase = Math.Min(4, unique); } return(reqBase); }
/* 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 static CheckMoveResult[] VerifyPreRelearnEggBase(PKM pkm, int[] Moves, EggInfoSource infoset) { CheckMoveResult[] res = new CheckMoveResult[4]; var gen = pkm.GenNumber; // Obtain level1 moves var reqBase = GetRequiredBaseMoveCount(Moves, infoset); var em = string.Empty; // Check if the required amount of Base Egg Moves are present. for (int i = 0; i < reqBase; i++) { if (infoset.Base.Contains(Moves[i])) { res[i] = new CheckMoveResult(MoveSource.Initial, gen, Severity.Valid, V179, CheckIdentifier.Move); continue; } // mark remaining base egg moves missing for (int z = i; z < reqBase; z++) { res[z] = new CheckMoveResult(MoveSource.Initial, gen, Severity.Invalid, V180, CheckIdentifier.Move); } // provide the list of suggested base moves for the last required slot em = string.Join(", ", GetMoveNames(infoset.Base)); break; } int moveoffset = reqBase; int endSpecial = moveoffset + infoset.Special.Count; // Check also if the required amount of Special Egg Moves are present, ir are after base moves for (int i = moveoffset; i < endSpecial; i++) { if (infoset.Special.Contains(Moves[i])) { res[i] = new CheckMoveResult(MoveSource.SpecialEgg, gen, Severity.Valid, V333, CheckIdentifier.Move); continue; } // Not in special moves, mark remaining special egg moves missing for (int z = i; z < endSpecial; z++) { res[z] = new CheckMoveResult(MoveSource.SpecialEgg, gen, Severity.Invalid, V342, CheckIdentifier.Move); } // provide the list of suggested base moves and species moves for the last required slot if (string.IsNullOrEmpty(em)) { em = string.Join(", ", GetMoveNames(infoset.Base)); } em += ", "; em += string.Join(", ", GetMoveNames(infoset.Special)); break; } if (!string.IsNullOrEmpty(em)) { res[reqBase > 0 ? reqBase - 1 : 0].Comment = string.Format(Environment.NewLine + V343, em); } // Inherited moves appear after the required base moves. var AllowInheritedSeverity = infoset.AllowInherited ? Severity.Valid : Severity.Invalid; for (int i = reqBase + infoset.Special.Count; i < 4; i++) { if (Moves[i] == 0) // empty { res[i] = new CheckMoveResult(MoveSource.None, gen, Severity.Valid, V167, CheckIdentifier.Move); } else if (infoset.Egg.Contains(Moves[i])) // inherited egg move { res[i] = new CheckMoveResult(MoveSource.EggMove, gen, AllowInheritedSeverity, infoset.AllowInherited ? V344 : V341, CheckIdentifier.Move); } else if (infoset.LevelUp.Contains(Moves[i])) // inherited lvl moves { res[i] = new CheckMoveResult(MoveSource.InheritLevelUp, gen, AllowInheritedSeverity, infoset.AllowInherited ? V345 : V347, CheckIdentifier.Move); } else if (infoset.TMHM.Contains(Moves[i])) // inherited TMHM moves { res[i] = new CheckMoveResult(MoveSource.TMHM, gen, AllowInheritedSeverity, infoset.AllowInherited ? V349 : V350, CheckIdentifier.Move); } else if (infoset.Tutor.Contains(Moves[i])) // inherited tutor moves { res[i] = new CheckMoveResult(MoveSource.Tutor, gen, AllowInheritedSeverity, infoset.AllowInherited ? V346 : V348, CheckIdentifier.Move); } else // not inheritable, flag { res[i] = new CheckMoveResult(MoveSource.Unknown, gen, Severity.Invalid, V340, CheckIdentifier.Move); } } return(res); }
private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, int[] Moves, int[] SpecialMoves, EncounterEgg e) { EggInfoSource infoset = new EggInfoSource(pkm, SpecialMoves, e); return(VerifyPreRelearnEggBase(pkm, Moves, infoset)); }
/* 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 static CheckMoveResult[] VerifyPreRelearnEggBase(PKM pkm, IReadOnlyList <int> currentMoves, EggInfoSource infoset) { CheckMoveResult[] res = new CheckMoveResult[4]; var gen = pkm.GenNumber; // Obtain level1 moves var reqBase = GetRequiredBaseMoveCount(currentMoves, infoset); var sb = new System.Text.StringBuilder(); // Check if the required amount of Base Egg Moves are present. for (int i = 0; i < reqBase; i++) { if (infoset.Base.Contains(currentMoves[i])) { res[i] = new CheckMoveResult(Initial, gen, Valid, LMoveRelearnEgg, Move); continue; } // mark remaining base egg moves missing for (int z = i; z < reqBase; z++) { res[z] = new CheckMoveResult(Initial, gen, Invalid, LMoveRelearnEggMissing, Move); } // provide the list of suggested base moves for the last required slot sb.Append(string.Join(", ", GetMoveNames(infoset.Base))); break; } if (sb.Length != 0) { res[reqBase > 0 ? reqBase - 1 : 0].Comment = string.Format(Environment.NewLine + LMoveFExpect_0, sb); } // Inherited moves appear after the required base moves. var AllowInheritedSeverity = infoset.AllowInherited ? Valid : Invalid; for (int i = reqBase; i < 4; i++) { if (currentMoves[i] == 0) // empty { res[i] = new CheckMoveResult(None, gen, Valid, LMoveSourceEmpty, Move); } else if (infoset.Egg.Contains(currentMoves[i])) // inherited egg move { res[i] = new CheckMoveResult(EggMove, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggInherited : LMoveEggInvalidEvent, Move); } else if (infoset.LevelUp.Contains(currentMoves[i])) // inherited lvl moves { res[i] = new CheckMoveResult(InheritLevelUp, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggLevelUp : LMoveEggInvalidEventLevelUp, Move); } else if (infoset.TMHM.Contains(currentMoves[i])) // inherited TMHM moves { res[i] = new CheckMoveResult(TMHM, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggTMHM : LMoveEggInvalidEventTMHM, Move); } else if (infoset.Tutor.Contains(currentMoves[i])) // inherited tutor moves { res[i] = new CheckMoveResult(Tutor, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggInheritedTutor : LMoveEggInvalidEventTutor, Move); } else // not inheritable, flag { res[i] = new CheckMoveResult(Unknown, gen, Invalid, LMoveEggInvalid, Move); } } return(res); }
private static CheckMoveResult[] ParseMovesIsEggPreRelearn(PKM pkm, IReadOnlyList <int> currentMoves, EncounterEgg e) { var infoset = new EggInfoSource(pkm, e); return(VerifyPreRelearnEggBase(pkm, currentMoves, infoset)); }
/* 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 static CheckMoveResult[] VerifyPreRelearnEggBase(PKM pkm, int[] Moves, EggInfoSource infoset) { CheckMoveResult[] res = new CheckMoveResult[4]; var gen = pkm.GenNumber; // Obtain level1 moves var reqBase = GetRequiredBaseMoveCount(Moves, infoset); var sb = new System.Text.StringBuilder(); // Check if the required amount of Base Egg Moves are present. for (int i = 0; i < reqBase; i++) { if (infoset.Base.Contains(Moves[i])) { res[i] = new CheckMoveResult(MoveSource.Initial, gen, Severity.Valid, LMoveRelearnEgg, CheckIdentifier.Move); continue; } // mark remaining base egg moves missing for (int z = i; z < reqBase; z++) { res[z] = new CheckMoveResult(MoveSource.Initial, gen, Severity.Invalid, LMoveRelearnEggMissing, CheckIdentifier.Move); } // provide the list of suggested base moves for the last required slot sb.Append(string.Join(", ", GetMoveNames(infoset.Base))); break; } int moveoffset = reqBase; int endSpecial = moveoffset + infoset.Special.Count; // Check also if the required amount of Special Egg Moves are present, ir are after base moves for (int i = moveoffset; i < endSpecial; i++) { if (infoset.Special.Contains(Moves[i])) { res[i] = new CheckMoveResult(MoveSource.SpecialEgg, gen, Severity.Valid, LMoveSourceEggEvent, CheckIdentifier.Move); continue; } // Not in special moves, mark remaining special egg moves missing for (int z = i; z < endSpecial; z++) { res[z] = new CheckMoveResult(MoveSource.SpecialEgg, gen, Severity.Invalid, LMoveEggMissing, CheckIdentifier.Move); } // provide the list of suggested base moves and species moves for the last required slot if (sb.Length == 0) { sb.Append(string.Join(", ", GetMoveNames(infoset.Base))); } sb.Append(", "); sb.Append(string.Join(", ", GetMoveNames(infoset.Special))); break; } if (sb.Length != 0) { res[reqBase > 0 ? reqBase - 1 : 0].Comment = string.Format(Environment.NewLine + LMoveFExpect_0, sb); } // Inherited moves appear after the required base moves. var AllowInheritedSeverity = infoset.AllowInherited ? Severity.Valid : Severity.Invalid; for (int i = reqBase + infoset.Special.Count; i < 4; i++) { if (Moves[i] == 0) // empty { res[i] = new CheckMoveResult(MoveSource.None, gen, Severity.Valid, LMoveSourceEmpty, CheckIdentifier.Move); } else if (infoset.Egg.Contains(Moves[i])) // inherited egg move { res[i] = new CheckMoveResult(MoveSource.EggMove, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggInherited : LMoveEggInvalidEvent, CheckIdentifier.Move); } else if (infoset.LevelUp.Contains(Moves[i])) // inherited lvl moves { res[i] = new CheckMoveResult(MoveSource.InheritLevelUp, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggLevelUp : LMoveEggInvalidEventLevelUp, CheckIdentifier.Move); } else if (infoset.TMHM.Contains(Moves[i])) // inherited TMHM moves { res[i] = new CheckMoveResult(MoveSource.TMHM, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggTMHM : LMoveEggInvalidEventTMHM, CheckIdentifier.Move); } else if (infoset.Tutor.Contains(Moves[i])) // inherited tutor moves { res[i] = new CheckMoveResult(MoveSource.Tutor, gen, AllowInheritedSeverity, infoset.AllowInherited ? LMoveEggInheritedTutor : LMoveEggInvalidEventTutor, CheckIdentifier.Move); } else // not inheritable, flag { res[i] = new CheckMoveResult(MoveSource.Unknown, gen, Severity.Invalid, LMoveEggInvalid, CheckIdentifier.Move); } } return(res); }