<commit_before>﻿/*
 * Copyright © 2016 EDDiscovery development team
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 * 
 * EDDiscovery is not affiliated with Frontier Developments plc.
 */
using EDDiscovery.DB;
using EDDiscovery.EliteDangerous;
using EDDiscovery.EliteDangerous.JournalEvents;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EDDiscovery.EliteDangerous
{
    // [System.Diagnostics.DebuggerDisplay("MatDB {category} {name} {fdname} {type} {shortname}")]
    public class MaterialCommodityDB
    {
        public string category { get; set; }                // either Commodity, or one of the Category types from the MaterialCollected type.
        public string name { get; set; }                    // name of it in nice text
        public string fdname { get; set; }                  // fdnames
        public string type { get; set; }                    // and its type, for materials its rarity, for commodities its group ("Metals" etc).
        public string shortname { get; set; }               // short abv. name
        public Color colour { get; set; }                   // colour if its associated with one
        public int flags { get; set; }                      // now out of date.. keep for now to limit code changes

        public static string CommodityCategory = "Commodity";
        public static string MaterialRawCategory = "Raw";
        public static string MaterialEncodedCategory = "Encoded";
        public static string MaterialManufacturedCategory = "Manufactured";

        private static Dictionary<string, MaterialCommodityDB> cachelist = new Dictionary<string, MaterialCommodityDB>();

        public static MaterialCommodityDB GetCachedMaterial(string fdname)
        {
            return cachelist.ContainsKey(fdname) ? cachelist[fdname] : null;
        }

        public static MaterialCommodityDB GetCachedMaterialByShortName(string shortname)
        {
            List<MaterialCommodityDB> lst = cachelist.Values.ToList();
            int i = lst.FindIndex(x => x.shortname.Equals(shortname));
            return i >= 0 ? lst[i] : null;
        }
        
        public MaterialCommodityDB()
        {
        }

        public MaterialCommodityDB(string cs, string n, string fd, string t, string shortn, Color cl, int fl)
        {
            category = cs;
            name = n;
            fdname = fd;
            type = t;
            shortname = shortn;
            colour = cl;
            flags = fl;
        }

        public void SetCache()
        {
            cachelist[this.fdname.ToLower()] = this;
        }

        public static MaterialCommodityDB EnsurePresent(string cat, string fdname, SQLiteConnectionUser conn)  // By FDNAME
        {
            if (!cachelist.ContainsKey(fdname.ToLower()))
            {
                MaterialCommodityDB mcdb = new MaterialCommodityDB(cat, fdname.SplitCapsWordFull(), fdname, "", "", Color.Green, 0);
                mcdb.SetCache();
                System.Diagnostics.Debug.WriteLine("Material not present: " + cat + "," + fdname );
            }

            return cachelist[fdname.ToLower()];
        }


        #region Initial setup

        private static bool AddNewType(string c, string namelist, string t)
        {
            return AddNewTypeC(c, Color.Green, namelist, t);
        }

        private static bool AddNewTypeC(string c, Color cl, string namelist, string t, string sn = "")
        {
            string[] list = namelist.Split(';');

            foreach (string name in list)
            {
                if (name.Length > 0)   // just in case a semicolon slips thru
                {
                    if (!AddNewTypeF(c, cl, name, t, sn))
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        private static bool AddNewTypeF(string c, Color cl, string name, string t, string sn = "", string fdName = "")
        {
            string fdn = (fdName.Length > 0) ? fdName : name.FDName();
            MaterialCommodityDB mc = new MaterialCommodityDB(c, name, fdn, t, sn, cl, 0);
            mc.SetCache();
            return true;
        }

        public static void SetUpInitialTable()
        {
            AddNewTypeC(MaterialRawCategory, Color.Red, "Antimony", "Very Rare", "Sb");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Polonium", "Very Rare", "Po");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Ruthenium", "Very Rare", "Ru");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Technetium", "Very Rare", "Tc");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Tellurium", "Very Rare", "Te");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Yttrium", "Very Rare", "Y");

            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Cadmium", "Rare", "Cd");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Mercury", "Rare", "Hg");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Molybdenum", "Rare", "Mo");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Niobium", "Rare", "Nb");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Tin", "Rare", "Sn");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Tungsten", "Rare", "W");

            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Carbon", "Very Common", "C");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Iron", "Very Common", "Fe");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Nickel", "Very Common", "Ni");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Phosphorus", "Very Common", "P");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Sulphur", "Very Common", "S");

            AddNewTypeC(MaterialRawCategory, Color.Green, "Arsenic", "Common", "As");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Chromium", "Common", "Cr");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Germanium", "Common", "Ge");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Manganese", "Common", "Mn");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Selenium", "Common", "Se");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Vanadium", "Common", "V");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Zinc", "Common", "Zn");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Zirconium", "Common", "Zr");

            AddNewType(CommodityCategory, "Explosives;Hydrogen Fuel;Hydrogen Peroxide;Liquid Oxygen;Mineral Oil;Nerve Agents;Pesticides;Surface Stabilisers;Synthetic Reagents;Water", "Chemicals");
            AddNewType(CommodityCategory, "Clothing;Consumer Technology;Domestic Appliances;Evacuation Shelter;Survival Equipment", "Consumer Items");
            AddNewType(CommodityCategory, "Algae;Animal Meat;Coffee;Fish;Food Cartridges;Fruit and Vegetables;Grain;Synthetic Meat;Tea", "Foods");
            AddNewType(CommodityCategory, "Ceramic Composites;CMM Composite;Insulating Membrane;Meta-Alloys;Micro-Weave Cooling Hoses;Cooling Hoses;Neofabric Insulation;Polymers;Semiconductors;Superconductors", "Industrial Materials");
            AddNewType(CommodityCategory, "Beer;Bootleg Liquor;Liquor;Narcotics;Tobacco;Wine;Lavian Brandy", "Legal Drugs");
            AddNewType(CommodityCategory, "Articulation Motors;Atmospheric Processors;Building Fabricators;Crop Harvesters;Emergency Power Cells;Energy Grid Assembly;Exhaust Manifold;Geological Equipment", "Machinery");
            AddNewType(CommodityCategory, "Heatsink Interlink;HN Shock Mount;Ion Distributor;Magnetic Emitter Coil;Marine Equipment", "Machinery");
            AddNewType(CommodityCategory, "Microbial Furnaces;Mineral Extractors;Modular Terminals;Power Converter;Power Generators;Power Transfer Bus", "Machinery");
            AddNewType(CommodityCategory, "Radiation Baffle;Reinforced Mounting Plate;Skimmer Components;Thermal Cooling Units;Water Purifiers", "Machinery");
            AddNewType(CommodityCategory, "Advanced Medicines;Agri-Medicines;Basic Medicines;Combat Stabilisers;Performance Enhancers;Progenitor Cells", "Medicines");
            AddNewType(CommodityCategory, "Aluminium;Beryllium;Bismuth;Cobalt;Copper;Gallium;Gold;Hafnium 178;Indium;Lan;hanum;Lithium;Osmium;Palladium;Platinum;Praseodymium;Samarium;Silver;Tantalum;Thallium;Thorium;Titanium;Uranium", "Metals");
            AddNewType(CommodityCategory, "Bauxite;Bertrandite;Bromellite;Coltan;Cryolite;Gallite;Goslarite", "Minerals");
            AddNewType(CommodityCategory, "Indite;Jadeite;Lepidolite;Lithium Hydroxide;Low Temperature Diamonds;Methane ;lathrate;Methanol Monohydrate;Moissanite;Painite;Pyrophyllite;Rutile;Taaffeite;Uraninite", "Minerals");
            AddNewType(CommodityCategory, "Ai Relics;Ancient Artefact;Antimatter Containment Unit;Antiquities;Assault Plans;Black Box;Commercial Samples;Data Core;Diplomatic Bag;Encrypted Correspondence;Encrypted Data Storage;Experimental Chemicals;Fossil Remnants;Ancient Orb;Ancient Casket;Ancient Relic", "Salvage");
            AddNewType(CommodityCategory, "Galactic Travel Guide;Geological Samples;Hostage;Military Intelligence;Military Plans (USS Cargo);Mysterious Idol;Occupied CryoPod;Occupied Escape Pod;Personal Effects;Political Prisoner;Precious Gems;Prohibited Research Materials;Prototype Tech", "Salvage");
            AddNewType(CommodityCategory, "Rare Artwork;Rebel Transmissions;Salvageable Wreckage;Sap 8 Core Container;Scientific Research;Scientific Samples;Space Pioneer Relics;Tactical Data;Technical Blueprints;Trade Data;Unknown Artefact;Unknown Probe;Unstable Data Core", "Salvage");
            AddNewType(CommodityCategory, "Imperial Slaves;Slaves", "Slavery");
            AddNewType(CommodityCategory, "Advanced Catalysers;Animal Monitors;Aquaponic Systems;Auto-Fabricators;Bioreducing Lichen;Computer Components", "Technology");
            AddNewType(CommodityCategory, "H.E. Suits;Hardware Diagnostic Sensor;Land Enrichment Systems;Medical Diagnostic Equipment;Micro Controllers;Muon Imager", "Technology");
            AddNewType(CommodityCategory, "Nanobreakers;Resonating Separators;Robotics;Structural Regulators;Telemetry Suite", "Technology");
            AddNewType(CommodityCategory, "Conductive Fabrics;Leather;Military Grade Fabrics;Natural Fabrics;Synthetic Fabrics", "Textiles");
            AddNewType(CommodityCategory, "Biowaste;Chemical Waste;Scrap;Toxic Waste", "Waste");
            AddNewType(CommodityCategory, "Battle Weapons;Landmines;Non-lethal Weapons;Personal Weapons;Reactive Armour", "Weapons");

            // very common data
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Anomalous Bulk Scan Data", "Very Common", "ABSD", "bulkscandata");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Atypical Disrupted Wake Echoes", "Very Common", "ADWE", "disruptedwakeechoes");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Distorted Shield Cycle Recordings", "Very Common", "DSCR", "shieldcyclerecordings");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Exceptional Scrambled Emission Data", "Very Common", "ESED", "scrambledemissiondata");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Specialised Legacy Firmware", "Very Common", "SLF", "legacyfirmware");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Unusual Encrypted Files", "Very Common", "UEF", "encryptedfiles");
            // common data
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Anomalous FSD Telemetry", "Common", "AFT", "fsdtelemetry");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Inconsistent Shield Soak Analysis", "Common", "ISSA", "shieldsoakanalysis");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Irregular Emission Data", "Common", "IED", "archivedemissiondata");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Modified Consumer Firmware", "Common", "MCF", "consumerfirmware");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Tagged Encryption Codes", "Common", "TEC", "encryptioncodes");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Unidentified Scan Archives", "Common", "USA", "scanarchives");
            // standard data
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Classified Scan Databanks", "Standard", "CSD", "scandatabanks");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Cracked Industrial Firmware", "Standard", "CIF", "industrialfirmware");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Open Symmetric Keys", "Standard", "OSK", "symmetrickeys");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Strange Wake Solutions", "Standard", "SWS", "wakesolutions");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Unexpected Emission Data", "Standard", "UED", "emissiondata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Untypical Shield Scans", "Standard", "USS", "shielddensityreports");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Shield Frequency Data", "Standard", "SFD", "shieldfrequencydata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Classified Scan Data", "Standard", "CFSD", "classifiedscandata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Compact Emissions Data", "Standard", "CED", "compactemissionsdata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Embedded Firmware", "Standard", "EFW", "embeddedfirmware");

            // rare data
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Aberrant Shield Pattern Analysis", "Rare", "ASPA", "shieldpatternanalysis");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Atypical Encryption Archives", "Rare", "AEA", "encryptionarchives");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Decoded Emission Data", "Rare", "DED");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Divergent Scan Data", "Rare", "DSD", "encodedscandata");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Eccentric Hyperspace Trajectories", "Rare", "EHT", "hyperspacetrajectories");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Alpha Obelisk Data", "Rare", "ODA");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Beta Obelisk Data", "Rare", "ODB");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Gamma Obelisk Data", "Rare", "ODG");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Delta Obelisk Data", "Rare", "ODD");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Epsilon Obelisk Data", "Rare", "ODE");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Security Firmware Patch", "Rare", "SFP", "securityfirmware");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Unknown Ship Signature", "Rare", "USSig");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Unknown Wake Data", "Rare", "UWD");
            // very rare data
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Abnormal Compact Emission Data", "Very Rare", "ACED");
            AddNewTypeF(MaterialEncodedCategory, Color.Red, "Adaptive Encryptors Capture", "Very Rare", "AEC", "adaptiveencryptors");
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Classified Scan Fragment", "Very Rare", "CSF");
            AddNewTypeF(MaterialEncodedCategory, Color.Red, "Datamined Wake Exceptions", "Very Rare", "DWEx", "dataminedwake");
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Modified Embedded Firmware", "Very Rare", "MEF");
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Peculiar Shield Frequency Data", "Very Rare", "PSFD");

            //very common manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Basic Conductors", "Very Common", "BaC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Chemical Storage Units", "Very Common", "CSU");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Compact Composites", "Very Common", "CC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Crystal Shards", "Very Common", "CS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Grid Resistors", "Very Common", "GR");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Heat Conduction Wiring", "Very Common", "HCW");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Mechanical Scrap", "Very Common", "MS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Salvaged Alloys", "Very Common", "SAll");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Tempered Alloys", "Very Common", "TeA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Worn Shield Emitters", "Very Common", "WSE");
            // common manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Chemical Processors", "Common", "CP");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Conductive Components", "Common", "CCo");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Filament Composites", "Common", "FiC");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Flawed Focus Crystals", "Common", "FFC", "uncutfocuscrystals");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Galvanising Alloys", "Common", "GA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Heat Dispersion Plate", "Common", "HDP");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Heat Resistant Ceramics", "Common", "HRC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Hybrid Capacitors", "Common", "HC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Mechanical Equipment", "Common", "ME");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Shield Emitters", "Common", "SE");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Federal Core Composites", "Common", "FCC", "fedcorecomposites");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Federal Proprietary Composites", "Common", "FPC", "fedproprietarycomposites");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Unknown Energy Source", "Common", "UES" , "unknownenergysource");

            // standard manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Chemical Distillery", "Standard", "CD");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Conductive Ceramics", "Standard", "CCe");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Electrochemical Arrays", "Standard", "EA");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Focus Crystals", "Standard", "FoC");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Heat Exchangers", "Standard", "HE");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "High Density Composites", "Standard", "HDC");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Mechanical Components", "Standard", "MC");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Phase Alloys", "Standard", "PA");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Precipitated Alloys", "Standard", "PAll");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Shielding Sensors", "Standard", "SS");
            // rare manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Chemical Manipulators", "Rare", "CM");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Compound Shielding", "Rare", "CoS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Conductive Polymers", "Rare", "CPo");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Configurable Components", "Rare", "CCom");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Heat Vanes", "Rare", "HV");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Polymer Capacitors", "Rare", "PCa");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Proprietary Composites", "Rare", "PCo");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Proto Light Alloys", "Rare", "PLA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Refined Focus Crystals", "Rare", "RFC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Thermic Alloys", "Rare", "ThA");
            // very rare manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Biotech Conductors", "Very Rare", "BiC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Core Dynamics Composites", "Very Rare", "CDC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Exquisite Focus Crystals", "Very Rare", "EFC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Imperial Shielding", "Very Rare", "IS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Improvised Components", "Very Rare", "IC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Military Grade Alloys", "Very Rare", "MGA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Military Supercapacitors", "Very Rare", "MSC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Pharmaceutical Isolators", "Very Rare", "PI");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Proto Heat Radiators", "Very Rare", "PHR");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Proto Radiolic Alloys", "Very Rare", "PRA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Unknown Fragment", "Very Rare", "UF");
        }

        #endregion
    }
}


<commit_msg>Added rare list, marked as Rare to commodities..<commit_after>﻿/*
 * Copyright © 2016 EDDiscovery development team
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 * 
 * EDDiscovery is not affiliated with Frontier Developments plc.
 */
using EDDiscovery.DB;
using EDDiscovery.EliteDangerous;
using EDDiscovery.EliteDangerous.JournalEvents;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EDDiscovery.EliteDangerous
{
    // [System.Diagnostics.DebuggerDisplay("MatDB {category} {name} {fdname} {type} {shortname}")]
    public class MaterialCommodityDB
    {
        public string category { get; set; }                // either Commodity, or one of the Category types from the MaterialCollected type.
        public string name { get; set; }                    // name of it in nice text
        public string fdname { get; set; }                  // fdnames
        public string type { get; set; }                    // and its type, for materials its rarity, for commodities its group ("Metals" etc).
        public string shortname { get; set; }               // short abv. name
        public Color colour { get; set; }                   // colour if its associated with one
        public int flags { get; set; }                      // now out of date.. keep for now to limit code changes

        public static string CommodityCategory = "Commodity";
        public static string MaterialRawCategory = "Raw";
        public static string MaterialEncodedCategory = "Encoded";
        public static string MaterialManufacturedCategory = "Manufactured";

        private static Dictionary<string, MaterialCommodityDB> cachelist = new Dictionary<string, MaterialCommodityDB>();

        public static MaterialCommodityDB GetCachedMaterial(string fdname)
        {
            return cachelist.ContainsKey(fdname) ? cachelist[fdname] : null;
        }

        public static MaterialCommodityDB GetCachedMaterialByShortName(string shortname)
        {
            List<MaterialCommodityDB> lst = cachelist.Values.ToList();
            int i = lst.FindIndex(x => x.shortname.Equals(shortname));
            return i >= 0 ? lst[i] : null;
        }
        
        public MaterialCommodityDB()
        {
        }

        public MaterialCommodityDB(string cs, string n, string fd, string t, string shortn, Color cl, int fl)
        {
            category = cs;
            name = n;
            fdname = fd;
            type = t;
            shortname = shortn;
            colour = cl;
            flags = fl;
        }

        public void SetCache()
        {
            cachelist[this.fdname.ToLower()] = this;
        }

        public static MaterialCommodityDB EnsurePresent(string cat, string fdname, SQLiteConnectionUser conn)  // By FDNAME
        {
            if (!cachelist.ContainsKey(fdname.ToLower()))
            {
                MaterialCommodityDB mcdb = new MaterialCommodityDB(cat, fdname.SplitCapsWordFull(), fdname, "", "", Color.Green, 0);
                mcdb.SetCache();
                System.Diagnostics.Debug.WriteLine("Material not present: " + cat + "," + fdname );
            }

            return cachelist[fdname.ToLower()];
        }


        #region Initial setup

        private static bool AddNewRare(string fdname, string name)
        {
            return AddNewTypeF(CommodityCategory, Color.Green, name, "Rare", "", fdname);
        }

        private static bool AddNewType(string c, string namelist, string t)
        {
            return AddNewTypeC(c, Color.Green, namelist, t);
        }

        private static bool AddNewTypeC(string c, Color cl, string namelist, string t, string sn = "")
        {
            string[] list = namelist.Split(';');

            foreach (string name in list)
            {
                if (name.Length > 0)   // just in case a semicolon slips thru
                {
                    if (!AddNewTypeF(c, cl, name, t, sn))
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        private static bool AddNewTypeF(string c, Color cl, string name, string t, string sn = "", string fdName = "")
        {
            string fdn = (fdName.Length > 0) ? fdName : name.FDName();
            MaterialCommodityDB mc = new MaterialCommodityDB(c, name, fdn, t, sn, cl, 0);
            mc.SetCache();
            return true;
        }

        public static void SetUpInitialTable()
        {
            AddNewTypeC(MaterialRawCategory, Color.Red, "Antimony", "Very Rare", "Sb");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Polonium", "Very Rare", "Po");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Ruthenium", "Very Rare", "Ru");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Technetium", "Very Rare", "Tc");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Tellurium", "Very Rare", "Te");
            AddNewTypeC(MaterialRawCategory, Color.Red, "Yttrium", "Very Rare", "Y");

            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Cadmium", "Rare", "Cd");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Mercury", "Rare", "Hg");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Molybdenum", "Rare", "Mo");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Niobium", "Rare", "Nb");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Tin", "Rare", "Sn");
            AddNewTypeC(MaterialRawCategory, Color.Yellow, "Tungsten", "Rare", "W");

            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Carbon", "Very Common", "C");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Iron", "Very Common", "Fe");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Nickel", "Very Common", "Ni");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Phosphorus", "Very Common", "P");
            AddNewTypeC(MaterialRawCategory, Color.Cyan, "Sulphur", "Very Common", "S");

            AddNewTypeC(MaterialRawCategory, Color.Green, "Arsenic", "Common", "As");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Chromium", "Common", "Cr");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Germanium", "Common", "Ge");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Manganese", "Common", "Mn");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Selenium", "Common", "Se");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Vanadium", "Common", "V");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Zinc", "Common", "Zn");
            AddNewTypeC(MaterialRawCategory, Color.Green, "Zirconium", "Common", "Zr");

            AddNewType(CommodityCategory, "Explosives;Hydrogen Fuel;Hydrogen Peroxide;Liquid Oxygen;Mineral Oil;Nerve Agents;Pesticides;Surface Stabilisers;Synthetic Reagents;Water", "Chemicals");
            AddNewType(CommodityCategory, "Clothing;Consumer Technology;Domestic Appliances;Evacuation Shelter;Survival Equipment", "Consumer Items");
            AddNewType(CommodityCategory, "Algae;Animal Meat;Coffee;Fish;Food Cartridges;Fruit and Vegetables;Grain;Synthetic Meat;Tea", "Foods");
            AddNewType(CommodityCategory, "Ceramic Composites;CMM Composite;Insulating Membrane;Meta-Alloys;Micro-Weave Cooling Hoses;Cooling Hoses;Neofabric Insulation;Polymers;Semiconductors;Superconductors", "Industrial Materials");
            AddNewType(CommodityCategory, "Beer;Bootleg Liquor;Liquor;Narcotics;Tobacco;Wine;Lavian Brandy", "Legal Drugs");
            AddNewType(CommodityCategory, "Articulation Motors;Atmospheric Processors;Building Fabricators;Crop Harvesters;Emergency Power Cells;Energy Grid Assembly;Exhaust Manifold;Geological Equipment", "Machinery");
            AddNewType(CommodityCategory, "Heatsink Interlink;HN Shock Mount;Ion Distributor;Magnetic Emitter Coil;Marine Equipment", "Machinery");
            AddNewType(CommodityCategory, "Microbial Furnaces;Mineral Extractors;Modular Terminals;Power Converter;Power Generators;Power Transfer Bus", "Machinery");
            AddNewType(CommodityCategory, "Radiation Baffle;Reinforced Mounting Plate;Skimmer Components;Thermal Cooling Units;Water Purifiers", "Machinery");
            AddNewType(CommodityCategory, "Advanced Medicines;Agri-Medicines;Basic Medicines;Combat Stabilisers;Performance Enhancers;Progenitor Cells", "Medicines");
            AddNewType(CommodityCategory, "Aluminium;Beryllium;Bismuth;Cobalt;Copper;Gallium;Gold;Hafnium 178;Indium;Lan;hanum;Lithium;Osmium;Palladium;Platinum;Praseodymium;Samarium;Silver;Tantalum;Thallium;Thorium;Titanium;Uranium", "Metals");
            AddNewType(CommodityCategory, "Bauxite;Bertrandite;Bromellite;Coltan;Cryolite;Gallite;Goslarite", "Minerals");
            AddNewType(CommodityCategory, "Indite;Jadeite;Lepidolite;Lithium Hydroxide;Low Temperature Diamonds;Methane ;lathrate;Methanol Monohydrate;Moissanite;Painite;Pyrophyllite;Rutile;Taaffeite;Uraninite", "Minerals");
            AddNewType(CommodityCategory, "Ai Relics;Ancient Artefact;Antimatter Containment Unit;Antiquities;Assault Plans;Black Box;Commercial Samples;Data Core;Diplomatic Bag;Encrypted Correspondence;Encrypted Data Storage;Experimental Chemicals;Fossil Remnants;Ancient Orb;Ancient Casket;Ancient Relic", "Salvage");
            AddNewType(CommodityCategory, "Galactic Travel Guide;Geological Samples;Hostage;Military Intelligence;Military Plans (USS Cargo);Mysterious Idol;Occupied CryoPod;Occupied Escape Pod;Personal Effects;Political Prisoner;Precious Gems;Prohibited Research Materials;Prototype Tech", "Salvage");
            AddNewType(CommodityCategory, "Rare Artwork;Rebel Transmissions;Salvageable Wreckage;Sap 8 Core Container;Scientific Research;Scientific Samples;Space Pioneer Relics;Tactical Data;Technical Blueprints;Trade Data;Unknown Artefact;Unknown Probe;Unstable Data Core", "Salvage");
            AddNewType(CommodityCategory, "Imperial Slaves;Slaves", "Slavery");
            AddNewType(CommodityCategory, "Advanced Catalysers;Animal Monitors;Aquaponic Systems;Auto-Fabricators;Bioreducing Lichen;Computer Components", "Technology");
            AddNewType(CommodityCategory, "H.E. Suits;Hardware Diagnostic Sensor;Land Enrichment Systems;Medical Diagnostic Equipment;Micro Controllers;Muon Imager", "Technology");
            AddNewType(CommodityCategory, "Nanobreakers;Resonating Separators;Robotics;Structural Regulators;Telemetry Suite", "Technology");
            AddNewType(CommodityCategory, "Conductive Fabrics;Leather;Military Grade Fabrics;Natural Fabrics;Synthetic Fabrics", "Textiles");
            AddNewType(CommodityCategory, "Biowaste;Chemical Waste;Scrap;Toxic Waste", "Waste");
            AddNewType(CommodityCategory, "Battle Weapons;Landmines;Non-lethal Weapons;Personal Weapons;Reactive Armour", "Weapons");


            AddNewRare("advert1", "Advert 1");
            AddNewRare("aerialedenapple", "Aerial Eden Apple");
            AddNewRare("aganipperush", "Aganippe Rush");
            AddNewRare("alacarakmoskinart", "Alacarakmo Skin Art");
            AddNewRare("albinoquechuamammoth", "Albino Quechua Mammoth");
            AddNewRare("alieneggs", "Alien Eggs");
            AddNewRare("altairianskin", "Altairian Skin");
            AddNewRare("alyabodilysoap", "Alya Body Soap");
            AddNewRare("anduligafireworks", "Anduliga Fireworks");
            AddNewRare("anynacoffee", "Any Na Coffee");
            AddNewRare("aroucaconventualsweets", "Arouca Conventual Sweets");
            AddNewRare("azcancriformula42", "Azcancri Formula 42");
            AddNewRare("bakedgreebles", "Baked Greebles");
            AddNewRare("baltahsinevacuumkrill", "Baltah'sine Vacuum Krill");
            AddNewRare("bankiamphibiousleather", "Banki Amphibious Leather");
            AddNewRare("bastsnakegin", "Bast Snake Gin");
            AddNewRare("belalansrayleather", "Belalans Ray Leather");
            AddNewRare("bluemilk", "Blue Milk");
            AddNewRare("borasetanipathogenetics", "Borasetani Pathogenetics");
            AddNewRare("buckyballbeermats", "Buckyball beermats");
            AddNewRare("burnhambiledistillate", "Burnham Bile Distillate");
            AddNewRare("cd75catcoffee", "CD75 Cat Coffee");
            AddNewRare("centaurimegagin", "Centaurimegagin");
            AddNewRare("ceremonialheiketea", "Ceremonial Heike Tea");
            AddNewRare("cetiaepyornisegg", "Cetiaepyornis Egg");
            AddNewRare("cetirabbits", "Ceti Rabbits");
            AddNewRare("chameleoncloth", "Chameleon Cloth");
            AddNewRare("chateaudeaegaeon", "Chateau De Aegaeon");
            AddNewRare("cherbonesbloodcrystals", "Cherbones Blood Crystals");
            AddNewRare("chieridanimarinepaste", "Chi Eridani Marine Paste");
            AddNewRare("coquimspongiformvictuals", "Coquim Spongiform Victuals");
            AddNewRare("cromsilverfesh", "Crom Silver Fesh");
            AddNewRare("crystallinespheres", "Crystalline Spheres");
            AddNewRare("damnacarapaces", "Damna Carapaces");
            AddNewRare("deltaphoenicispalms", "Delta Phoenicis Palms");
            AddNewRare("deuringastruffles", "Deuringas Truffles");
            AddNewRare("disomacorn", "Diso Ma Corn");
            AddNewRare("eleuthermals", "Eleu Thermals");
            AddNewRare("eraninpearlwhisky", "Eranin Pearl Whisky");
            AddNewRare("eshuumbrellas", "Eshu Umbrellas");
            AddNewRare("esusekucaviar", "<NAME>");
            AddNewRare("ethgrezeteabuds", "Ethgreze Tea Buds");
            AddNewRare("fujintea", "Fujin Tea");
            AddNewRare("galactictravelguide", "Galactic Travel Guide");
            AddNewRare("geawendancedust", "Geawen Dance Dust");
            AddNewRare("gerasiangueuzebeer", "Gerasian Gueuze Beer");
            AddNewRare("giantirukamasnails", "Gian Tirukama Snails");
            AddNewRare("giantverrix", "Giant Verrix");
            AddNewRare("gilyasignatureweapons", "Gilya Signature Weapons");
            AddNewRare("gomanyauponcoffee", "Goman Yaupon Coffee");
            AddNewRare("haidneblackbrew", "Haidne Black Brew");
            AddNewRare("havasupaidreamcatcher", "Havasupai Dream Catcher");
            AddNewRare("helvetitjpearls", "Helvetitj Pearls");
            AddNewRare("hip10175bushmeat", "Hip10175 Bushmeat");
            AddNewRare("hip118311swarm", "Hip118311 Wwarm");
            AddNewRare("hip41181squid", "Hip41181 Squid");
            AddNewRare("hiporganophosphates", "Hip Organophosphates");
            AddNewRare("holvaduellingblades", "Holva Duelling Blades");
            AddNewRare("honestypills", "Honesty Pills");
            AddNewRare("hr7221wheat", "Hr7221 Wheat");
            AddNewRare("indibourbon", "Indi Bourbon");
            AddNewRare("jaquesquinentianstill", "Jaques Quinentian Still");
            AddNewRare("jaradharrepuzzlebox", "Jaradharre Puzzle Box");
            AddNewRare("jarouarice", "Jaroua Rice");
            AddNewRare("jotunmookah", "Jotun Mookah");
            AddNewRare("kachiriginleaches", "Kachirigin Leaches");
            AddNewRare("kamitracigars", "Kamitra Cigars");
            AddNewRare("kamorinhistoricweapons", "Kamorin Historic Weapons");
            AddNewRare("karetiicouture", "Karetii Couture");
            AddNewRare("karsukilocusts", "Karsuki Locusts");
            AddNewRare("kinagoinstruments", "Kinago Instruments");
            AddNewRare("konggaale", "Kongga Ale");
            AddNewRare("korrokungpellets", "Korro Kung Pellets");
            AddNewRare("lavianbrandy", "Lavian Brandy");
            AddNewRare("leestianeviljuice", "Leestian Evil Juice");
            AddNewRare("lftvoidextractcoffee", "Lft Void Extract Coffee");
            AddNewRare("livehecateseaworms", "Live Hecate Seaworms");
            AddNewRare("ltthypersweet", "Ltt Hypersweet");
            AddNewRare("lyraeweed", "Lyrae Weed");
            AddNewRare("masterchefs", "Master Chefs");
            AddNewRare("mechucoshightea", "Mechucos High Tea");
            AddNewRare("medbstarlube", "Medb Starlube");
            AddNewRare("mokojingbeastfeast", "Mokojing Beast Feast");
            AddNewRare("momusbogspaniel", "Momus Bog Spaniel");
            AddNewRare("motronaexperiencejelly", "Motrona Experience Jelly");
            AddNewRare("mukusubiichitinos", "Mukusubii Chitinos");
            AddNewRare("mulachigiantfungus", "Mulachigiantfungus");
            AddNewRare("neritusberries", "Neritusberries");
            AddNewRare("ngadandarifireopals", "Ngadandarifireopals");
            AddNewRare("ngunamodernantiques", "Ngunamodernantiques");
            AddNewRare("njangarisaddles", "Njangarisaddles");
            AddNewRare("noneuclidianexotanks", "Noneuclidianexotanks");
            AddNewRare("ochoengchillies", "Ochoengchillies");
            AddNewRare("onionhead", "Onion Head");
            AddNewRare("onionheada", "Onion Head A");
            AddNewRare("onionheadb", "Onion Head B");
            AddNewRare("onionheadc", "Onion Head C");
            AddNewRare("onionheadd", "Onion Head D");
            AddNewRare("onionheadderivatives", "Onion Head Derivatives");
            AddNewRare("onionheade", "Onion Head E");
            AddNewRare("onionheadsamples", "Onion Head Samples");
            AddNewRare("ophiuchiexinoartefacts", "Ophiuchi Exino Artefacts");
            AddNewRare("orrerianviciousbrew", "Orrerian Vicious Brew");
            AddNewRare("pantaaprayersticks", "Pantaa Prayer Sticks");
            AddNewRare("pavoniseargrubs", "Pavonis Ear Grubs");
            AddNewRare("personalgifts", "Personal Gifts");
            AddNewRare("rajukrustoves", "Rajukru Stoves");
            AddNewRare("rapabaosnakeskins", "Rapabao Snakeskins");
            AddNewRare("rusanioldsmokey", "Rusani Old Smokey");
            AddNewRare("sanumameat", "Sanuma Meat");
            AddNewRare("saxonwine", "Saxon Wine");
            AddNewRare("shanscharisorchid", "Shans Charis Orchid");
            AddNewRare("soontillrelics", "Soontill Relics");
            AddNewRare("sothiscrystallinegold", "Sothis Crystalline Gold");
            AddNewRare("tanmarktranquiltea", "Tanmark Tranquil Tea");
            AddNewRare("tarachtorspice", "Tarachtor Spice");
            AddNewRare("taurichimes", "Tauri Chimes");
            AddNewRare("terramaterbloodbores", "Terra Mater Blood Bores");
            AddNewRare("thehuttonmug", "The Hutton Mug");
            AddNewRare("thrutiscream", "Thrutis Cream");
            AddNewRare("tiegfriessynthsilk", "Tieg Fries Synthsilk");
            AddNewRare("tiolcewaste2pasteunits", "Tiolce Waste2paste Units");
            AddNewRare("toxandjivirocide", "ToxanDji Virocide");
            AddNewRare("transgeniconionhead", "Transgenic Onion Head");
            AddNewRare("uszaiantreegrub", "Uszaian Tree Grub");
            AddNewRare("utgaroarmillenialeggs", "Utgaroar Millenial Eggs");
            AddNewRare("uzumokulowgwings", "Uzumoku Low-G Wings");
            AddNewRare("vacuumkrill", "Vacuum Krill");
            AddNewRare("vanayequirhinofur", "Vanayequi Rhino Fur");
            AddNewRare("vegaslimweed", "Vega Slimweed");
            AddNewRare("vherculisbodyrub", "Vherculis Body Rub");
            AddNewRare("vidavantianlace", "Vidavantian Lace");
            AddNewRare("voidworms", "Void Worms");
            AddNewRare("volkhabbeedrones", "Volkhabbee Drones");
            AddNewRare("watersofshintara", "Waters Of shintara");
            AddNewRare("wheemetewheatcakes", "Wheemete Wheat Cakes");
            AddNewRare("witchhaulkobebeef", "Witchhaul Kobe Beef");
            AddNewRare("wolf1301fesh", "Wolf1301 Fesh");
            AddNewRare("wulpahyperboresystems", "Wulpa Hyperbore Systems");
            AddNewRare("wuthielokufroth", "Wuthielo ku froth");
            AddNewRare("xihecompanions", "Xihe Companions");
            AddNewRare("yasokondileaf", "Yaso Kondi Leaf");
            AddNewRare("zeesszeantglue", "Zeessze Ant Glue");

            // very common data
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Anomalous Bulk Scan Data", "Very Common", "ABSD", "bulkscandata");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Atypical Disrupted Wake Echoes", "Very Common", "ADWE", "disruptedwakeechoes");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Distorted Shield Cycle Recordings", "Very Common", "DSCR", "shieldcyclerecordings");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Exceptional Scrambled Emission Data", "Very Common", "ESED", "scrambledemissiondata");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Specialised Legacy Firmware", "Very Common", "SLF", "legacyfirmware");
            AddNewTypeF(MaterialEncodedCategory, Color.Cyan, "Unusual Encrypted Files", "Very Common", "UEF", "encryptedfiles");
            // common data
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Anomalous FSD Telemetry", "Common", "AFT", "fsdtelemetry");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Inconsistent Shield Soak Analysis", "Common", "ISSA", "shieldsoakanalysis");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Irregular Emission Data", "Common", "IED", "archivedemissiondata");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Modified Consumer Firmware", "Common", "MCF", "consumerfirmware");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Tagged Encryption Codes", "Common", "TEC", "encryptioncodes");
            AddNewTypeF(MaterialEncodedCategory, Color.Green, "Unidentified Scan Archives", "Common", "USA", "scanarchives");
            // standard data
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Classified Scan Databanks", "Standard", "CSD", "scandatabanks");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Cracked Industrial Firmware", "Standard", "CIF", "industrialfirmware");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Open Symmetric Keys", "Standard", "OSK", "symmetrickeys");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Strange Wake Solutions", "Standard", "SWS", "wakesolutions");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Unexpected Emission Data", "Standard", "UED", "emissiondata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Untypical Shield Scans", "Standard", "USS", "shielddensityreports");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Shield Frequency Data", "Standard", "SFD", "shieldfrequencydata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Classified Scan Data", "Standard", "CFSD", "classifiedscandata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Compact Emissions Data", "Standard", "CED", "compactemissionsdata");
            AddNewTypeF(MaterialEncodedCategory, Color.SandyBrown, "Embedded Firmware", "Standard", "EFW", "embeddedfirmware");

            // rare data
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Aberrant Shield Pattern Analysis", "Rare", "ASPA", "shieldpatternanalysis");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Atypical Encryption Archives", "Rare", "AEA", "encryptionarchives");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Decoded Emission Data", "Rare", "DED");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Divergent Scan Data", "Rare", "DSD", "encodedscandata");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Eccentric Hyperspace Trajectories", "Rare", "EHT", "hyperspacetrajectories");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Alpha Obelisk Data", "Rare", "ODA");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Beta Obelisk Data", "Rare", "ODB");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Gamma Obelisk Data", "Rare", "ODG");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Delta Obelisk Data", "Rare", "ODD");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Pattern Epsilon Obelisk Data", "Rare", "ODE");
            AddNewTypeF(MaterialEncodedCategory, Color.Yellow, "Security Firmware Patch", "Rare", "SFP", "securityfirmware");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Unknown Ship Signature", "Rare", "USSig");
            AddNewTypeC(MaterialEncodedCategory, Color.Yellow, "Unknown Wake Data", "Rare", "UWD");
            // very rare data
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Abnormal Compact Emission Data", "Very Rare", "ACED");
            AddNewTypeF(MaterialEncodedCategory, Color.Red, "Adaptive Encryptors Capture", "Very Rare", "AEC", "adaptiveencryptors");
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Classified Scan Fragment", "Very Rare", "CSF");
            AddNewTypeF(MaterialEncodedCategory, Color.Red, "Datamined Wake Exceptions", "Very Rare", "DWEx", "dataminedwake");
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Modified Embedded Firmware", "Very Rare", "MEF");
            AddNewTypeC(MaterialEncodedCategory, Color.Red, "Peculiar Shield Frequency Data", "Very Rare", "PSFD");

            //very common manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Basic Conductors", "Very Common", "BaC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Chemical Storage Units", "Very Common", "CSU");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Compact Composites", "Very Common", "CC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Crystal Shards", "Very Common", "CS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Grid Resistors", "Very Common", "GR");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Heat Conduction Wiring", "Very Common", "HCW");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Mechanical Scrap", "Very Common", "MS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Salvaged Alloys", "Very Common", "SAll");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Tempered Alloys", "Very Common", "TeA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Cyan, "Worn Shield Emitters", "Very Common", "WSE");
            // common manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Chemical Processors", "Common", "CP");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Conductive Components", "Common", "CCo");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Filament Composites", "Common", "FiC");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Flawed Focus Crystals", "Common", "FFC", "uncutfocuscrystals");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Galvanising Alloys", "Common", "GA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Heat Dispersion Plate", "Common", "HDP");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Heat Resistant Ceramics", "Common", "HRC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Hybrid Capacitors", "Common", "HC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Mechanical Equipment", "Common", "ME");
            AddNewTypeC(MaterialManufacturedCategory, Color.Green, "Shield Emitters", "Common", "SE");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Federal Core Composites", "Common", "FCC", "fedcorecomposites");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Federal Proprietary Composites", "Common", "FPC", "fedproprietarycomposites");
            AddNewTypeF(MaterialManufacturedCategory, Color.Green, "Unknown Energy Source", "Common", "UES" , "unknownenergysource");

            // standard manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Chemical Distillery", "Standard", "CD");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Conductive Ceramics", "Standard", "CCe");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Electrochemical Arrays", "Standard", "EA");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Focus Crystals", "Standard", "FoC");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Heat Exchangers", "Standard", "HE");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "High Density Composites", "Standard", "HDC");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Mechanical Components", "Standard", "MC");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Phase Alloys", "Standard", "PA");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Precipitated Alloys", "Standard", "PAll");
            AddNewTypeC(MaterialManufacturedCategory, Color.SandyBrown, "Shielding Sensors", "Standard", "SS");
            // rare manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Chemical Manipulators", "Rare", "CM");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Compound Shielding", "Rare", "CoS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Conductive Polymers", "Rare", "CPo");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Configurable Components", "Rare", "CCom");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Heat Vanes", "Rare", "HV");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Polymer Capacitors", "Rare", "PCa");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Proprietary Composites", "Rare", "PCo");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Proto Light Alloys", "Rare", "PLA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Refined Focus Crystals", "Rare", "RFC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Yellow, "Thermic Alloys", "Rare", "ThA");
            // very rare manufactured
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Biotech Conductors", "Very Rare", "BiC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Core Dynamics Composites", "Very Rare", "CDC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Exquisite Focus Crystals", "Very Rare", "EFC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Imperial Shielding", "Very Rare", "IS");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Improvised Components", "Very Rare", "IC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Military Grade Alloys", "Very Rare", "MGA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Military Supercapacitors", "Very Rare", "MSC");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Pharmaceutical Isolators", "Very Rare", "PI");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Proto Heat Radiators", "Very Rare", "PHR");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Proto Radiolic Alloys", "Very Rare", "PRA");
            AddNewTypeC(MaterialManufacturedCategory, Color.Red, "Unknown Fragment", "Very Rare", "UF");
        }

        #endregion
    }
}



{'fraction_non_alphanumeric': 0.11598387448245805, 'fraction_numerical': 0.001706980460521537, 'mean_word_length': 3.683932976099345, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4733121', 'n_tokens_mistral': 17001, 'n_tokens_neox': 16021, 'n_words': 3546}