private CheckResult VerifyForm(LegalityAnalysis data) { var pkm = data.pkm; var PersonalInfo = data.PersonalInfo; int count = PersonalInfo.FormeCount; var form = pkm.AltForm; if (count <= 1 && form == 0) { return(VALID); // no forms to check } var species = pkm.Species; var EncounterMatch = data.EncounterMatch; var Info = data.Info; if (!PersonalInfo.IsFormeWithinRange(form) && !FormConverter.IsValidOutOfBoundsForme(species, form, Info.Generation)) { return(GetInvalid(string.Format(LFormInvalidRange, count - 1, form))); } if (EncounterMatch is EncounterSlot w && w.Area.Type == SlotType.FriendSafari) { VerifyFormFriendSafari(data); }
public override void Verify(LegalityAnalysis data) { var pkm = data.pkm; if (pkm.Format < 4) { return; // no forms exist } var PersonalInfo = data.PersonalInfo; var EncounterMatch = data.EncounterMatch; var Info = data.Info; int count = PersonalInfo.FormeCount; if (count <= 1 && pkm.AltForm == 0) { return; // no forms to check } if (!PersonalInfo.IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, Info.Generation)) { data.AddLine(GetInvalid(string.Format(V304, count - 1, pkm.AltForm))); return; } if (EncounterMatch is EncounterSlot w && w.Type == SlotType.FriendSafari) { VerifyFormFriendSafari(data); }
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <DexLevel> vs, bool all = false) { if (NoHatchFromEgg.Contains(pkm.Species)) { yield break; } if (FormConverter.IsTotemForm(pkm.Species, pkm.AltForm, pkm.GenNumber)) { yield break; // no totem eggs } int gen = pkm.GenNumber; if (gen <= 1) { yield break; // can't get eggs } // version is a true indicator for all generation 3-5 origins var ver = (GameVersion)pkm.Version; int max = GetMaxSpeciesOrigin(gen); var baseSpecies = GetBaseSpecies(pkm, vs, 0); int lvl = GetEggHatchLevel(gen); if (baseSpecies <= max) { yield return(new EncounterEgg { Version = ver, Level = lvl, Species = baseSpecies }); if (gen > 5 && (pkm.WasTradedEgg || all)) { yield return new EncounterEgg { Version = GetOtherTradePair(ver), Level = lvl, Species = baseSpecies } } ; } if (!GetSplitBreedGeneration(pkm).Contains(pkm.Species)) { yield break; // no other possible species } var other = GetBaseSpecies(pkm, vs, 1); if (other <= max) { yield return(new EncounterEggSplit { Version = ver, Level = lvl, Species = other, OtherSpecies = baseSpecies }); if (gen > 5 && (pkm.WasTradedEgg || all)) { yield return new EncounterEggSplit { Version = GetOtherTradePair(ver), Level = lvl, Species = other, OtherSpecies = baseSpecies } } ; } }
private static IReadOnlyList <string> GetSaveFileErrata(this SaveFile sav, PKM pkm, IBasicStrings strings) { var errata = new List <string>(); ushort held = (ushort)pkm.HeldItem; if (sav.Generation > 1 && held != 0) { string?msg = null; if (held > sav.MaxItemID) { msg = MsgIndexItemGame; } else if (!pkm.CanHoldItem(sav.HeldItems)) { msg = MsgIndexItemHeld; } if (msg != null) { var itemstr = GameInfo.Strings.GetItemStrings(pkm.Format, (GameVersion)pkm.Version); errata.Add($"{msg} {(held >= itemstr.Count ? held.ToString() : itemstr[held])}"); } } if (pkm.Species > strings.Species.Count) { errata.Add($"{MsgIndexSpeciesRange} {pkm.Species}"); } else if (sav.MaxSpeciesID < pkm.Species) { errata.Add($"{MsgIndexSpeciesGame} {strings.Species[pkm.Species]}"); } if (!sav.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber)) { errata.Add(string.Format(LegalityCheckStrings.LFormInvalidRange, Math.Max(0, sav.Personal[pkm.Species].FormeCount - 1), pkm.AltForm)); } if (pkm.Moves.Any(m => m > strings.Move.Count)) { errata.Add($"{MsgIndexMoveRange} {string.Join(", ", pkm.Moves.Where(m => m > strings.Move.Count).Select(m => m.ToString()))}"); } else if (pkm.Moves.Any(m => m > sav.MaxMoveID)) { errata.Add($"{MsgIndexMoveGame} {string.Join(", ", pkm.Moves.Where(m => m > sav.MaxMoveID).Select(m => strings.Move[m]))}"); } if (pkm.Ability > strings.Ability.Count) { errata.Add($"{MsgIndexAbilityRange} {pkm.Ability}"); } else if (pkm.Ability > sav.MaxAbilityID) { errata.Add($"{MsgIndexAbilityGame} {strings.Ability[pkm.Ability]}"); } return(errata); }
private static IReadOnlyList <string> GetSaveFileErrata(this SaveFile SAV, PKM pkm, IBasicStrings strings) { var errata = new List <string>(); if (SAV.Generation > 1) { ushort held = (ushort)pkm.HeldItem; if (held > strings.Item.Count) { errata.Add($"{MsgIndexItemRange} {held}"); } else if (held > SAV.MaxItemID) { errata.Add($"{MsgIndexItemGame} {strings.Item[held]}"); } else if (!pkm.CanHoldItem(SAV.HeldItems)) { errata.Add($"{MsgIndexItemHeld} {strings.Item[held]}"); } } if (pkm.Species > strings.Species.Count) { errata.Add($"{MsgIndexSpeciesRange} {pkm.Species}"); } else if (SAV.MaxSpeciesID < pkm.Species) { errata.Add($"{MsgIndexSpeciesGame} {strings.Species[pkm.Species]}"); } if (!SAV.Personal[pkm.Species].IsFormeWithinRange(pkm.AltForm) && !FormConverter.IsValidOutOfBoundsForme(pkm.Species, pkm.AltForm, pkm.GenNumber)) { errata.Add(string.Format(LegalityCheckStrings.V304, Math.Max(0, SAV.Personal[pkm.Species].FormeCount - 1), pkm.AltForm)); } if (pkm.Moves.Any(m => m > strings.Move.Count)) { errata.Add($"{MsgIndexMoveRange} {string.Join(", ", pkm.Moves.Where(m => m > strings.Move.Count).Select(m => m.ToString()))}"); } else if (pkm.Moves.Any(m => m > SAV.MaxMoveID)) { errata.Add($"{MsgIndexMoveGame} {string.Join(", ", pkm.Moves.Where(m => m > SAV.MaxMoveID).Select(m => strings.Move[m]))}"); } if (pkm.Ability > strings.Ability.Count) { errata.Add($"{MsgIndexAbilityRange} {pkm.Ability}"); } else if (pkm.Ability > SAV.MaxAbilityID) { errata.Add($"{MsgIndexAbilityGame} {strings.Ability[pkm.Ability]}"); } return(errata); }
/// <summary> /// Gets the Form ID from the input <see cref="name"/>. /// </summary> /// <param name="name"></param> /// <param name="strings"></param> /// <param name="species">Species ID the form belongs to</param> /// <param name="format">Format the form name should appear in</param> /// <returns>Zero (base form) if no form matches the input string.</returns> public static int GetFormFromString(string name, GameStrings strings, int species, int format) { if (name.Length == 0) { return(0); } string[] formStrings = FormConverter.GetFormList(species, strings.Types, strings.forms, genderForms, format); return(Math.Max(0, Array.FindIndex(formStrings, z => z.Contains(name)))); }
/// <summary> /// Converts a Form ID to string. /// </summary> /// <param name="form"></param> /// <param name="strings"></param> /// <param name="species"></param> /// <param name="format"></param> /// <returns></returns> public static string GetStringFromForm(int form, GameStrings strings, int species, int format) { if (form <= 0) { return(string.Empty); } var forms = FormConverter.GetFormList(species, strings.Types, strings.forms, genderForms, format); return(form >= forms.Length ? string.Empty : forms[form]); }
public void SetFormString(int index) { FormIndex = index; if (index <= 0) { Form = string.Empty; return; } var Forms = FormConverter.GetFormList(Species, Strings.Types, Strings.forms, genderForms, Format); Form = FormIndex >= Forms.Length ? string.Empty : Forms[index]; }
private static bool NoHatchFromEggForm(int species, int form, int gen) { if (FormConverter.IsTotemForm(species, form, gen)) { return(true); } if ((species == (int)Species.Sinistea || species == (int)Species.Polteageist) && form != 0) // Chipped = impossible { return(true); // can't get Chipped eggs } return(false); }
protected override bool IsMatchForm(PKM pkm, DexLevel evo) { if (SkipFormCheck) { return(true); } if (FormConverter.IsTotemForm(Species, Form, Generation)) { var expectForm = pkm.Format == 7 ? Form : FormConverter.GetTotemBaseForm(Species, Form); return(expectForm == evo.Form); } return(Form == evo.Form || Legal.IsFormChangeable(Species, Form, pkm.AltForm, pkm.Format)); }
private void LoadLines(IEnumerable <string> lines) { lines = lines.Select(z => z.Replace('\'', '’').Replace('–', '-').Trim()); // Sanitize apostrophes & dashes lines = lines.Where(z => z.Length > 2); ParseLines(lines); Form = ConvertFormFromShowdown(Form, Species, Ability); // Set Form if (Form.Length == 0) { FormIndex = 0; return; } string[] formStrings = FormConverter.GetFormList(Species, Strings.Types, Strings.forms, genderForms, Format); FormIndex = Math.Max(0, Array.FindIndex(formStrings, z => z.Contains(Form))); }
private static bool NoHatchFromEggForm(int species, int form, int gen) { if (form == 0) { return(false); } if (FormConverter.IsTotemForm(species, form, gen)) { return(true); } if (species == (int)Species.Pichu) { return(true); // can't get Spiky Ear Pichu eggs } if (species == (int)Species.Sinistea || species == (int)Species.Polteageist) // Antique = impossible { return(true); // can't get Antique eggs } return(false); }
private static IEnumerable <EncounterSlot> GetFilteredSlots67(PKM pkm, IEnumerable <EncounterSlot> encounterSlots) { int species = pkm.Species; int form = pkm.AltForm; // Edge Case Handling switch (species) { case 744 when form == 1: // Rockruff Event case 745 when form == 2: // Lycanroc Event yield break; } EncounterSlot slotMax = null; void CachePressureSlot(EncounterSlot s) { if (slotMax != null && s.LevelMax > slotMax.LevelMax) { slotMax = s; } } if (AlolanVariantEvolutions12.Contains(species)) // match form if same species, else form 0. { foreach (var slot in encounterSlots) { if (species == slot.Species ? slot.Form == form : slot.Form == 0) { yield return(slot); } CachePressureSlot(slot); } } else if (ShouldMatchSlotForm()) // match slot form { foreach (var slot in encounterSlots) { if (slot.Form == form) { yield return(slot); } CachePressureSlot(slot); } } else { foreach (var slot in encounterSlots) { yield return(slot); // no form checking CachePressureSlot(slot); } } // Filter for Form Specific // Pressure Slot if (slotMax == null) { yield break; } if (AlolanVariantEvolutions12.Contains(species)) // match form if same species, else form 0. { if (species == slotMax.Species ? slotMax.Form == form : slotMax.Form == 0) { yield return(GetPressureSlot(slotMax, pkm)); } } else if (ShouldMatchSlotForm()) // match slot form { if (slotMax.Form == form) { yield return(GetPressureSlot(slotMax, pkm)); } } else { yield return(GetPressureSlot(slotMax, pkm)); } bool ShouldMatchSlotForm() => WildForms.Contains(species) || AlolanOriginForms.Contains(species) || FormConverter.IsTotemForm(species, form); }
/// <summary> /// Gets a list of formes that the species can have. /// </summary> /// <param name="species">National Dex number of the Pokémon.</param> /// <param name="types">List of type names</param> /// <param name="forms">List of form names</param> /// <param name="genders">List of genders names</param> /// <param name="generation">Generation number for exclusive formes</param> /// <returns>A list of strings corresponding to the formes that a Pokémon can have.</returns> public static string[] GetFormList(int species, string[] types, string[] forms, string[] genders, int generation = Generation) { return(FormConverter.GetFormList(species, types, forms, genders, generation)); }
/// <summary> /// Gets a list of formes that the species can have. /// </summary> /// <param name="species">National Dex number of the Pokémon.</param> /// <param name="types">List of type names</param> /// <param name="forms">List of form names</param> /// <param name="genders">List of genders names</param> /// <param name="generation">Generation number for exclusive formes</param> /// <returns>A list of strings corresponding to the formes that a Pokémon can have.</returns> public static string[] GetFormList(int species, IReadOnlyList <string> types, IReadOnlyList <string> forms, IReadOnlyList <string> genders, int generation = Generation) { return(FormConverter.GetFormList(species, types, forms, genders, generation)); }
public static IEnumerable <EncounterEgg> GenerateEggs(PKM pkm, IReadOnlyList <EvoCriteria> vs, bool all = false) { int species = pkm.Species; if (NoHatchFromEgg.Contains(species)) { yield break; } int gen = pkm.GenNumber; if (gen <= 1) { yield break; // can't get eggs } if (FormConverter.IsTotemForm(species, pkm.AltForm, gen)) { yield break; // no totem eggs } // version is a true indicator for all generation 3-5 origins var ver = (GameVersion)pkm.Version; int lvl = GetEggHatchLevel(gen); int max = GetMaxSpeciesOrigin(gen); var e = GetBaseSpecies(species, vs, 0); if (e.Species <= max) { yield return(new EncounterEgg(e.Species, e.Form, lvl) { Version = ver }); if (gen > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return new EncounterEgg(e.Species, e.Form, lvl) { Version = GetOtherTradePair(ver) } } ; } if (!GetSplitBreedGeneration(gen).Contains(species)) { yield break; // no other possible species } var o = GetBaseSpecies(species, vs, 1); if (o.Species <= max) { yield return(new EncounterEggSplit(o.Species, o.Form, lvl, e.Species) { Version = ver }); if (gen > 5 && (pkm.WasTradedEgg || all) && HasOtherGamePair(ver)) { yield return new EncounterEggSplit(o.Species, o.Form, lvl, e.Species) { Version = GetOtherTradePair(ver) } } ; } }