/// <summary> /// Sets the <see cref="PKM.Gender"/> value, with special consideration for the <see cref="PKM.Format"/> values which derive the <see cref="PKM.Gender"/> value. /// </summary> /// <param name="pk">Pokémon to modify.</param> /// <param name="gender">Desired <see cref="PKM.Gender"/> value to set.</param> public static void SetGender(this PKM pk, string gender) { int g = string.IsNullOrEmpty(gender) ? pk.GetSaneGender() : PKX.GetGenderFromString(gender); pk.SetGender(g); }
public void ApplyToPKM(PKM pkm) { if (Species < 0) { return; } pkm.Species = Species; if (Nickname != null && Nickname.Length <= pkm.NickLength) { pkm.Nickname = Nickname; } else { pkm.Nickname = PKX.GetSpeciesName(pkm.Species, pkm.Language); } int gender = PKX.GetGenderFromString(Gender); pkm.Gender = Math.Max(0, gender); var list = PKX.GetFormList(pkm.Species, types, forms, genders); int formnum = Array.IndexOf(list, Form); pkm.AltForm = Math.Max(0, formnum); var abils = pkm.PersonalInfo.Abilities; int index = Array.IndexOf(abils, Ability); pkm.RefreshAbility(Math.Max(0, Math.Min(2, index))); if (Shiny && !pkm.IsShiny) { pkm.SetShinyPID(); } else if (!Shiny && pkm.IsShiny) { pkm.PID = Util.Rand32(); } pkm.CurrentLevel = Level; pkm.HeldItem = Math.Max(0, HeldItem); pkm.CurrentFriendship = Friendship; pkm.Nature = Nature; pkm.EVs = EVs; pkm.IVs = IVs; pkm.Moves = Moves; }