Use showdown specific gender culture for formID

Closes #1793 , the form was returning -1 because it was expecting ♀ not
F
This commit is contained in:
Kurt
2018-01-29 17:20:12 -08:00
parent 74f185591a
commit d7eae51c1f
2 changed files with 8 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ public class ShowdownSet
// String to Values
private static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" };
private static readonly string[] genders = {"M", "F", ""};
private static readonly string[] genderForms = {"", "F", ""};
private const string Language = "en";
private static readonly string[] types = Util.GetTypesList(Language);
private static readonly string[] forms = Util.GetFormsList(Language);
@@ -34,6 +35,7 @@ public class ShowdownSet
public bool Shiny { get; private set; }
public int Friendship { get; private set; } = 255;
public int Nature { get; private set; }
public int FormIndex { get; private set; }
public int[] EVs { get; private set; } = {00, 00, 00, 00, 00, 00};
public int[] IVs { get; private set; } = {31, 31, 31, 31, 31, 31};
public int[] Moves { get; private set; } = {0, 0, 0, 0};
@@ -148,6 +150,9 @@ public ShowdownSet(string input = null)
// Showdown Quirks
Form = ConvertFormFromShowdown(Form, Species, Ability);
// Set Form
string[] formStrings = PKX.GetFormList(Species, types, forms, genderForms);
FormIndex = Math.Max(0, Array.FindIndex(formStrings, z => z.Contains(Form ?? "")));
}
public string Text => GetText();
@@ -237,7 +242,7 @@ public static string GetShowdownText(PKM pkm)
if (pkm.Species == 0)
return string.Empty;
string[] Forms = PKX.GetFormList(pkm.Species, types, forms, new[] {"", "F", ""}, pkm.Format);
string[] Forms = PKX.GetFormList(pkm.Species, types, forms, genderForms, pkm.Format);
ShowdownSet Set = new ShowdownSet
{
Nickname = pkm.Nickname,
@@ -252,6 +257,7 @@ public static string GetShowdownText(PKM pkm)
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,
};

View File

@@ -1973,12 +1973,7 @@ private void LoadShowdownSetDefault(ShowdownSet Set)
Label_Gender.ForeColor = GetGenderColor(Gender);
}
// Set Form
string[] formStrings = PKX.GetFormList(Set.Species,
Util.GetTypesList("en"),
Util.GetFormsList("en"), gendersymbols, pkm.Format);
int form = Array.FindIndex(formStrings, z => z.Contains(Set.Form ?? ""));
CB_Form.SelectedIndex = Math.Min(CB_Form.Items.Count - 1, Math.Max(0, form));
CB_Form.SelectedIndex = Math.Min(CB_Form.Items.Count - 1, Set.FormIndex);
// Set Ability and Moves
int abil = Math.Max(0, Array.IndexOf(pkm.PersonalInfo.Abilities, Set.Ability));