2016-06-20 04:22:43 +00:00
|
|
|
|
using System;
|
2016-09-04 06:14:05 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
public class ShowdownSet
|
|
|
|
|
{
|
|
|
|
|
// String to Values
|
2016-09-20 05:59:15 +00:00
|
|
|
|
private static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" };
|
2016-10-06 04:06:24 +00:00
|
|
|
|
private static readonly string[] types = Util.getTypesList("en");
|
|
|
|
|
private static readonly string[] forms = Util.getFormsList("en");
|
2016-08-08 20:11:02 +00:00
|
|
|
|
private static readonly string[] species = Util.getSpeciesList("en");
|
2016-10-06 04:06:24 +00:00
|
|
|
|
private static readonly string[] items = Util.getItemsList("en");
|
|
|
|
|
private static readonly string[] natures = Util.getNaturesList("en");
|
2016-08-08 20:11:02 +00:00
|
|
|
|
private static readonly string[] moves = Util.getMovesList("en");
|
|
|
|
|
private static readonly string[] abilities = Util.getAbilitiesList("en");
|
2016-06-20 04:22:43 +00:00
|
|
|
|
private static readonly string[] hptypes = types.Skip(1).ToArray();
|
2016-11-22 18:54:49 +00:00
|
|
|
|
private const int MAX_SPECIES = 802;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
|
|
|
|
|
// Default Set Data
|
2016-09-20 05:59:15 +00:00
|
|
|
|
public string Nickname { get; set; }
|
|
|
|
|
public int Species { get; private set; } = -1;
|
|
|
|
|
public string Form { get; private set; }
|
|
|
|
|
public string Gender { get; private set; }
|
|
|
|
|
public int Item { get; private set; }
|
|
|
|
|
public int Ability { get; private set; }
|
|
|
|
|
public int Level { get; private set; } = 100;
|
|
|
|
|
public bool Shiny { get; private set; }
|
|
|
|
|
public int Friendship { get; private set; } = 255;
|
|
|
|
|
public int Nature { 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};
|
2016-09-10 02:13:48 +00:00
|
|
|
|
public readonly List<string> InvalidLines = new List<string>();
|
2016-06-20 04:22:43 +00:00
|
|
|
|
|
2016-09-20 05:59:15 +00:00
|
|
|
|
private int[] IVsSpeedFirst => new[] {IVs[0], IVs[1], IVs[2], IVs[5], IVs[3], IVs[4]};
|
|
|
|
|
private int[] IVsSpeedLast => new[] {IVs[0], IVs[1], IVs[2], IVs[4], IVs[5], IVs[3]};
|
|
|
|
|
private int[] EVsSpeedFirst => new[] {EVs[0], EVs[1], EVs[2], EVs[5], EVs[3], EVs[4]};
|
|
|
|
|
private int[] EVsSpeedLast => new[] {EVs[0], EVs[1], EVs[2], EVs[4], EVs[5], EVs[3]};
|
2016-09-18 05:10:27 +00:00
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
// Parsing Utility
|
|
|
|
|
public ShowdownSet(string input = null)
|
|
|
|
|
{
|
|
|
|
|
if (input == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string[] lines = input.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
|
|
|
|
|
for (int i = 0; i < lines.Length; i++) lines[i] = lines[i].Replace("'", "’").Trim(); // Sanitize apostrophes
|
|
|
|
|
|
2016-09-20 05:59:15 +00:00
|
|
|
|
lines = lines.Where(line => line.Length > 2).ToArray();
|
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
if (lines.Length < 3) return;
|
|
|
|
|
|
|
|
|
|
// Seek for start of set
|
2016-09-20 05:59:15 +00:00
|
|
|
|
int start = Array.FindIndex(lines, line => line.Contains(" @ "));
|
|
|
|
|
|
|
|
|
|
if (start != -1) // Has Item -- skip to start.
|
|
|
|
|
lines = lines.Skip(start).Take(lines.Length - start).ToArray();
|
|
|
|
|
else // Has no Item -- try parsing the first line anyway.
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
parseFirstLine(lines[0]);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
if (Species < -1)
|
2016-09-20 05:59:15 +00:00
|
|
|
|
return; // Abort if no text is found
|
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
lines = lines.Skip(1).Take(lines.Length - 1).ToArray();
|
|
|
|
|
}
|
|
|
|
|
int movectr = 0;
|
|
|
|
|
// Detect relevant data
|
|
|
|
|
foreach (string line in lines)
|
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
if (line.StartsWith("-"))
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
string moveString = parseLineMove(line);
|
2016-09-18 05:10:27 +00:00
|
|
|
|
int move = Array.IndexOf(moves, moveString);
|
|
|
|
|
if (move < 0)
|
|
|
|
|
InvalidLines.Add($"Unknown Move: {moveString}");
|
|
|
|
|
else
|
|
|
|
|
Moves[movectr++] = move;
|
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
if (movectr == 4)
|
|
|
|
|
break; // End of moves
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string[] brokenline = line.Split(new[] { ": " }, StringSplitOptions.None);
|
2017-01-29 08:32:02 +00:00
|
|
|
|
if (brokenline.Length == 1)
|
|
|
|
|
brokenline = new[] {brokenline[0], ""};
|
2016-06-20 04:22:43 +00:00
|
|
|
|
switch (brokenline[0])
|
|
|
|
|
{
|
|
|
|
|
case "Trait":
|
2016-09-20 05:59:15 +00:00
|
|
|
|
case "Ability": { Ability = Array.IndexOf(abilities, brokenline[1].Trim()); break; }
|
|
|
|
|
case "Level": { Level = Util.ToInt32(brokenline[1].Trim()); break; }
|
|
|
|
|
case "Shiny": { Shiny = brokenline[1].Trim() == "Yes"; break; }
|
|
|
|
|
case "Happiness": { Friendship = Util.ToInt32(brokenline[1].Trim()); break; }
|
|
|
|
|
case "Nature": { Nature = Array.IndexOf(natures, brokenline[1].Trim()); break; }
|
|
|
|
|
case "EV":
|
|
|
|
|
case "EVs": { parseLineEVs(brokenline[1].Trim()); break; }
|
|
|
|
|
case "IV":
|
|
|
|
|
case "IVs": { parseLineIVs(brokenline[1].Trim()); break; }
|
2016-12-17 17:54:22 +00:00
|
|
|
|
case "Type": { brokenline = new[] {line}; goto default; } // Type: Null edge case
|
2016-09-20 05:59:15 +00:00
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
// Either Nature or Gender ItemSpecies
|
|
|
|
|
if (brokenline[0].Contains(" @ "))
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
string[] pieces = line.Split(new[] {" @ "}, StringSplitOptions.None);
|
|
|
|
|
string itemstr = pieces.Last().Trim();
|
|
|
|
|
int item = Array.IndexOf(items, itemstr);
|
|
|
|
|
if (item < 0)
|
|
|
|
|
InvalidLines.Add($"Unknown Item: {itemstr}");
|
|
|
|
|
else
|
|
|
|
|
Item = item;
|
|
|
|
|
|
|
|
|
|
parseFirstLine(pieces[0]);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
2016-09-20 05:59:15 +00:00
|
|
|
|
else if (brokenline[0].Contains("Nature"))
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
string naturestr = line.Split(' ')[0].Trim();
|
|
|
|
|
int nature = Array.IndexOf(natures, naturestr);
|
2016-11-27 03:23:19 +00:00
|
|
|
|
if (nature < 0)
|
2016-09-20 05:59:15 +00:00
|
|
|
|
InvalidLines.Add($"Unknown Nature: {naturestr}");
|
|
|
|
|
else
|
|
|
|
|
Nature = nature;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
2016-09-20 05:59:15 +00:00
|
|
|
|
else // Fallback
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
string speciesstr = line.Split('(')[0].Trim();
|
|
|
|
|
int spec = Array.IndexOf(species, speciesstr);
|
|
|
|
|
if (spec < 1)
|
|
|
|
|
InvalidLines.Add(speciesstr);
|
|
|
|
|
else
|
|
|
|
|
Species = spec;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2016-09-20 05:59:15 +00:00
|
|
|
|
}
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-18 05:10:27 +00:00
|
|
|
|
|
|
|
|
|
IVs = IVsSpeedFirst;
|
|
|
|
|
EVs = EVsSpeedFirst;
|
2016-12-23 23:37:56 +00:00
|
|
|
|
|
|
|
|
|
// Showdown Quirks
|
|
|
|
|
switch (Species)
|
|
|
|
|
{
|
2016-12-24 23:50:26 +00:00
|
|
|
|
case 658: // Greninja
|
2017-02-03 01:50:58 +00:00
|
|
|
|
if (Ability == 210) Form = "Ash"; // Battle Bond
|
2016-12-24 23:50:26 +00:00
|
|
|
|
break;
|
2017-02-03 00:58:22 +00:00
|
|
|
|
case 666: // Vivillon
|
|
|
|
|
if (Form == "Pokeball") Form = "Poké Ball";
|
|
|
|
|
break;
|
2016-12-23 23:37:56 +00:00
|
|
|
|
case 718: // Zygarde
|
|
|
|
|
if (string.IsNullOrEmpty(Form)) Form = "50%";
|
|
|
|
|
else if (Form == "Complete") Form = "100%";
|
|
|
|
|
if (Ability == 211) Form += "-C"; // Power Construct
|
|
|
|
|
break;
|
|
|
|
|
case 774: // Minior
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Form) && Form != "Meteor")
|
|
|
|
|
Form = "C-" + Form;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
public string getText()
|
|
|
|
|
{
|
2016-09-20 05:59:15 +00:00
|
|
|
|
if (Species == 0 || Species > MAX_SPECIES)
|
2016-06-20 04:22:43 +00:00
|
|
|
|
return "";
|
|
|
|
|
|
2016-12-23 23:37:56 +00:00
|
|
|
|
// Showdown Quirks
|
|
|
|
|
string form = Form;
|
2017-02-03 00:33:27 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(form))
|
2016-12-23 23:37:56 +00:00
|
|
|
|
{
|
2017-02-03 00:33:27 +00:00
|
|
|
|
switch (Species)
|
|
|
|
|
{
|
|
|
|
|
case 658: // Greninja
|
|
|
|
|
form = form.Replace("Ash", "");
|
|
|
|
|
form = form.Replace("Active", "");
|
|
|
|
|
break;
|
|
|
|
|
case 718: // Zygarde
|
|
|
|
|
form = form.Replace("-C", "");
|
|
|
|
|
form = form.Replace("50%", "");
|
|
|
|
|
form = form.Replace("100%", "Complete");
|
|
|
|
|
break;
|
|
|
|
|
case 774: // Minior
|
|
|
|
|
if (form.StartsWith("M-"))
|
|
|
|
|
form = "Meteor";
|
|
|
|
|
form = form.Replace("C-", "");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Species == 774) // Minior
|
|
|
|
|
{
|
|
|
|
|
form = "Meteor";
|
2016-12-23 23:37:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
// First Line: Name, Nickname, Gender, Item
|
2016-09-18 05:10:27 +00:00
|
|
|
|
string specForm = species[Species];
|
2016-12-23 23:37:56 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(form))
|
|
|
|
|
specForm += "-" + form.Replace("Mega ", "Mega-");
|
2016-10-04 02:24:46 +00:00
|
|
|
|
|
2016-09-18 05:10:27 +00:00
|
|
|
|
string result = Nickname != null && species[Species] != Nickname ? $"{Nickname} ({specForm})" : $"{specForm}";
|
|
|
|
|
if (!string.IsNullOrEmpty(Gender))
|
|
|
|
|
result += $" ({Gender})";
|
|
|
|
|
if (Item > 0 && Item < items.Length)
|
|
|
|
|
result += " @ " + items[Item];
|
|
|
|
|
result += Environment.NewLine;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
|
|
|
|
|
// IVs
|
|
|
|
|
string[] ivstr = new string[6];
|
|
|
|
|
int ivctr = 0;
|
2016-09-18 05:10:27 +00:00
|
|
|
|
int[] sIVs = IVsSpeedLast; // Reorganize speed
|
2016-06-20 04:22:43 +00:00
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
if (sIVs[i] == 31) continue;
|
|
|
|
|
ivstr[ivctr++] += $"{sIVs[i]} {StatNames[i]}";
|
|
|
|
|
}
|
|
|
|
|
if (ivctr > 0)
|
|
|
|
|
result += "IVs: " + string.Join(" / ", ivstr.Take(ivctr)) + Environment.NewLine;
|
|
|
|
|
|
|
|
|
|
// EVs
|
|
|
|
|
string[] evstr = new string[6];
|
2016-09-18 05:10:27 +00:00
|
|
|
|
int[] sEVs = EVsSpeedLast; // Reorganize speed
|
2016-06-20 04:22:43 +00:00
|
|
|
|
int evctr = 0;
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
if (sEVs[i] == 0) continue;
|
|
|
|
|
evstr[evctr++] += $"{sEVs[i]} {StatNames[i]}";
|
|
|
|
|
}
|
|
|
|
|
if (evctr > 0)
|
|
|
|
|
result += "EVs: " + string.Join(" / ", evstr.Take(evctr)) + Environment.NewLine;
|
|
|
|
|
|
|
|
|
|
// Secondary Stats
|
2016-09-18 05:10:27 +00:00
|
|
|
|
if (Ability > -1 && Ability < abilities.Length)
|
2016-09-04 06:14:05 +00:00
|
|
|
|
result += "Ability: " + abilities[Ability] + Environment.NewLine;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
result += "Level: " + Level + Environment.NewLine;
|
|
|
|
|
if (Shiny)
|
|
|
|
|
result += "Shiny: Yes" + Environment.NewLine;
|
|
|
|
|
|
2016-09-04 06:14:05 +00:00
|
|
|
|
if (Nature > -1)
|
|
|
|
|
result += natures[Nature] + " Nature" + Environment.NewLine;
|
2016-06-20 04:22:43 +00:00
|
|
|
|
// Add in Moves
|
|
|
|
|
string[] MoveLines = new string[Moves.Length];
|
|
|
|
|
int movectr = 0;
|
|
|
|
|
foreach (int move in Moves.Where(move => move != 0 && move < moves.Length))
|
|
|
|
|
{
|
|
|
|
|
MoveLines[movectr] += "- " + moves[move];
|
2016-06-28 05:26:39 +00:00
|
|
|
|
if (move == 237) // Hidden Power
|
|
|
|
|
{
|
|
|
|
|
int hp = 0;
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
hp |= (IVs[i] & 1) << i;
|
|
|
|
|
hp *= 0xF; hp /= 0x3F;
|
|
|
|
|
MoveLines[movectr] += $" [{hptypes[hp]}]";
|
|
|
|
|
}
|
2016-06-20 04:22:43 +00:00
|
|
|
|
movectr++;
|
|
|
|
|
}
|
|
|
|
|
result += string.Join(Environment.NewLine, MoveLines.Take(movectr));
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2017-01-08 07:54:09 +00:00
|
|
|
|
public static string getShowdownText(PKM pkm)
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
if (pkm.Species == 0) return "";
|
2016-09-18 05:10:27 +00:00
|
|
|
|
|
2016-12-23 17:37:15 +00:00
|
|
|
|
string[] Forms = PKX.getFormList(pkm.Species, types, forms, new[] {"", "F", ""}, pkm.Format);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
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,
|
2016-09-18 05:10:27 +00:00
|
|
|
|
Gender = new[] { "M", "F", "" }[pkm.Gender < 2 ? pkm.Gender : 2],
|
2016-06-20 04:22:43 +00:00
|
|
|
|
Friendship = pkm.CurrentFriendship,
|
|
|
|
|
Level = PKX.getLevel(pkm.Species, pkm.EXP),
|
|
|
|
|
Shiny = pkm.IsShiny,
|
2016-09-18 05:10:27 +00:00
|
|
|
|
Form = pkm.AltForm > 0 && pkm.AltForm < Forms.Length ? Forms[pkm.AltForm] : "",
|
2016-06-20 04:22:43 +00:00
|
|
|
|
};
|
2017-02-03 00:58:22 +00:00
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
if (Set.Form == "F") Set.Gender = "";
|
2017-02-03 01:02:14 +00:00
|
|
|
|
else if (Set.Species == 676) Set.Form = ""; // Furfrou
|
|
|
|
|
else if (Set.Species == 666 && Set.Form == "Poké Ball") Set.Form = "Pokeball"; // Vivillon
|
2017-02-03 00:58:22 +00:00
|
|
|
|
|
2016-06-20 04:22:43 +00:00
|
|
|
|
return Set.getText();
|
|
|
|
|
}
|
2016-09-20 05:59:15 +00:00
|
|
|
|
|
|
|
|
|
private void parseFirstLine(string line)
|
|
|
|
|
{
|
|
|
|
|
// Gender Detection
|
|
|
|
|
string last3 = line.Substring(line.Length - 3);
|
|
|
|
|
if (last3 == "(M)" || last3 == "(F)")
|
|
|
|
|
{
|
|
|
|
|
Gender = last3.Substring(1, 1);
|
|
|
|
|
line = line.Substring(0, line.Length - 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Nickname Detection
|
|
|
|
|
string spec = line;
|
|
|
|
|
if (spec.Contains("(") && spec.Contains(")"))
|
|
|
|
|
parseSpeciesNickname(ref spec);
|
|
|
|
|
|
|
|
|
|
spec = spec.Trim();
|
|
|
|
|
if ((Species = Array.IndexOf(species, spec)) >= 0) // success, nothing else!
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
|
|
|
|
|
if (tmp.Length < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Species = Array.IndexOf(species, tmp[0].Trim());
|
|
|
|
|
Form = tmp[1].Trim();
|
|
|
|
|
if (tmp.Length > 2)
|
|
|
|
|
Form += " " + tmp[2];
|
|
|
|
|
}
|
|
|
|
|
private void parseSpeciesNickname(ref string line)
|
|
|
|
|
{
|
|
|
|
|
int index = line.LastIndexOf("(", StringComparison.Ordinal);
|
|
|
|
|
string n1, n2;
|
2017-03-20 07:03:31 +00:00
|
|
|
|
if (index > 1) // correct format
|
2016-09-20 05:59:15 +00:00
|
|
|
|
{
|
|
|
|
|
n1 = line.Substring(0, index - 1);
|
|
|
|
|
n2 = line.Substring(index).Trim();
|
|
|
|
|
replaceAll(ref n2, "", "[", "]", "(", ")"); // Trim out excess data
|
|
|
|
|
}
|
|
|
|
|
else // nickname first (manually created set, incorrect)
|
|
|
|
|
{
|
|
|
|
|
int end = line.IndexOf(")", StringComparison.Ordinal);
|
|
|
|
|
n2 = line.Substring(index + 1, end - 1);
|
|
|
|
|
n1 = line.Substring(end + 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool inverted = Array.IndexOf(species, n2.Replace(" ", "")) > -1 || (Species = Array.IndexOf(species, n2.Split('-')[0])) > 0;
|
|
|
|
|
line = inverted ? n2 : n1;
|
|
|
|
|
Nickname = inverted ? n1 : n2;
|
|
|
|
|
}
|
|
|
|
|
private string parseLineMove(string line)
|
|
|
|
|
{
|
|
|
|
|
string moveString = line.Substring(line[1] == ' ' ? 2 : 1);
|
|
|
|
|
if (!moveString.Contains("Hidden Power"))
|
|
|
|
|
return moveString;
|
|
|
|
|
|
|
|
|
|
// Defined Hidden Power
|
|
|
|
|
if (moveString.Length > 13)
|
|
|
|
|
{
|
|
|
|
|
string type = moveString.Remove(0, 13);
|
|
|
|
|
replaceAll(ref type, "", "[", "]", "(", ")"); // Trim out excess data
|
|
|
|
|
int hpVal = Array.IndexOf(hptypes, type); // Get HP Type
|
|
|
|
|
if (hpVal >= 0)
|
|
|
|
|
IVs = PKX.setHPIVs(hpVal, IVs); // Get IVs
|
|
|
|
|
else
|
|
|
|
|
InvalidLines.Add($"Invalid Hidden Power Type: {type}");
|
|
|
|
|
}
|
|
|
|
|
moveString = "Hidden Power";
|
|
|
|
|
return moveString;
|
|
|
|
|
}
|
|
|
|
|
private void parseLineEVs(string line)
|
|
|
|
|
{
|
|
|
|
|
string[] evlist = splitLineStats(line);
|
2017-01-29 08:32:02 +00:00
|
|
|
|
if (evlist.Length == 1)
|
|
|
|
|
InvalidLines.Add("Unknown EV input.");
|
2016-09-20 05:59:15 +00:00
|
|
|
|
for (int i = 0; i < evlist.Length / 2; i++)
|
|
|
|
|
{
|
|
|
|
|
ushort EV;
|
|
|
|
|
ushort.TryParse(evlist[i * 2 + 0], out EV);
|
|
|
|
|
int index = Array.IndexOf(StatNames, evlist[i * 2 + 1]);
|
|
|
|
|
if (index > -1)
|
|
|
|
|
EVs[index] = EV;
|
|
|
|
|
else
|
|
|
|
|
InvalidLines.Add($"Unknown EV Type input: {evlist[i * 2]}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void parseLineIVs(string line)
|
|
|
|
|
{
|
|
|
|
|
string[] ivlist = splitLineStats(line);
|
2017-01-29 08:32:02 +00:00
|
|
|
|
if (ivlist.Length == 1)
|
|
|
|
|
InvalidLines.Add("Unknown IV input.");
|
2016-09-20 05:59:15 +00:00
|
|
|
|
for (int i = 0; i < ivlist.Length / 2; i++)
|
|
|
|
|
{
|
|
|
|
|
byte IV;
|
|
|
|
|
byte.TryParse(ivlist[i * 2 + 0], out IV);
|
|
|
|
|
int index = Array.IndexOf(StatNames, ivlist[i * 2 + 1]);
|
|
|
|
|
if (index > -1)
|
|
|
|
|
IVs[index] = IV;
|
|
|
|
|
else
|
|
|
|
|
InvalidLines.Add($"Unknown IV Type input: {ivlist[i * 2]}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string[] splitLineStats(string line)
|
|
|
|
|
{
|
|
|
|
|
// Because people think they can type sets out...
|
|
|
|
|
return line
|
|
|
|
|
.Replace("SAtk", "SpA").Replace("Sp Atk", "SpA")
|
|
|
|
|
.Replace("SDef", "SpD").Replace("Sp Def", "SpD")
|
|
|
|
|
.Replace("Spd", "Spe").Replace("Speed", "Spe").Split(new[] { " / ", " " }, StringSplitOptions.None);
|
|
|
|
|
}
|
|
|
|
|
private static void replaceAll(ref string rv, string o, params string[] i)
|
|
|
|
|
{
|
|
|
|
|
rv = i.Aggregate(rv, (current, v) => current.Replace(v, o));
|
|
|
|
|
}
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|