/// <summary> /// Checks if the encounter is even valid before processing it /// </summary> /// <param name="set">showdown set</param> /// <param name="enc">encounter object</param> /// <param name="isHidden">is HA requested</param> /// <param name="destVer">version to generate in</param> /// <param name="ver">version of enc/destVer</param> /// <returns>if the encounter is valid or not</returns> private static bool IsEncounterValid(IBattleTemplate set, IEncounterable enc, bool isHidden, GameVersion destVer, out GameVersion ver) { // Pokemon who are in games of generation >= 8 can change non HA to HA via a capsule and vice versa isHidden = isHidden && destVer.GetGeneration() < 8; // initialize out vars (not calculating here to save time) ver = GameVersion.Any; // Don't process if encounter min level is higher than requested level if (enc.LevelMin > set.Level) { var isRaid = enc is EncounterStatic8N || enc is EncounterStatic8NC || enc is EncounterStatic8ND || enc is EncounterStatic8U; if (!isRaid) { return(false); } } // Don't process if Hidden Ability is requested and the PKM is from Gen 3 or Gen 4 var gen = enc.Generation; if (isHidden && (uint)(gen - 3) < 2) // Gen 3 and Gen 4 { return(false); } // Don't process if requested PKM is Gigantamax but the Game is not SW/SH ver = enc is IVersion v ? v.Version : destVer; if (set.CanGigantamax && !GameVersion.SWSH.Contains(ver)) { return(false); } // Don't process if Game is LGPE and requested PKM is not Kanto / Meltan / Melmetal // Don't process if Game is SWSH and requested PKM is not from the Galar Dex (Zukan8.DexLookup) if (GameVersion.GG.Contains(destVer)) { return(set.Species <= 151 || set.Species == 808 || set.Species == 809); } if (GameVersion.SWSH.Contains(destVer)) { return(((PersonalInfoSWSH)PersonalTable.SWSH.GetFormeEntry(set.Species, set.FormIndex)).IsPresentInGame || SimpleEdits.Zukan8Additions.Contains(set.Species)); } if (set.Species > destVer.GetMaxSpeciesID()) { return(false); } // Encounter should hopefully be possible return(true); }
public PersonalTable(byte[] data, GameVersion format) { var get = GetConstructor(format); int size = GetEntrySize(format); byte[][] entries = SplitBytes(data, size); Table = new PersonalInfo[data.Length / size]; for (int i = 0; i < Table.Length; i++) { Table[i] = get(entries[i]); } MaxSpeciesID = format.GetMaxSpeciesID(); }
/// <summary> /// Checks if the encounter is even valid before processing it /// </summary> /// <param name="set">showdown set</param> /// <param name="enc">encounter object</param> /// <param name="isHidden">is HA requested</param> /// <param name="destVer">version to generate in</param> /// <param name="ver">version of enc/destVer</param> /// <returns>if the encounter is valid or not</returns> private static bool IsEncounterValid(IBattleTemplate set, IEncounterable enc, bool isHidden, GameVersion destVer, out GameVersion ver) { // initialize out vars (not calculating here to save time) ver = GameVersion.Any; // Don't process if encounter min level is higher than requested level if (enc.LevelMin > set.Level) { if (!(enc is EncounterStatic8N)) { return(false); } } // Don't process if Hidden Ability is requested and the PKM is from Gen 3 or Gen 4 var gen = enc.Generation; if (isHidden && (uint)(gen - 3) < 2) // Gen 3 and Gen 4 { return(false); } // Don't process if requested PKM is Gigantamax but the Game is not SW/SH ver = enc is IVersion v ? v.Version : destVer; if (set.CanGigantamax && !GameVersion.SWSH.Contains(ver)) { return(false); } // Don't process if Game is LGPE and requested PKM is not Kanto / Meltan / Melmetal // Don't process if Game is SWSH and requested PKM is not from the Galar Dex (Zukan8.DexLookup) var species = Enumerable.Range(1, destVer.GetMaxSpeciesID()); if (GameVersion.GG.Contains(destVer)) { species = species.Where(z => z <= 151 || (z == 808 || z == 809)); } if (GameVersion.SWSH.Contains(destVer)) { species = species.Where(z => Zukan8.DexLookup.TryGetValue(z, out _) || SimpleEdits.Zukan8Additions.Contains(z)); } if (!species.Contains(set.Species)) { return(false); } // Encounter should hopefully be possible return(true); }