public static Blueprint FromTable(IDataStruct blueprintTable) { var data = blueprintTable.Get("data"); string name = data.GetValue("name") as string; IDataStruct blocks = blueprintTable.Get("blocks"); int cost = 0; Console.WriteLine("Parsing blueprint for ship: " + name); foreach (IDataStruct block in blocks) { int id = int.Parse(block.GetValue(0).ToString()); cost += BlockData.GetBlockCost(id); } Console.WriteLine($"Succesfully parsed ship {name} with a cost of {cost}"); return(new Blueprint(name, cost, blueprintTable.Serialize())); }
public static List <Blueprint> FromFile(string path) { using (IDataStruct data = DataParse.FromFile(path)) { List <Blueprint> results = new List <Blueprint>(); IDataStruct blueprints = data.Get("blueprints"); for (int i = 0; i < blueprints.Count; i++) { IDataStruct blueprintTable = blueprints.Get(i); if (blueprintTable.Count > 1) { results.Add(FromTable(blueprintTable)); } } return(results); } }