private static bool IsWithinEncounterRange(this IEncounterTemplate encounter, int lvl) { return(encounter.LevelMin <= lvl && lvl <= encounter.LevelMax); }
// Invalid encounters won't be recognized as an EncounterEgg; check if it *should* be a bred egg. private static IReadOnlyList <int> GetSuggestedRelearnInternal(this IEncounterTemplate enc, PKM pk) => enc switch {
private static int[] GetSuggestedMoves(PKM pk, EvolutionHistory evoChains, MoveSourceType types, IEncounterTemplate enc) { if (pk.IsEgg && pk.Format <= 5) // pre relearn { return(MoveList.GetBaseEggMoves(pk, pk.Species, 0, (GameVersion)pk.Version, pk.CurrentLevel)); } if (types != MoveSourceType.None) { return(GetValidMoves(pk, evoChains, types).Skip(1).ToArray()); // skip move 0 } // try to give current moves if (enc.Generation <= 2) { var lvl = pk.Format >= 7 ? pk.Met_Level : pk.CurrentLevel; var ver = enc.Version; return(MoveLevelUp.GetEncounterMoves(enc.Species, 0, lvl, ver)); } if (pk.Species == enc.Species) { return(MoveLevelUp.GetEncounterMoves(pk.Species, pk.Form, pk.CurrentLevel, (GameVersion)pk.Version)); } return(GetValidMoves(pk, evoChains, types).Skip(1).ToArray()); // skip move 0 }
private static EvoCriteria[][] GetChainAll(PKM pkm, IEncounterTemplate enc, EvoCriteria[] fullChain) { int maxgen = ParseSettings.AllowGen1Tradeback && pkm is PK1 ? 2 : pkm.Format; var GensEvoChains = GetAllEmpty(maxgen + 1); var head = 0; // inlined FIFO queue indexing var mostEvolved = fullChain[head++]; var lvl = (byte)pkm.CurrentLevel; var maxLevel = lvl; int pkGen = enc.Generation; // Iterate generations backwards // Maximum level of an earlier generation (GenX) will never be greater than a later generation (GenX+Y). int mingen = pkGen >= 3 ? pkGen : GBRestrictions.GetTradebackStatusInitial(pkm) == PotentialGBOrigin.Gen2Only ? 2 : 1; bool noxfrDecremented = true; for (int g = GensEvoChains.Length - 1; g >= mingen; g--) { if (pkGen <= 2 && g == 6) { g = 2; // skip over 6543 as it never existed in these. } if (g <= 4 && pkm.Format > 2 && pkm.Format > g && !pkm.HasOriginalMetLocation) { // Met location was lost at this point but it also means the pokemon existed in generations 1 to 4 with maximum level equals to met level var met = pkm.Met_Level; if (lvl > pkm.Met_Level) { lvl = (byte)met; } } int maxspeciesgen = g == 2 && pkm.VC1 ? MaxSpeciesID_1 : GetMaxSpeciesOrigin(g); // Remove future gen evolutions after a few special considerations: // If the pokemon origin is illegal (e.g. Gen3 Infernape) the list will be emptied -- species lineage did not exist at any evolution stage. while (mostEvolved.Species > maxspeciesgen) { if (head >= fullChain.Length) { if (g <= 2 && pkm.VC1) { GensEvoChains[pkm.Format] = NONE; // invalidate here since we haven't reached the regular invalidation } return(GensEvoChains); } if (mostEvolved.RequiresLvlUp) { // This is a Gen3 pokemon in a Gen4 phase evolution that requires level up and then transferred to Gen5+ // We can deduce that it existed in Gen4 until met level, // but if current level is met level we can also deduce it existed in Gen3 until maximum met level -1 if (g == 3 && pkm.Format > 4 && lvl == maxLevel) { lvl--; } // The same condition for Gen2 evolution of Gen1 pokemon, level of the pokemon in Gen1 games would be CurrentLevel -1 one level below Gen2 level else if (g == 1 && pkm.Format == 2 && lvl == maxLevel) { lvl--; } } mostEvolved = fullChain[head++]; } // Alolan form evolutions, remove from gens 1-6 chains if (HasAlolanForm(mostEvolved.Species)) { if (g < 7 && pkm.Format >= 7 && mostEvolved.Form > 0) { if (head >= fullChain.Length) { break; } mostEvolved = fullChain[head++]; } } GensEvoChains[g] = GetEvolutionChain(pkm, enc, mostEvolved.Species, lvl); ref var genChain = ref GensEvoChains[g]; if (genChain.Length == 0) { continue; } if (g > 2 && !pkm.HasOriginalMetLocation && g >= pkGen && noxfrDecremented) { bool isTransferred = HasMetLocationUpdatedTransfer(pkGen, g); if (!isTransferred) { continue; } noxfrDecremented = g > (pkGen != 3 ? 4 : 5); // Remove previous evolutions below transfer level // For example a gen3 Charizard in format 7 with current level 36 and met level 36, thus could never be Charmander / Charmeleon in Gen5+. // chain level for Charmander is 35, is below met level. int minlvl = GetMinLevelGeneration(pkm, g); int minIndex = Array.FindIndex(genChain, e => e.LevelMax >= minlvl); if (minIndex != -1) { genChain = genChain.AsSpan(minIndex).ToArray(); } } else if (g == 1) { // Remove Gen7 pre-evolutions and chain break scenarios if (pkm.VC1) { TrimVC1Transfer(pkm, GensEvoChains); } ref var lastGen = ref GensEvoChains[1]; var g1 = lastGen.AsSpan(); // Remove Gen2 post-evolutions (Scizor, Blissey...) if (g1[0].Species > MaxSpeciesID_1) { if (g1.Length == 1) { lastGen = Array.Empty <EvoCriteria>(); continue; // done } g1 = g1[1..];
private static List <string> GetIncorrectRibbons(PKM pkm, IReadOnlyList <EvoCriteria>[] evos, IEncounterTemplate enc) { List <string> missingRibbons = new(); List <string> invalidRibbons = new(); var ribs = GetRibbonResults(pkm, evos, enc); foreach (var bad in ribs) { (bad.Invalid ? invalidRibbons : missingRibbons).Add(bad.Name); } var result = new List <string>(); if (missingRibbons.Count > 0) { result.Add(string.Format(LRibbonFMissing_0, string.Join(", ", missingRibbons).Replace(RibbonInfo.PropertyPrefix, string.Empty))); } if (invalidRibbons.Count > 0) { result.Add(string.Format(LRibbonFInvalid_0, string.Join(", ", invalidRibbons).Replace(RibbonInfo.PropertyPrefix, string.Empty))); } return(result); }
private static void AddEdgeCaseMoves(List <int> moves, IEncounterTemplate encounter, PKM pkm) { if (pkm is IBattleVersion { BattleVersion : not 0 })
/// <summary> /// Sets the contests stats as requested. /// </summary> /// <param name="pk">Pokémon to modify.</param> /// <param name="enc">Encounter matched to.</param> /// <param name="option">Option to apply with</param> public static ModifyResult SetContestStats(PKM pk, IEncounterTemplate enc, string option) { if (option.Length != 0 && option[BatchEditing.CONST_SUGGEST.Length..] is not "0") { pk.SetMaxContestStats(enc); }
public abstract bool IsInvalidGeneralLocationMemoryValue(byte memory, ushort variable, IEncounterTemplate enc, PKM pk);