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])); }
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.GetValidPreEvolutions(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()); }
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 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); } }
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); } }
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); } }
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 }
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); }
private static IEnumerable <MysteryGift> GetMatchingWC6(PKM pkm, IEnumerable <MysteryGift> DB) { if (DB == null) { yield break; } var deferred = new List <MysteryGift>(); var vs = EvolutionChain.GetValidPreEvolutions(pkm); var enumerable = DB.OfType <WC6>().Where(wc => vs.Any(dl => dl.Species == wc.Species)); foreach (WC6 wc in enumerable) { if (!GetIsMatchWC6(pkm, wc, vs)) { continue; } switch (wc.CardID) { case 0525 when wc.IV_HP == 0xFE: // Diancie was distributed with no IV enforcement & 3IVs case 0504 when wc.RibbonClassic != ((IRibbonSetEvent4)pkm).RibbonClassic: // magmar with/without classic deferred.Add(wc); 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 IReadOnlyList <EvoCriteria> GetOriginChain(PKM pkm, int maxSpecies, int maxLevel, int 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); foreach (var evo in chain) { evo.Level = maxLevel; evo.MinLevel = minLevel; } return(chain); }
private static IReadOnlyList <EvoCriteria> GetOriginChain(PKM pkm, int maxSpecies, int maxLevel, int 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 (int i = chain.Count - 1; i >= 0; i--) { var evo = chain[i]; if (evo.MinLevel > maxLevel) { chain.RemoveAt(i); if (chain.Any(z => z.Level >= maxLevel)) { continue; } chain.Clear(); break; } if (evo.Level > maxLevel) { evo.Level = maxLevel; } } return(chain); }
private static bool IsEvolutionValid(PKM pkm, int minSpecies = -1, int minLevel = -1) { var curr = EvolutionChain.GetValidPreEvolutions(pkm, minLevel: minLevel); var min = curr.FindLast(z => z.Species == minSpecies); if (min != null && min.Level < minLevel) { return(false); } var poss = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, minLevel: minLevel, skipChecks: true); if (minSpecies != -1) { int last = poss.FindLastIndex(z => z.Species == minSpecies); return(curr.Count >= last); } int gen = pkm.GenNumber; if (gen >= 3 && GetSplitBreedGeneration(gen).Contains(EvoBase.GetBaseSpecies(poss, 1).Species)) { return(curr.Count >= poss.Count - 1); } return(curr.Count >= poss.Count); }
private static IEnumerable <MysteryGift> GetMatchingGifts(PKM pkm, IEnumerable <MysteryGift> DB) { var vs = EvolutionChain.GetValidPreEvolutions(pkm); return(GetMatchingGifts(pkm, DB, vs)); }
internal static bool GetCanRelearnMove(PKM pkm, int move, int generation, GameVersion version = GameVersion.Any) { return(GetValidMoves(pkm, version, EvolutionChain.GetValidPreEvolutions(pkm), generation, LVL: true, Relearn: true).Contains(move)); }
public static IEnumerable <EncounterTrade> GetPossible(PKM pkm, GameVersion gameSource = GameVersion.Any) { var p = EvolutionChain.GetValidPreEvolutions(pkm); return(GetPossible(pkm, p, gameSource)); }
private static IEnumerable <GBEncounterData> GenerateRawEncounters12(PKM pkm, GameVersion game) { bool gsc = GameVersion.GSC.Contains(game); var gen = gsc ? 2 : 1; // Since encounter matching is super weak due to limited stored data in the structure // Calculate all 3 at the same time and pick the best result (by species). // Favor special event move gifts as Static Encounters when applicable var maxspeciesorigin = gsc ? MaxSpeciesID_2 : MaxSpeciesID_1; var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); HashSet <int> species = new HashSet <int>(vs.Select(p => p.Species).ToList()); var deferred = new List <IEncounterable>(); foreach (var t in GetValidEncounterTrades(pkm, vs, game)) { if (pkm.Format >= 7) { deferred.Add(t); continue; } yield return(new GBEncounterData(pkm, gen, t, t.Version)); } foreach (var s in GetValidStaticEncounter(pkm, game).Where(z => species.Contains(z.Species))) { // Valid stadium and non-stadium encounters, return only non-stadium encounters, they are less restrictive switch (s.Version) { case GameVersion.Stadium: case GameVersion.Stadium2: deferred.Add(s); continue; case GameVersion.EventsGBGen2: if (!s.EggEncounter && !pkm.HasOriginalMetLocation) { continue; } if (pkm.Japanese) { deferred.Add(s); } continue; case GameVersion.C when gsc && pkm.Format == 2: // Crystal specific data needs to be present if (!s.EggEncounter && !pkm.HasOriginalMetLocation) { continue; } if (s.Species == 251 && AllowGBCartEra) // no celebi, the GameVersion.EventsGBGen2 will pass thru { continue; } break; } yield return(new GBEncounterData(pkm, gen, s, s.Version)); } // clear egg flag // necessary for static egg gifts which appear in wild, level 8 GS clefairy // GetValidWildEncounters immediately returns empty otherwise pkm.WasEgg = false; foreach (var e in GetValidWildEncounters(pkm, game).OfType <EncounterSlot1>()) { if (!species.Contains(e.Species)) { continue; } yield return(new GBEncounterData(pkm, gen, e, e.Version)); } if (gsc) { bool WasEgg = !pkm.Gen1_NotTradeback && GetWasEgg23(pkm) && !NoHatchFromEgg.Contains(pkm.Species); if (WasEgg) { // Further Filtering if (pkm.Format < 3) { WasEgg &= pkm.Met_Location == 0 || pkm.Met_Level == 1; // 2->1->2 clears met info WasEgg &= pkm.CurrentLevel >= 5; } } if (WasEgg) { int eggspec = GetBaseEggSpecies(pkm); if (AllowGen2Crystal(pkm)) { yield return(new GBEncounterData(eggspec, GameVersion.C)); // gen2 egg } yield return(new GBEncounterData(eggspec, GameVersion.GS)); // gen2 egg } } foreach (var d in deferred) { yield return(new GBEncounterData(pkm, gen, d, game)); } }
private static IEnumerable <IEncounterable> GenerateRawEncounters12(PKM pkm, GameVersion game) { bool gsc = GameVersion.GSC.Contains(game); // Since encounter matching is super weak due to limited stored data in the structure // Calculate all 3 at the same time and pick the best result (by species). // Favor special event move gifts as Static Encounters when applicable var maxspeciesorigin = gsc ? MaxSpeciesID_2 : MaxSpeciesID_1; var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); var deferred = new List <IEncounterable>(); foreach (var t in GetValidEncounterTrades(pkm, vs, game)) { // some OTs are longer than the keyboard entry; don't defer these if (pkm.Format >= 7 && pkm.OT_Name.Length <= (pkm.Japanese || pkm.Korean ? 5 : 7)) { deferred.Add(t); continue; } yield return(t); } foreach (var s in GetValidStaticEncounter(pkm, vs, game)) { // Valid stadium and non-stadium encounters, return only non-stadium encounters, they are less restrictive switch (s.Version) { case GameVersion.Stadium: case GameVersion.Stadium2: deferred.Add(s); continue; case GameVersion.EventsGBGen2: if (!s.EggEncounter && !pkm.HasOriginalMetLocation) { continue; } if (pkm.Japanese) { deferred.Add(s); } continue; case GameVersion.C when gsc && pkm.Format == 2: // Crystal specific data needs to be present if (!s.EggEncounter && !pkm.HasOriginalMetLocation) { continue; } if (s.Species == 251 && ParseSettings.AllowGBCartEra) // no celebi, the GameVersion.EventsGBGen2 will pass thru { continue; } break; } yield return(s); } foreach (var e in GetValidWildEncounters12(pkm, vs, game)) { yield return(e); } if (gsc) { var canBeEgg = GetCanBeEgg(pkm); if (canBeEgg) { int eggspec = GetBaseEggSpecies(pkm); if (ParseSettings.AllowGen2Crystal(pkm)) { yield return new EncounterEgg { Species = eggspec, Version = GameVersion.C, Level = 5 } } ; // gen2 egg yield return(new EncounterEgg { Species = eggspec, Version = GameVersion.GS, Level = 5 }); // gen2 egg } } foreach (var d in deferred) { yield return(d); } }
private static IEnumerable <IEncounterable> GenerateRawEncounters12(PKM pkm, GameVersion game) { bool gsc = GameVersion.GSC.Contains(game); // Since encounter matching is super weak due to limited stored data in the structure // Calculate all 3 at the same time and pick the best result (by species). // Favor special event move gifts as Static Encounters when applicable var maxspeciesorigin = gsc ? MaxSpeciesID_2 : MaxSpeciesID_1; var vs = EvolutionChain.GetValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin); var deferred = new List <IEncounterable>(); foreach (var t in GetValidEncounterTrades(pkm, vs, game)) { if (pkm.Format >= 7 && (t.Generation == 2 || t.GetOT(pkm.Language) != pkm.OT_Name)) // ot length collision { deferred.Add(t); continue; } yield return(t); } foreach (var s in GetValidStaticEncounter(pkm, vs, game)) { // Valid stadium and non-stadium encounters, return only non-stadium encounters, they are less restrictive switch (s.Version) { case GameVersion.Stadium: case GameVersion.Stadium2: deferred.Add(s); continue; case GameVersion.EventsGBGen2: if (!s.EggEncounter && !pkm.HasOriginalMetLocation) { continue; } if (pkm.Japanese) { deferred.Add(s); } continue; case GameVersion.C when gsc && pkm.Format == 2: // Crystal specific data needs to be present if (!s.EggEncounter && !pkm.HasOriginalMetLocation) { continue; } if (s.Species == 251 && ParseSettings.AllowGBCartEra) // no celebi, the GameVersion.EventsGBGen2 will pass thru { continue; } break; } yield return(s); } // clear egg flag // necessary for static egg gifts which appear in wild, level 8 GS clefairy // GetValidWildEncounters immediately returns empty otherwise pkm.WasEgg = false; foreach (var e in GetValidWildEncounters12(pkm, vs, game)) { yield return(e); } if (gsc) { bool WasEgg = !pkm.Gen1_NotTradeback && GetWasEgg23(pkm) && !NoHatchFromEgg.Contains(pkm.Species); if (WasEgg) { // Further Filtering if (pkm.Format < 3) { WasEgg &= pkm.Met_Location == 0 || pkm.Met_Level == 1; // 2->1->2 clears met info WasEgg &= pkm.CurrentLevel >= 5; } } if (WasEgg) { int eggspec = GetBaseEggSpecies(pkm); if (ParseSettings.AllowGen2Crystal(pkm)) { yield return new EncounterEgg { Species = eggspec, Version = GameVersion.C, Level = 5 } } ; // gen2 egg yield return(new EncounterEgg { Species = eggspec, Version = GameVersion.GS, Level = 5 }); // gen2 egg } } foreach (var d in deferred) { yield return(d); } }
internal static EncounterSlot?GetCaptureLocation(PKM pkm) { var chain = EvolutionChain.GetValidPreEvolutions(pkm, maxLevel: 100, skipChecks: true); return(GetPossible(pkm, chain).OrderBy(z => z.LevelMin).FirstOrDefault()); }
public static IEnumerable <EncounterSlot> GetValidFriendSafari(PKM pkm) { var chain = EvolutionChain.GetValidPreEvolutions(pkm); return(GetValidFriendSafari(chain)); }