/// <summary> /// Exports the <see cref="box"/> to <see cref="ShowdownSet"/> as a single string. /// </summary> /// <param name="sav">Save File to export from</param> /// <param name="box">Box to export from</param> /// <returns>Concatenated string of all sets in the specified box.</returns> public static string GetShowdownSetsFromBox(this SaveFile sav, int box) { var data = sav.GetBoxData(box); var sep = Environment.NewLine + Environment.NewLine; return(ShowdownSet.GetShowdownSets(data, sep)); }
public static List <ShowdownTeamSet> GetTeams(string paste) { string[] lines = paste.Split(new[] { "\n" }, StringSplitOptions.None); var result = new List <ShowdownTeamSet>(); for (int i = 0; i < lines.Length; i++) { var line = lines[i]?.Trim(); if (string.IsNullOrWhiteSpace(line)) { continue; } if (!IsLineShowdownTeam(line)) { continue; } var split = line.Split(new[] { "===" }, 0); if (split.Length != 3) { continue; } var split2 = split[1].Trim().Split(']'); if (split2.Length != 2) { continue; } var format = split2[0].Substring(1); var name = split2[1].TrimStart(); // find end int end = i + 1; while (end < lines.Length) { if (IsLineShowdownTeam(lines[end])) { break; } end++; } var teamlines = lines.Skip(i + 1).Take(end - i - 1).Where(z => !string.IsNullOrWhiteSpace(z)); var sets = ShowdownSet.GetShowdownSets(teamlines).ToList(); if (sets.Count <= 0) { continue; } result.Add(new ShowdownTeamSet { Format = format, TeamName = name, Team = sets }); i = end; } return(result); }
/// <summary> /// A method to get a list of ShowdownSet(s) from a string paste /// Needs to be extended to hold several teams /// </summary> /// <param name="paste"></param> /// <returns></returns> private static List <ShowdownSet> ShowdownSets(string paste, out Dictionary <int, string[]> TeamData) { TeamData = null; paste = paste.Trim(); // Remove White Spaces if (TeamBackup(paste)) { TeamData = GenerateTeamData(paste, out paste); } string[] lines = paste.Split(new string[] { "\n" }, StringSplitOptions.None); return(ShowdownSet.GetShowdownSets(lines).ToList()); }
/// <summary> /// A method to get a list of ShowdownSet(s) from a string paste /// Needs to be extended to hold several teams /// </summary> /// <param name="paste"></param> public static List <ShowdownSet> ShowdownSets(string paste) { paste = paste.Trim(); // Remove White Spaces if (IsTeamBackup(paste)) { return(ShowdownTeamSet.GetTeams(paste).SelectMany(z => z.Team).ToList()); } var lines = paste.Split(new[] { "\n" }, StringSplitOptions.None); return(ShowdownSet.GetShowdownSets(lines).ToList()); }
public void SimulatorParseMultiple() { var text = string.Join("\r\n\r\n", Sets); var lines = text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None); var sets = ShowdownSet.GetShowdownSets(lines); Assert.IsTrue(sets.Count() == Sets.Length); sets = ShowdownSet.GetShowdownSets(Enumerable.Empty <string>()); Assert.IsTrue(!sets.Any()); sets = ShowdownSet.GetShowdownSets(new [] { "", " ", " " }); Assert.IsTrue(!sets.Any()); }
private static void VerifyFile(string path) { var lines = File.ReadAllLines(path); var sets = ShowdownSet.GetShowdownSets(lines); var game = GetGameFromFile(path); var sav = SaveUtil.GetBlankSAV(game, "ALM"); sav.Should().NotBeNull(); foreach (var s in sets) { var pk = sav.GetLegalFromSet(s, out _); var la = new LegalityAnalysis(pk); la.Valid.Should().BeTrue($"{path}'s set for {GameInfo.Strings.Species[s.Species]} should generate a legal mon"); } }
private void BoxToShowdown(object sender, EventArgs e) { try { var CurrBox = SaveFileEditor.SAV.GetBoxData(SaveFileEditor.SAV.CurrentBox); var str = ShowdownSet.GetShowdownSets(CurrBox, Environment.NewLine + Environment.NewLine); if (string.IsNullOrWhiteSpace(str)) { return; } Clipboard.SetText(str); } catch { } MessageBox.Show("Exported the active box to Showdown format"); }
private void ExportBoxToShowdown(object sender, EventArgs e) { try { IList <PKM> BoxData = C_SAV.SAV.BoxData; List <PKM> BoxList = new List <PKM>(BoxData); List <PKM> CurrBox = BoxList.GetRange(C_SAV.CurrentBox * C_SAV.SAV.BoxSlotCount, C_SAV.SAV.BoxSlotCount); var str = ShowdownSet.GetShowdownSets(CurrBox, Environment.NewLine + Environment.NewLine); if (string.IsNullOrWhiteSpace(str)) { return; } Clipboard.SetText(str); } catch { } WinFormsUtil.Alert("Exported the active box to Showdown format"); }