private static IEnumerable <MysteryGift> GetMatchingPGF(PKM pkm, IEnumerable <MysteryGift> DB) { if (DB == null) { yield break; } var deferred = new List <MysteryGift>(); var vs = EvolutionChain.GetValidPreEvolutions(pkm); var enumerable = DB.OfType <PGF>().Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (PGF wc in enumerable) { if (!GetIsMatchPGF(pkm, wc, vs)) { continue; } if (wc.Species == pkm.Species) // best match { yield return(wc); } else { deferred.Add(wc); } } foreach (var z in deferred) { yield return(z); } }
private static EvoCriteria[] GetOriginChain(PKM pkm, int maxSpecies, byte maxLevel, byte minLevel, bool hasOriginMet) { if (maxLevel < minLevel) { return(Array.Empty <EvoCriteria>()); } if (hasOriginMet) { return(EvolutionChain.GetValidPreEvolutions(pkm, maxSpecies, maxLevel, minLevel)); } // Permit the maximum to be all the way up to Current Level; we'll trim these impossible evolutions out later. var tempMax = pkm.CurrentLevel; var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxSpecies, tempMax, minLevel); for (var i = 0; i < chain.Length; i++) { chain[i] = chain[i] with { LevelMax = maxLevel, LevelMin = minLevel } } ; return(chain); }
public static IEnumerable <EncounterSlot> GetValidWildEncounters(PKM pkm, GameVersion gameSource = GameVersion.Any) { int maxspeciesorigin = GetMaxSpecies(gameSource); var chain = EvolutionChain.GetOriginChain(pkm, maxspeciesorigin: maxspeciesorigin); return(GetValidWildEncounters(pkm, chain, gameSource)); }
private static bool IsEvolutionValid(PKM pkm) { var curr = EvolutionChain.GetValidPreEvolutions(pkm, minLevel: 5); var poss = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, minLevel: 5, skipChecks: true); return(curr.Count >= poss.Count); }
/// <summary> /// Gets an object containing met data properties that might be legal. /// </summary> public static EncounterSuggestionData?GetSuggestedMetInfo(PKM pkm) { int loc = GetSuggestedTransferLocation(pkm); if (pkm.WasEgg) { return(GetSuggestedEncounterEgg(pkm, loc)); } var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); var w = EncounterSlotGenerator.GetCaptureLocation(pkm, chain); var s = EncounterStaticGenerator.GetStaticLocation(pkm, chain); if (w is null) { return(s is null ? null : GetSuggestedEncounter(pkm, s, loc)); } if (s is null) { return(GetSuggestedEncounter(pkm, w, loc)); } bool isDefinitelySlot = chain.Any(z => z.Species == w.Species && z.Form == w.Form); bool isDefinitelyStatic = chain.Any(z => z.Species == s.Species && z.Form == s.Form); IEncounterable obj = (isDefinitelySlot || !isDefinitelyStatic) ? w : s; return(GetSuggestedEncounter(pkm, obj, loc)); }
public static IEnumerable <EncounterSlot> GetPossible(PKM pkm, GameVersion gameSource = GameVersion.Any) { int maxspeciesorigin = GetMaxSpecies(gameSource); var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); return(GetPossible(pkm, vs, gameSource)); }
private static IEnumerable <EncounterSlot> GetRawEncounterSlots(PKM pkm, int lvl, GameVersion gameSource) { int maxspeciesorigin = GetMaxSpecies(gameSource); var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); return(GetRawEncounterSlots(pkm, lvl, vs, gameSource)); }
private static IEnumerable <WC3> GetMatchingWC3(PKM pkm, IEnumerable <WC3> DB) { var validWC3 = new List <WC3>(); var vs = EvolutionChain.GetValidPreEvolutions(pkm, MaxSpeciesID_3); var enumerable = DB.Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (var wc in enumerable) { if (!GetIsMatchWC3(pkm, wc)) { continue; } if (wc.Species == pkm.Species) // best match { yield return(wc); } else { validWC3.Add(wc); } } foreach (var z in validWC3) { yield return(z); } }
public static IEnumerable <MysteryGift> GetPossible(PKM pkm) { int maxSpecies = Legal.GetMaxSpeciesOrigin(pkm.Format); var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxSpecies); return(GetPossible(pkm, vs)); }
/// <summary> /// Checks if the Evolution from the source <see cref="IEncounterable"/> is valid. /// </summary> /// <param name="pkm">Source data to verify</param> /// <param name="info">Source supporting information to verify with</param> /// <returns>Evolution is valid or not</returns> private static bool IsValidEvolution(PKM pkm, LegalInfo info) { int species = pkm.Species; if (info.EncounterMatch.Species == species) { return(true); } if (info.EncounterMatch.EggEncounter && species == 350 && pkm.Format >= 5 && !pkm.IsUntraded) // Prism Scale { return(true); } if (EvolutionChain.GetEvoChainSpeciesIndex(info.EvoChainsAllGens[pkm.Format], pkm.Species) < 0) { return(false); // Can't exist as current species } if (info.Generation > 0 && info.EvoChainsAllGens[info.Generation].All(z => z.Species != info.EncounterMatch.Species)) { return(false); // Can't exist as origin species } // If current species evolved with a move evolution and encounter species is not current species check if the evolution by move is valid // Only the evolution by move is checked, if there is another evolution before the evolution by move is covered in IsEvolutionValid if (Legal.SpeciesEvolutionWithMove.Contains(pkm.Species)) { return(Legal.IsEvolutionValidWithMove(pkm, info)); } return(true); }
private static IEnumerable <WC6> GetMatchingWC6(PKM pkm, IEnumerable <WC6> DB) { var deferred = new List <WC6>(); var vs = EvolutionChain.GetValidPreEvolutions(pkm); var enumerable = DB.Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (var wc in enumerable) { if (!GetIsMatchWC6(pkm, wc, vs)) { continue; } if (GetIsDeferredWC6(pkm, wc)) { deferred.Add(wc); } else { yield return(wc); } } foreach (var z in deferred) { yield return(z); } }
public static IEnumerable <MysteryGift> GetPossible(PKM pkm) { int maxSpecies = Legal.GetMaxSpeciesOrigin(pkm.Format); var chain = EvolutionChain.GetOriginChain(pkm, maxSpecies); return(GetPossible(pkm, chain)); }
internal static bool GetCanKnowMove(PKM pkm, int move, int generation, GameVersion version = GameVersion.Any) { if (pkm.Species == 235 && !InvalidSketch.Contains(move)) { return(true); } return(GetValidMoves(pkm, version, EvolutionChain.GetValidPreEvolutions(pkm), generation, LVL: true, Relearn: true, Tutor: true, Machine: true).Contains(move)); }
public static IEnumerable <EncounterStatic> GetPossible(PKM pkm, GameVersion gameSource = GameVersion.Any) { int gen = pkm.GenNumber; int maxID = gen == 2 ? MaxSpeciesID_2 : gen == 1 ? MaxSpeciesID_1 : -1; var dl = EvolutionChain.GetValidPreEvolutions(pkm, maxID); return(GetPossible(pkm, dl, gameSource)); }
internal static EncounterSlot?GetCaptureLocation(PKM pkm) { var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); return(GetPossible(pkm, chain) .OrderBy(z => !chain.Any(s => s.Species == z.Species && s.Form == z.Form)) .ThenBy(z => z.LevelMin) .FirstOrDefault()); }
private static IEnumerable <EncounterSlot> GetRawEncounterSlots(PKM pkm, int lvl, GameVersion gameSource = GameVersion.Any) { int maxspeciesorigin = GetMaxSpecies(gameSource); var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); var possibleAreas = GetEncounterAreas(pkm, gameSource); return(possibleAreas.SelectMany(area => GetValidEncounterSlots(pkm, area, vs, DexNav: pkm.AO, lvl: lvl))); }
public static IEnumerable <EncounterSlot> GetValidFriendSafari(PKM pkm) { if (!pkm.XY || pkm.Met_Location != 148 || pkm.Met_Level != 30 || pkm.Egg_Location != 0) // Friend Safari { return(Enumerable.Empty <EncounterSlot>()); } var vs = EvolutionChain.GetValidPreEvolutions(pkm).Where(d => d.Level >= 30); return(vs.SelectMany(z => Encounters6.FriendSafari[z.Species])); }
internal static EncounterArea?GetCaptureLocation(PKM pkm) { var chain = EvolutionChain.GetOriginChain(pkm); return((from area in GetEncounterSlots(pkm) let slots = GetValidEncounterSlots(pkm, area, chain, lvl: 0).ToArray() where slots.Length != 0 select new EncounterAreaFake { Location = area.Location, Slots = slots, }).OrderBy(area => area.Slots.Min(x => x.LevelMin)).FirstOrDefault()); }
public static IEnumerable <EncounterStatic> GetPossible(PKM pkm, GameVersion gameSource = GameVersion.Any) { int gen = pkm.GenNumber; int maxID = gen switch { 1 => MaxSpeciesID_1, 2 => MaxSpeciesID_2, _ => - 1 }; var dl = EvolutionChain.GetOriginChain(pkm, maxID); return(GetPossible(pkm, dl, gameSource)); }
internal static EncounterArea GetCaptureLocation(PKM pkm) { var vs = EvolutionChain.GetValidPreEvolutions(pkm); return((from area in GetEncounterSlots(pkm) let slots = GetValidEncounterSlots(pkm, area, vs, DexNav: pkm.AO, ignoreLevel: true).ToArray() where slots.Length != 0 select new EncounterArea { Location = area.Location, Slots = slots, }).OrderBy(area => area.Slots.Min(x => x.LevelMin)).FirstOrDefault()); }
private static List <int> GetValidPostEvolutionMoves(PKM pkm, int Species, IReadOnlyList <EvoCriteria> evoChain, int Generation, GameVersion Version) { var evomoves = new List <int>(); var index = EvolutionChain.GetEvoChainSpeciesIndex(evoChain, Species); for (int i = 0; i <= index; i++) { var evo = evoChain[i]; var moves = GetMoves(pkm, evo.Species, 1, 1, evo.Level, pkm.AltForm, moveTutor: true, Version: Version, LVL: true, specialTutors: true, Machine: true, MoveReminder: true, RemoveTransferHM: false, Generation: Generation); // Moves from Species or any species after in the evolution phase evomoves.AddRange(moves); } return(evomoves); }
internal static EncounterStatic?GetStaticLocation(PKM pkm, int species = -1) { switch (pkm.GenNumber) { case 1: return(GetRBYStaticTransfer(species, pkm.Met_Level)); case 2: return(GetGSStaticTransfer(species, pkm.Met_Level)); default: var dl = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); return(GetPossible(pkm, dl).FirstOrDefault()); } }
internal static IEnumerable <int> GetExclusivePreEvolutionMoves(PKM pkm, int Species, IReadOnlyList <EvoCriteria> evoChain, int Generation, GameVersion Version) { var preevomoves = new List <int>(); var evomoves = new List <int>(); var index = EvolutionChain.GetEvoChainSpeciesIndex(evoChain, Species); for (int i = 0; i < evoChain.Count; i++) { var evo = evoChain[i]; var moves = GetMoves(pkm, evo.Species, 1, 1, evo.Level, pkm.AltForm, moveTutor: true, Version: Version, LVL: true, specialTutors: true, Machine: true, MoveReminder: true, RemoveTransferHM: false, Generation: Generation); var list = i >= index ? preevomoves : evomoves; list.AddRange(moves); } return(preevomoves.Except(evomoves).Distinct()); }
internal static bool IsDexNavValid(PKM pkm) { if (!pkm.AO || !pkm.InhabitedGeneration(6)) { return(false); } var vs = EvolutionChain.GetValidPreEvolutions(pkm); var table = pkm.Version == (int)GameVersion.AS ? SlotsA : SlotsO; int loc = pkm.Met_Location; var areas = table.Where(l => l.Location == loc); var d_areas = areas.Select(area => GetValidEncounterSlots(pkm, area, vs, DexNav: true)); return(d_areas.Any(slots => slots.Any(slot => slot.Permissions.AllowDexNav && slot.Permissions.DexNav))); }
private static IEnumerable <MysteryGift> GetMatchingWC7(PKM pkm, IEnumerable <MysteryGift> DB) { if (DB == null) { yield break; } var deferred = new List <MysteryGift>(); var vs = EvolutionChain.GetValidPreEvolutions(pkm); var enumerable = DB.OfType <WC7>().Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (WC7 wc in enumerable) { if (!GetIsMatchWC7(pkm, wc, vs)) { continue; } if ((pkm.SID << 16 | pkm.TID) == 0x79F57B49) // Greninja WC has variant PID and can arrive @ 36 or 37 { if (!pkm.IsShiny) { deferred.Add(wc); } continue; } if (wc.PIDType == 0 && pkm.PID != wc.PID) { continue; } if (GetIsDeferredWC7(pkm, wc)) { deferred.Add(wc); } else { yield return(wc); } } foreach (var z in deferred) { yield return(z); } }
public static IEnumerable <EncounterSlot> GetValidWildEncounters34(PKM pkm, GameVersion gameSource = GameVersion.Any) { int lvl = GetMaxLevelEncounter(pkm); if (lvl <= 0) { return(Enumerable.Empty <EncounterSlot>()); } if (gameSource == GameVersion.Any) { gameSource = (GameVersion)pkm.Version; } var chain = EvolutionChain.GetOriginChain(pkm); var slots = GetRawEncounterSlots(pkm, lvl, chain, gameSource); return(slots); // defer deferrals to the method consuming this collection }
private static IEnumerable <MysteryGift> GetMatchingPCD(PKM pkm, IEnumerable <PCD> DB) { if (pkm.IsEgg && pkm.Format != 4) // transferred { yield break; } if (IsRangerManaphy(pkm)) { if (pkm.Language != (int)LanguageID.Korean) // never korean { yield return(RangerManaphy); } yield break; } var deferred = new List <PCD>(); var vs = EvolutionChain.GetValidPreEvolutions(pkm); var enumerable = DB.Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (var mg in enumerable) { var wc = mg.Gift.PK; if (!GetIsMatchPCD(pkm, wc, vs)) { continue; } bool receivable = mg.CanBeReceivedBy(pkm.Version); if (wc.Species == pkm.Species && receivable) // best match { yield return(mg); } else { deferred.Add(mg); } } foreach (var z in deferred) { yield return(z); } }
public static IEnumerable <EncounterSlot> GetValidWildEncounters34(PKM pkm, GameVersion gameSource = GameVersion.Any) { int lvl = GetMinLevelEncounter(pkm); if (lvl <= 0) { return(Enumerable.Empty <EncounterSlot>()); } if (gameSource == GameVersion.Any) { gameSource = (GameVersion)pkm.Version; } int maxspeciesorigin = GetMaxSpecies(gameSource); var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); var s = GetRawEncounterSlots(pkm, lvl, vs, gameSource); return(s); // defer deferrals to the method consuming this collection }
private static IEnumerable <WB7> GetMatchingWB7(PKM pkm, IEnumerable <WB7> DB) { var vs = EvolutionChain.GetValidPreEvolutions(pkm); var enumerable = DB.Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (var wc in enumerable) { if (!GetIsMatchWB7(pkm, wc, vs)) { continue; } if (wc.PIDType == 0 && pkm.PID != wc.PID) { continue; } yield return(wc); } }
internal static bool IsEvolutionValid(PKM pkm, int minSpecies = -1, int minLevel = -1) { var curr = EvolutionChain.GetValidPreEvolutions(pkm); var min = curr.FindLast(z => z.Species == minSpecies); if (min != null && min.Level < minLevel) { return(false); } var poss = EvolutionChain.GetValidPreEvolutions(pkm, lvl: 100, skipChecks: true); if (minSpecies != -1) { int last = poss.FindLastIndex(z => z.Species == minSpecies); return(curr.Count >= last); } if (GetSplitBreedGeneration(pkm).Contains(GetBaseSpecies(pkm, poss, 1))) { return(curr.Count >= poss.Count - 1); } return(curr.Count >= poss.Count); }