/// <summary> /// Sets the <see cref="PKM.RelearnMoves"/> based on a legality check's suggestions. /// </summary> /// <param name="pk"></param> public static void SetSuggestedRelearnMoves(this PKM pk) { if (pk.Format < 6) { return; } pk.ClearRelearnMoves(); var la = new LegalityAnalysis(pk); var m = la.GetSuggestedRelearn(); if (m.All(z => z == 0)) { if (!pk.WasEgg && !pk.WasEvent && !pk.WasEventEgg && !pk.WasLink) { if (pk.Version != (int)GameVersion.CXD) { var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk); if (encounter != null) { m = encounter.Relearn; } } } } if (pk.RelearnMoves.SequenceEqual(m)) { return; } if (m.Count > 3) { pk.SetRelearnMoves(m); } }
/// <summary> /// Sets the <see cref="PKM.Met_Location"/> (and other met details) based on a legality check's suggestions. /// </summary> /// <param name="pk"></param> public static void SetSuggestedMetLocation(this PKM pk) { var encounter = EncounterSuggestion.GetSuggestedMetInfo(pk); if (encounter == null || (pk.Format >= 3 && encounter.Location < 0)) { return; } int level = encounter.LevelMin; int location = encounter.Location; int minlvl = EncounterSuggestion.GetLowestLevel(pk, encounter.Species); if (minlvl == 0) { minlvl = level; } if (pk.CurrentLevel >= minlvl && pk.Met_Level == level && pk.Met_Location == location) { return; } if (minlvl < level) { level = minlvl; } pk.Met_Location = location; pk.Met_Level = level; }
public static void SetMetValid(PKM pkm) { var encounter = EncounterSuggestion.GetSuggestedMetInfo(pkm); if (encounter == null || pkm.Format >= 3 && encounter.Location < 0) { return; } int level = encounter.LevelMin; int location = encounter.Location; int minlvl = EncounterSuggestion.GetLowestLevel(pkm, encounter.LevelMin); if (minlvl == 0) { minlvl = level; } if (pkm.CurrentLevel >= minlvl && pkm.Met_Level == level && pkm.Met_Location == location) { return; } if (minlvl < level) { minlvl = level; } if (pkm.Format >= 3) { pkm.Met_Location = location; pkm.Met_Level = encounter.GetSuggestedMetLevel(pkm); // 相遇地点狩猎区 int pkmLocation = pkm.Met_Location; if (pkmLocation == 52 || pkmLocation == 57 || pkmLocation == 136 || pkmLocation == 202) { pkm.Ball = 5; } if (pkm.Ball == 5 && pkmLocation != 52 && pkmLocation != 57 && pkmLocation != 136 && pkmLocation != 202) { pkm.Ball = 1; } if (pkm.Gen6 && pkm.WasEgg) { pkm.SetHatchMemory6(); } } if (pkm.CurrentLevel < minlvl) { pkm.CurrentLevel = minlvl; } }
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); }
public static ModifyResult SetMinimumCurrentLevel(BatchInfo info) { var result = EncounterSuggestion.IterateMinimumCurrentLevel(info.Entity, info.Legal); return(result ? ModifyResult.Modified : ModifyResult.Filtered); }
/// <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.Entity.GetMove(i); if (dn.CanBeDexNavMove(move)) { return new[] { move, 0, 0, 0 } } ; } } if (enc is EncounterSlot8b { IsUnderground : true } ug) { var moves = legal.Info.Moves; for (int i = 0; i < moves.Length; i++) { if (!moves[i].ShouldBeInRelearnMoves()) { continue; } var move = legal.Entity.GetMove(i); if (ug.CanBeUndergroundMove(move)) { return new[] { move, 0, 0, 0 } } ; } if (ug.GetBaseEggMove(out int any)) return new[] { any, 0, 0, 0 } ; } var encounter = EncounterSuggestion.GetSuggestedMetInfo(legal.Entity); if (encounter is IRelearn { Relearn : { Count : > 0 } r })