Minor refactoring

Moved QR text generation and tweaked a few property generations.
This commit is contained in:
Kurt 2015-09-23 23:02:26 -07:00
parent 43b2601dc6
commit f331fb95c9
3 changed files with 45 additions and 36 deletions

View File

@ -402,10 +402,11 @@ public string OT_Name
public bool IsShiny { get { return TSV == PSV; } }
public bool PKRS_Infected { get { return PKRS_Strain > 0; } }
public bool PKRS_Cured { get { return PKRS_Days == 0 && PKRS_Strain > 0; } }
public string[] ShowdownText { get { return getShowdownText(Nickname, Species, HeldItem, Ability, EVs, HPType, Move1, Move2, Move3, Move4); } }
// Complex Generated Attributes
public Image Sprite { get { return getSprite(Species, AltForm, Gender, HeldItem, IsEgg, IsShiny); } }
public Image Sprite { get { return getSprite(this); } }
public string[] ShowdownText { get { return getShowdownText(this); } }
public string[] QRText { get { return getQRText(this); } }
public int HPType
{
get { return (15 * ((IV_HP & 1) + 2 * (IV_ATK & 1) + 4 * (IV_DEF & 1) + 8 * (IV_SPE & 1) + 16 * (IV_SPA & 1) + 32 * (IV_SPD & 1))) / 63; }
@ -475,10 +476,7 @@ public byte[] Encrypt()
}
public void CalculateStats()
{
ushort[] Stats = getStats(Species, Stat_Level, Nature, AltForm,
EV_HP, EV_ATK, EV_DEF, EV_SPA, EV_SPD, EV_SPE,
IV_HP, IV_ATK, IV_DEF, IV_SPA, IV_SPD, IV_SPE);
ushort[] Stats = getStats(this);
Stat_HPMax = Stats[0];
Stat_ATK = Stats[1];
Stat_DEF = Stats[2];
@ -486,33 +484,5 @@ public void CalculateStats()
Stat_SPA = Stats[4];
Stat_SPD = Stats[5];
}
public string[] Summarize(string SpeciesName = null)
{
string[] response = new string[3];
// Summarize
string filename = Nickname;
if (Nickname != SpeciesName && SpeciesName != null)
filename += " (" + SpeciesName + ")";
response[0] = String.Format("{0} [{4}] lv{3} @ {1} -- {2}", filename, HeldItem, Nature, Stat_Level, Ability);
response[1] = String.Format("{0} / {1} / {2} / {3}", Move1, Move2, Move3, Move4);
response[2] = String.Format(
"IVs:{0}{1}{2}{3}{4}{5}"
+ Environment.NewLine + Environment.NewLine +
"EVs:{6}{7}{8}{9}{10}{11}",
Environment.NewLine + IV_HP.ToString("00"),
Environment.NewLine + IV_ATK.ToString("00"),
Environment.NewLine + IV_DEF.ToString("00"),
Environment.NewLine + IV_SPA.ToString("00"),
Environment.NewLine + IV_SPD.ToString("00"),
Environment.NewLine + IV_SPE.ToString("00"),
Environment.NewLine + EV_HP.ToString("00"),
Environment.NewLine + EV_ATK.ToString("00"),
Environment.NewLine + EV_DEF.ToString("00"),
Environment.NewLine + EV_SPA.ToString("00"),
Environment.NewLine + EV_SPD.ToString("00"),
Environment.NewLine + EV_SPE.ToString("00"));
return response;
}
}
}

View File

@ -262,6 +262,7 @@ internal static int getGender(string s)
return 1;
return 2;
}
internal static string[] getCountryRegionText(int country, int region, string lang)
{
// Get Language we're fetching for
@ -342,6 +343,40 @@ internal static string getLocation(bool eggmet, int gameorigin, int locval)
}
return null; // Shouldn't happen.
}
internal static string[] getQRText(PK6 pk6)
{
string[] response = new string[3];
// Summarize
string filename = pk6.Nickname;
if (pk6.Nickname != Main.specieslist[pk6.Species] && Main.specieslist[pk6.Species] != null)
filename += " (" + Main.specieslist[pk6.Species] + ")";
response[0] = String.Format("{0} [{4}] lv{3} @ {1} -- {2}", filename, Main.itemlist[pk6.HeldItem], Main.natures[pk6.Nature], pk6.Stat_Level, Main.abilitylist[pk6.Ability]);
response[1] = String.Format("{0} / {1} / {2} / {3}", Main.movelist[pk6.Move1], Main.movelist[pk6.Move2], Main.movelist[pk6.Move3], Main.movelist[pk6.Move4]);
response[2] = String.Format(
"IVs:{0}{1}{2}{3}{4}{5}"
+ Environment.NewLine + Environment.NewLine +
"EVs:{6}{7}{8}{9}{10}{11}",
Environment.NewLine + pk6.IV_HP.ToString("00"),
Environment.NewLine + pk6.IV_ATK.ToString("00"),
Environment.NewLine + pk6.IV_DEF.ToString("00"),
Environment.NewLine + pk6.IV_SPA.ToString("00"),
Environment.NewLine + pk6.IV_SPD.ToString("00"),
Environment.NewLine + pk6.IV_SPE.ToString("00"),
Environment.NewLine + pk6.EV_HP.ToString("00"),
Environment.NewLine + pk6.EV_ATK.ToString("00"),
Environment.NewLine + pk6.EV_DEF.ToString("00"),
Environment.NewLine + pk6.EV_SPA.ToString("00"),
Environment.NewLine + pk6.EV_SPD.ToString("00"),
Environment.NewLine + pk6.EV_SPE.ToString("00"));
return response;
}
internal static ushort[] getStats(PK6 pk6)
{
return getStats(pk6.Species, pk6.Stat_Level, pk6.Nature, pk6.AltForm,
pk6.EV_HP, pk6.EV_ATK, pk6.EV_DEF, pk6.EV_SPA, pk6.EV_SPD, pk6.EV_SPE,
pk6.IV_HP, pk6.IV_ATK, pk6.IV_DEF, pk6.IV_SPA, pk6.IV_SPD, pk6.IV_SPE);
}
internal static ushort[] getStats(int species, int level, int nature, int form,
int HP_EV, int ATK_EV, int DEF_EV, int SPA_EV, int SPD_EV, int SPE_EV,
int HP_IV, int ATK_IV, int DEF_IV, int SPA_IV, int SPD_IV, int SPE_IV)
@ -374,6 +409,7 @@ internal static string getLocation(bool eggmet, int gameorigin, int locval)
return stats;
}
// PKX Manipulation
internal static byte[] shuffleArray(byte[] pkx, uint sv)
{
@ -955,6 +991,10 @@ internal static Image getSprite(byte[] data)
return new PK6(data).Sprite;
}
internal static string[] getShowdownText(PK6 pk6)
{
return getShowdownText(pk6.Nickname, pk6.Species, pk6.HeldItem, pk6.Ability, pk6.EVs, pk6.HPType, pk6.Move1, pk6.Move2, pk6.Move3, pk6.Move4);
}
internal static string[] getShowdownText(string Nickname, int Species, int HeldItem, int Ability, int[] EVs,
int HPType, int Move1, int Move2, int Move3, int Move4)
{

View File

@ -1199,8 +1199,7 @@ private void clickQR(object sender, EventArgs e)
if (qr == null) return;
PK6 data = new PK6(pkx, "Tabs");
string[] r = data.Summarize(specieslist[data.Species]);
string[] r = new PK6(pkx, "Tabs").QRText;
new QR(qr, dragout.Image, r[0], r[1], r[2], "PKHeX @ ProjectPokemon.org").ShowDialog();
}
}