public static List <LogicObjects.SpoilerData> ReadTextSpoilerlog(string Path, LogicObjects.TrackerInstance instance) { List <LogicObjects.SpoilerData> SpoilerData = new List <LogicObjects.SpoilerData>(); if (Path == "") { OpenFileDialog SpoilerFile = new OpenFileDialog { Title = "Select A Logic File", Filter = "Text Spoiler Log (*.txt)|*.txt", FilterIndex = 1, Multiselect = false }; if (SpoilerFile.ShowDialog() != DialogResult.OK) { return(SpoilerData); } Path = SpoilerFile.FileName; } List <int> usedId = new List <int>(); foreach (string line in File.ReadLines(Path)) { LogicObjects.SpoilerData entry = new LogicObjects.SpoilerData(); if (line.Contains("->")) { var linedata = line.Split(new string[] { "->" }, StringSplitOptions.None); linedata[0] = linedata[0].Replace("*", ""); //Not sure if this is neccassary but I'm to linedata[1] = linedata[1].Replace("*", ""); //lazy to check and it's not hurting anything entry.LocationName = linedata[0].Trim(); entry.ItemName = linedata[1].Trim(); entry.LocationID = -2; entry.ItemID = -2; bool itemfound = false; foreach (LogicObjects.LogicEntry X in instance.Logic) { if (X.SpoilerLocation == entry.LocationName) { entry.LocationID = X.ID; } if (X.SpoilerItem == entry.ItemName && !usedId.Contains(X.ID) && !itemfound) { entry.ItemID = X.ID; usedId.Add(X.ID); itemfound = true; } } SpoilerData.Add(entry); } } return(SpoilerData); }
public static List <LogicObjects.SpoilerData> ReadHTMLSpoilerLog(string Path, LogicObjects.TrackerInstance Instance) { List <LogicObjects.SpoilerData> SpoilerData = new List <LogicObjects.SpoilerData>(); if (Path == "") { OpenFileDialog SpoilerFile = new OpenFileDialog { Title = "Select an HTML Spoiler Log", Filter = "HTML Spoiler Log (*.html)|*.html", FilterIndex = 1, Multiselect = false }; if (SpoilerFile.ShowDialog() != DialogResult.OK) { return(SpoilerData); } Path = SpoilerFile.FileName; } string Region = ""; LogicObjects.SpoilerData entry = new LogicObjects.SpoilerData(); foreach (string line in File.ReadAllLines(Path)) { if (line.Contains("<tr class=\"region\">")) { Region = line.Trim(); Region = Region.Replace("<tr class=\"region\"><td colspan=\"3\">", ""); Region = Region.Replace("</td></tr>", ""); } if (line.Contains("data-newlocationid=")) { var X = line.Trim().Split('"'); entry.LocationID = Int32.Parse(X[3]); entry.ItemID = Int32.Parse(X[1]); } if (line.Contains("<td class=\"newlocation\">")) { var X = line.Trim(); X = X.Replace("<td class=\"newlocation\">", ""); X = X.Replace("</td>", ""); entry.LocationName = X; } if (line.Contains("<td class=\"spoiler itemname\"><span data-content=\"") || line.Contains("<td class=\"spoiler itemname\"> <span data-content=\"")) { var X = line.Trim(); X = X.Replace("<td class=\"spoiler itemname\"> <span data-content=\"", ""); X = X.Replace("<td class=\"spoiler itemname\"><span data-content=\"", ""); X = X.Replace("\"></span></td>", ""); entry.ItemName = X; entry.LocationArea = Region; SpoilerData.Add(entry); entry = new LogicObjects.SpoilerData(); } if (line.Contains("<h2>Item Locations</h2>")) { break; } } if (Instance.EntranceRando) { return(SpoilerData); } //Fix Dungeon Entrances Dictionary <string, int> EntIDMatch = new Dictionary <string, int>(); var entranceIDs = Instance.EntranceAreaDic; foreach (LogicObjects.SpoilerData Thing in SpoilerData) { if (entranceIDs.ContainsValue(Thing.ItemID)) { EntIDMatch.Add(Thing.ItemName, Thing.ItemID); } } foreach (LogicObjects.SpoilerData Thing in SpoilerData) { if (EntIDMatch.ContainsKey(Thing.LocationName)) { Thing.LocationID = EntIDMatch[Thing.LocationName]; } } return(SpoilerData); }