/// <summary> /// Checks supplementary info to see if the encounter is still valid. /// </summary> /// <remarks> /// When an encounter is initially validated, only encounter-related checks are performed. /// By checking Moves, Evolution, and <see cref="PIDIV"/> data, a best match encounter can be found. /// If the encounter is not valid, the method will not reject it unless another encounter is available to check. /// </remarks> /// <param name="pkm">Source data to check the match for</param> /// <param name="info">Information containing the matched encounter</param> /// <param name="iterator">Peekable iterator </param> /// <returns>Indication whether or not the encounter passes secondary checks</returns> private static bool VerifySecondaryChecks(PKM pkm, LegalInfo info, PeekEnumerator <IEncounterable> iterator) { if (pkm.Format >= 6) { info.Relearn = VerifyRelearnMoves.VerifyRelearn(pkm, info); if (info.Relearn.Any(z => !z.Valid) && iterator.PeekIsNext()) { return(false); } } else { for (int i = 0; i < 4; i++) { info.Relearn[i] = new CheckResult(CheckIdentifier.RelearnMove); } } info.Moves = VerifyCurrentMoves.VerifyMoves(pkm, info); if (info.Moves.Any(z => !z.Valid) && iterator.PeekIsNext()) { return(false); } var evo = EvolutionVerifier.VerifyEvolution(pkm, info); if (!evo.Valid && iterator.PeekIsNext()) { return(false); } info.Parse.Add(evo); return(true); }
/// <summary> /// Returns legality info for an unmatched encounter scenario, including a hint as to what the actual match could be. /// </summary> /// <param name="pkm">Source data to check the match for</param> /// <param name="info">Information containing the unmatched encounter</param> /// <returns>Updated information pertaining to the unmatched encounter</returns> private static LegalInfo VerifyWithoutEncounter(PKM pkm, LegalInfo info) { info.EncounterMatch = new EncounterInvalid(pkm); string hint; // hint why an encounter was not found if (pkm.WasGiftEgg) { hint = LEncGift; } else if (pkm.WasEventEgg) { hint = LEncGiftEggEvent; } else if (pkm.WasEvent) { hint = LEncGiftNotFound; } else { hint = LEncInvalid; } info.Parse.Add(new CheckResult(Severity.Invalid, hint, CheckIdentifier.Encounter)); info.Relearn = VerifyRelearnMoves.VerifyRelearn(pkm, info); info.Moves = VerifyCurrentMoves.VerifyMoves(pkm, info); return(info); }
/// <summary> /// Gets the current <see cref="PKM.RelearnMoves"/> array of four moves that might be legal. /// </summary> public static IReadOnlyList <int> GetSuggestedRelearnMovesFromEncounter(this LegalityAnalysis analysis) { var info = analysis.Info; if (info.Generation < 6) { return(new int[4]); } var pkm = analysis.pkm; var enc = info.EncounterMatch; var parsed = VerifyRelearnMoves.GetSuggestedRelearn(pkm, enc); if (parsed.Count == 0) // Always true for Origins < 6 and encounters without relearn permitted. { return(new int[4]); } // Invalid encounters won't be recognized as an EncounterEgg; check if it *should* be a bred egg. if (!enc.EggEncounter) { return(parsed); } List <int> window = new(parsed.Where(z => z != 0)); window.AddRange(pkm.Moves.Where((_, i) => info.Moves[i].ShouldBeInRelearnMoves())); window = window.Distinct().ToList(); int[] moves = new int[4]; int start = Math.Max(0, window.Count - 4); int count = Math.Min(4, window.Count); window.CopyTo(start, moves, 0, count); return(moves); }
private static void ParseMovesPre3DS(PKM pkm, CheckMoveResult[] parse, int[] currentMoves, LegalInfo info) { if (info.EncounterMatch is EncounterEgg e) { if (pkm.IsEgg) { VerifyRelearnMoves.VerifyEggMoveset(e, parse, currentMoves, CurrentMove); } else { ParseMovesWasEggPreRelearn(pkm, parse, currentMoves, info, e); } return; } // Not all games have a re-learner. Initial moves may not fill out all 4 slots. int gen = info.EncounterMatch.Generation; if (gen == 1 || (gen == 2 && !AllowGen2MoveReminder(pkm))) { ParseMovesGenGB(pkm, currentMoves, info, parse); } ParseMovesSpecialMoveset(pkm, currentMoves, info, parse); }
/// <summary> /// Gets the current <see cref="PKM.RelearnMoves"/> array of four moves that might be legal. /// </summary> /// <remarks>Use <see cref="GetSuggestedRelearnMovesFromEncounter"/> instead of calling directly; this method just puts default values in without considering the final moveset.</remarks> public static IReadOnlyList <int> GetSuggestedRelearn(this IEncounterTemplate enc, PKM pkm) { if (VerifyRelearnMoves.ShouldNotHaveRelearnMoves(enc, pkm)) { return(Empty); } return(GetSuggestedRelearnInternal(enc, pkm)); }
/// <summary> /// Returns legality info for an unmatched encounter scenario, including a hint as to what the actual match could be. /// </summary> /// <param name="pkm">Source data to check the match for</param> /// <param name="info">Information containing the unmatched encounter</param> /// <returns>Updated information pertaining to the unmatched encounter</returns> private static LegalInfo VerifyWithoutEncounter(PKM pkm, LegalInfo info) { info.EncounterMatch = new EncounterInvalid(pkm); string hint = GetHintWhyNotFound(pkm); info.Parse.Add(new CheckResult(Severity.Invalid, hint, CheckIdentifier.Encounter)); info.Relearn = VerifyRelearnMoves.VerifyRelearn(pkm, info); info.Moves = VerifyCurrentMoves.VerifyMoves(pkm, info); return(info); }