/// <summary> /// Fetches <see cref="PKM.RelearnMoves"/> based on the provided <see cref="LegalityAnalysis"/>. /// </summary> /// <param name="legal"><see cref="LegalityAnalysis"/> which contains parsed information pertaining to legality.</param> /// <returns><see cref="PKM.RelearnMoves"/> best suited for the current <see cref="PKM"/> data.</returns> public static IReadOnlyList <int> GetSuggestedRelearnMoves(this LegalityAnalysis legal) { var m = legal.GetSuggestedRelearnMovesFromEncounter(); if (m.Any(z => z != 0)) { return(m); } var enc = legal.EncounterMatch; if (enc is MysteryGift || enc is EncounterEgg) { return(m); } var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.pkm); if (encounter is IRelearn r && r.Relearn.Count > 0) { return(r.Relearn); } return(m); }
/// <summary> /// Fetches <see cref="PKM.RelearnMoves"/> based on the provided <see cref="LegalityAnalysis"/>. /// </summary> /// <param name="legal"><see cref="LegalityAnalysis"/> which contains parsed information pertaining to legality.</param> /// <param name="enc">Encounter the relearn moves should be suggested for. If not provided, will try to detect it via legality analysis. </param> /// <returns><see cref="PKM.RelearnMoves"/> best suited for the current <see cref="PKM"/> data.</returns> public static IReadOnlyList <int> GetSuggestedRelearnMoves(this LegalityAnalysis legal, IEncounterable?enc = null) { var m = legal.GetSuggestedRelearnMovesFromEncounter(); if (m.Any(z => z != 0)) { return(m); } enc ??= legal.EncounterMatch; if (enc is MysteryGift or EncounterEgg) { return(m); } if (enc is EncounterSlot6AO { CanDexNav : true } dn) { var moves = legal.Info.Moves; for (int i = 0; i < moves.Length; i++) { if (moves[i].Valid) { continue; } var move = legal.pkm.GetMove(i); if (dn.CanBeDexNavMove(move)) { return new[] { move, 0, 0, 0 } } ; } } var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.pkm); if (encounter is IRelearn r && r.Relearn.Count > 0) { return(r.Relearn); } return(m); } }
/// <summary> /// Fetches <see cref="PKM.RelearnMoves"/> based on the provided <see cref="LegalityAnalysis"/>. /// </summary> /// <param name="legal"><see cref="LegalityAnalysis"/> which contains parsed information pertaining to legality.</param> /// <param name="enc">Encounter the relearn moves should be suggested for. If not provided, will try to detect it via legality analysis. </param> /// <returns><see cref="PKM.RelearnMoves"/> best suited for the current <see cref="PKM"/> data.</returns> public static IReadOnlyList <int> GetSuggestedRelearnMoves(this LegalityAnalysis legal, IEncounterTemplate?enc = null) { enc ??= legal.EncounterOriginal; var m = legal.GetSuggestedRelearnMovesFromEncounter(enc); if (m.Any(z => z != 0)) { return(m); } if (enc is MysteryGift or EncounterEgg) { return(m); } if (enc is EncounterSlot6AO { CanDexNav : true } dn) { var moves = legal.Info.Moves; for (int i = 0; i < moves.Length; i++) { if (!moves[i].ShouldBeInRelearnMoves()) { continue; } var move = legal.pkm.GetMove(i); if (dn.CanBeDexNavMove(move)) { return new[] { move, 0, 0, 0 } } ; } } var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.pkm); if (encounter is IRelearn { Relearn : { Count : > 0 } r })
public static ModifyResult SetSuggestedMetData(BatchInfo info) { var pk = info.Entity; var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk); if (encounter == null) { return(ModifyResult.Error); } int level = encounter.LevelMin; int location = encounter.Location; int minimumLevel = EncounterSuggestion.GetLowestLevel(pk, encounter.LevelMin); pk.Met_Level = level; pk.Met_Location = location; pk.CurrentLevel = Math.Max(minimumLevel, level); return(ModifyResult.Modified); }
/// <summary> /// Gets an object containing met data properties that might be legal. /// </summary> public EncounterStatic GetSuggestedMetInfo() => EncounterSuggestion.GetSuggestedMetInfo(pkm);
/// <summary> /// Sets the <see cref="PKM"/> data with a suggested value based on its <see cref="LegalityAnalysis"/>. /// </summary> /// <param name="name">Property to modify.</param> /// <param name="info">Cached info storing Legal data.</param> /// <param name="propValue">Suggestion string which starts with <see cref="CONST_SUGGEST"/></param> private static ModifyResult SetSuggestedPKMProperty(string name, PKMInfo info, string propValue) { bool isAll() => propValue.EndsWith("All", true, CultureInfo.CurrentCulture); bool isNone() => propValue.EndsWith("None", true, CultureInfo.CurrentCulture); var pk = info.Entity; switch (name) { // pb7 only case nameof(PB7.Stat_CP) when pk is PB7 pb7: pb7.ResetCP(); return(ModifyResult.Modified); case nameof(PB7.HeightAbsolute) when pk is PB7 pb7: pb7.HeightAbsolute = pb7.CalcHeightAbsolute; return(ModifyResult.Modified); case nameof(PB7.WeightAbsolute) when pk is PB7 pb7: pb7.WeightAbsolute = pb7.CalcWeightAbsolute; return(ModifyResult.Modified); // Date Copy case nameof(PKM.EggMetDate): pk.EggMetDate = pk.MetDate; return(ModifyResult.Modified); case nameof(PKM.MetDate): pk.MetDate = pk.EggMetDate; return(ModifyResult.Modified); case nameof(PKM.Nature) when pk.Format >= 8: pk.Nature = pk.StatNature; return(ModifyResult.Modified); case nameof(PKM.StatNature) when pk.Format >= 8: pk.StatNature = pk.Nature; return(ModifyResult.Modified); case nameof(PKM.Stats): pk.ResetPartyStats(); return(ModifyResult.Modified); case nameof(IHyperTrain.HyperTrainFlags): pk.SetSuggestedHyperTrainingData(); return(ModifyResult.Modified); case nameof(PKM.RelearnMoves): if (pk.Format >= 8) { pk.ClearRecordFlags(); if (isAll()) { pk.SetRecordFlags(); // all } else if (!isNone()) { pk.SetRecordFlags(pk.Moves); // whatever fit the current moves } } pk.SetRelearnMoves(info.SuggestedRelearn); return(ModifyResult.Modified); case PROP_RIBBONS: if (isNone()) { RibbonApplicator.RemoveAllValidRibbons(pk); } else // All { RibbonApplicator.SetAllValidRibbons(pk); } return(ModifyResult.Modified); case nameof(PKM.Met_Location): var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk); if (encounter == null) { return(ModifyResult.Error); } int level = encounter.LevelMin; int location = encounter.Location; int minlvl = EncounterSuggestion.GetLowestLevel(pk, encounter.LevelMin); pk.Met_Level = level; pk.Met_Location = location; pk.CurrentLevel = Math.Max(minlvl, level); return(ModifyResult.Modified); case nameof(PKM.Heal): pk.Heal(); return(ModifyResult.Modified); case nameof(PKM.HealPP): pk.HealPP(); return(ModifyResult.Modified); case nameof(PKM.Move1_PP): case nameof(PKM.Move2_PP): case nameof(PKM.Move3_PP): case nameof(PKM.Move4_PP): pk.SetSuggestedMovePP(name[4] - '1'); // 0-3 int32 return(ModifyResult.Modified); case nameof(PKM.Moves): return(SetMoves(pk, info.Legality.GetMoveSet())); case nameof(PKM.Ball): BallApplicator.ApplyBallLegalByColor(pk); return(ModifyResult.Modified); default: return(ModifyResult.Error); } }