/// <summary> /// Converts the <see cref="PKM"/> data into an importable set format for Pokémon Showdown. /// </summary> /// <param name="pkm">PKM to convert to string</param> /// <returns>Multi line set data</returns> public static string GetShowdownText(PKM pkm) { if (pkm.Species == 0) { return(string.Empty); } string[] Forms = PKX.GetFormList(pkm.Species, types, forms, genderForms, pkm.Format); ShowdownSet Set = new ShowdownSet { Nickname = pkm.Nickname, Species = pkm.Species, HeldItem = pkm.HeldItem, Ability = pkm.Ability, EVs = pkm.EVs, IVs = pkm.IVs, Moves = pkm.Moves, Nature = pkm.Nature, Gender = genders[pkm.Gender < 2 ? pkm.Gender : 2], Friendship = pkm.CurrentFriendship, Level = PKX.GetLevel(pkm.Species, pkm.EXP), Shiny = pkm.IsShiny, FormIndex = pkm.AltForm, Form = pkm.AltForm > 0 && pkm.AltForm < Forms.Length ? Forms[pkm.AltForm] : string.Empty, Format = pkm.Format, }; if (Set.Form == "F") { Set.Gender = string.Empty; } return(Set.Text); }
public static string getShowdownText(PKM pkm) { if (pkm.Species == 0) { return(""); } string[] Forms = PKX.getFormList(pkm.Species, types, forms, new[] { "", "F", "" }, pkm.Format); ShowdownSet Set = new ShowdownSet { Nickname = pkm.Nickname, Species = pkm.Species, Item = pkm.HeldItem, Ability = pkm.Ability, EVs = pkm.EVs, IVs = pkm.IVs, Moves = pkm.Moves, Nature = pkm.Nature, Gender = new[] { "M", "F", "" }[pkm.Gender < 2 ? pkm.Gender: 2], Friendship = pkm.CurrentFriendship, Level = PKX.getLevel(pkm.Species, pkm.EXP), Shiny = pkm.IsShiny, Form = pkm.AltForm > 0 && pkm.AltForm < Forms.Length ? Forms[pkm.AltForm] : "", }; if (Set.Form == "F") { Set.Gender = ""; } return(Set.getText()); }
public static string getShowdownText(PKM pkm) { if (pkm.Species == 0) return ""; string[] Forms = PKX.getFormList(pkm.Species, types, forms, new[] {"", "F", ""}, pkm.Format); ShowdownSet Set = new ShowdownSet { Nickname = pkm.Nickname, Species = pkm.Species, Item = pkm.HeldItem, Ability = pkm.Ability, EVs = pkm.EVs, IVs = pkm.IVs, Moves = pkm.Moves, Nature = pkm.Nature, Gender = new[] { "M", "F", "" }[pkm.Gender < 2 ? pkm.Gender : 2], Friendship = pkm.CurrentFriendship, Level = PKX.getLevel(pkm.Species, pkm.EXP), Shiny = pkm.IsShiny, Form = pkm.AltForm > 0 && pkm.AltForm < Forms.Length ? Forms[pkm.AltForm] : "", }; if (Set.Form == "F") Set.Gender = ""; return Set.getText(); }
// Misc Options private void clickShowdownImportPKM(object sender, EventArgs e) { if (!formInitialized) return; if (!Clipboard.ContainsText()) { WinFormsUtil.Alert("Clipboard does not contain text."); return; } // Get Simulator Data ShowdownSet Set = new ShowdownSet(Clipboard.GetText()); if (Set.Species < 0) { WinFormsUtil.Alert("Set data not found in clipboard."); return; } if (Set.Nickname != null && Set.Nickname.Length > SAV.NickLength) Set.Nickname = Set.Nickname.Substring(0, SAV.NickLength); if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Import this set?", Set.getText())) { return; } if (Set.InvalidLines.Any()) WinFormsUtil.Alert("Invalid lines detected:", string.Join(Environment.NewLine, Set.InvalidLines)); // Set Species & Nickname CB_Species.SelectedValue = Set.Species; CHK_Nicknamed.Checked = Set.Nickname != null; if (Set.Nickname != null) TB_Nickname.Text = Set.Nickname; if (Set.Gender != null) { int Gender = PKX.getGender(Set.Gender); Label_Gender.Text = gendersymbols[Gender]; Label_Gender.ForeColor = Gender == 2 ? Label_Species.ForeColor : (Gender == 1 ? Color.Red : Color.Blue); } // Set Form string[] formStrings = PKX.getFormList(Set.Species, Util.getTypesList("en"), Util.getFormsList("en"), gendersymbols, SAV.Generation); int form = 0; for (int i = 0; i < formStrings.Length; i++) if (formStrings[i].Contains(Set.Form ?? "")) { form = i; break; } CB_Form.SelectedIndex = Math.Min(CB_Form.Items.Count-1, form); // Set Ability int[] abilities = SAV.Personal.getAbilities(Set.Species, form); int ability = Array.IndexOf(abilities, Set.Ability); if (ability < 0) ability = 0; CB_Ability.SelectedIndex = ability; ComboBox[] m = {CB_Move1, CB_Move2, CB_Move3, CB_Move4}; for (int i = 0; i < 4; i++) m[i].SelectedValue = Set.Moves[i]; // Set Item and Nature CB_HeldItem.SelectedValue = Set.Item < 0 ? 0 : Set.Item; CB_Nature.SelectedValue = Set.Nature < 0 ? 0 : Set.Nature; // Set IVs TB_HPIV.Text = Set.IVs[0].ToString(); TB_ATKIV.Text = Set.IVs[1].ToString(); TB_DEFIV.Text = Set.IVs[2].ToString(); TB_SPAIV.Text = Set.IVs[4].ToString(); TB_SPDIV.Text = Set.IVs[5].ToString(); TB_SPEIV.Text = Set.IVs[3].ToString(); // Set EVs TB_HPEV.Text = Set.EVs[0].ToString(); TB_ATKEV.Text = Set.EVs[1].ToString(); TB_DEFEV.Text = Set.EVs[2].ToString(); TB_SPAEV.Text = Set.EVs[4].ToString(); TB_SPDEV.Text = Set.EVs[5].ToString(); TB_SPEEV.Text = Set.EVs[3].ToString(); // Set Level and Friendship TB_Level.Text = Set.Level.ToString(); TB_Friendship.Text = Set.Friendship.ToString(); // Reset IV/EVs BTN_RerollPID.PerformClick(); BTN_RerollEC.PerformClick(); ComboBox[] p = {CB_PPu1, CB_PPu2, CB_PPu3, CB_PPu4}; for (int i = 0; i < 4; i++) p[i].SelectedIndex = m[i].SelectedIndex != 0 ? 3 : 0; // max PP if (Set.Shiny) BTN_Shinytize.PerformClick(); pkm = preparePKM(); updateLegality(); }