Exemple #1
0
        static string MatName(long?matid, long?matcount, CVSFile mat)
        {
            if (matid != null && matcount != null)
            {
                int matrow = mat.FindInColumn("A", matid.Value.ToString());
                if (matrow >= 0)
                {
                    string name = mat[matrow]["F"].Trim();
                    EliteDangerousCore.MaterialCommodityData mc = EliteDangerousCore.MaterialCommodityData.GetCachedMaterialByName(name);

                    if (mc != null)
                    {
                        return(matcount.Value.ToString() + mc.shortname); //+ "(" + mc.name + ")";
                    }
                    else
                    {
                        return(matcount.Value.ToString() + name + "( **** UNKNOWN *****)");
                    }
                }
            }
            return("");
        }
        static public string ProcessEngineering(string rootpath)            // overall index of items
        {
            string ret = "";

            EliteDangerousCore.MaterialCommodityData.SetUpInitialTable();

            List <EngEntry> list = GetEng(rootpath);

            try
            {
                string blueprintspath = Path.Combine(rootpath, "blueprints.json");
                string blueprinttext  = File.ReadAllText(blueprintspath);

                JObject blueprintsjo = JObject.Parse(blueprinttext);

                foreach (JProperty c in blueprintsjo.Children())
                {
                    JObject jo     = (JObject)c.First;
                    string  fdname = jo["fdname"].Str();

                    //Console.WriteLine("Item " + c.Path + " " + fdname);

                    JObject grades = (JObject)jo["grades"];

                    foreach (JProperty gr in grades.Children())
                    {
                        string grname = gr.Name;
                        //                        Console.WriteLine("  Grade " + gr.Name);

                        JObject gradeinfo = (JObject)gr.Value;

                        JObject ingredients = (JObject)gradeinfo["components"];

                        string indlist = "";

                        foreach (JProperty hp in ingredients.Children())
                        {
                            EliteDangerousCore.MaterialCommodityData mat = EliteDangerousCore.MaterialCommodityData.GetCachedMaterialByName(hp.Name);
                            if (mat == null)
                            {
                                Console.WriteLine(hp.Name + " **** Not found in " + fdname + " " + grname);
                            }
                            else
                            {
                                string postfix = "(" + mat.name + ")";
                                indlist = indlist.AppendPrePad(hp.Value.Int() + mat.shortname + postfix, ",");
                            }
                        }

                        EngEntry eng = list.Find(x => x.fdname == fdname && x.grade == gr.Name);

                        if (eng == null)
                        {
                            Console.WriteLine(" **** No engineer for " + fdname + "," + gr.Name);
                        }
                        else
                        {
                            string englist = eng.englist;

                            string name      = fdname.SplitCapsWordFull();
                            string cat       = name.Word(new char[] { ' ' }, 1);
                            string classline = "new EngineeringRecipe(\"" + name + "\", \"" + indlist + "\", \"" + cat + "\", \"" + gr.Name + "\", \"" + englist + "\" ),";

                            ret += classline + Environment.NewLine;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.ToString());
            }

            return(ret);
        }