/// <summary>Find a module int outfitting that matches our existing module and provide its price</summary> private static void SetOutfittingCost(string name, Module existing, ref List<Module> outfittingModules, ref Dictionary<string, string> textValues, ref Dictionary<string, decimal?> decimalValues) { foreach (Module Module in outfittingModules) { if (existing.EDDBID == Module.EDDBID) { // Found it setDecimal(ref decimalValues, "Ship " + name + " station cost", (decimal?)Module.Cost); if (Module.Cost < existing.Cost) { // And it's cheaper setString(ref textValues, "Ship " + name + " station discount", humanize(existing.Cost - Module.Cost)); // TODO remove in next major release setString(ref textValues, "Ship " + name + " station discount (spoken)", humanize(existing.Cost - Module.Cost)); } return; } // Not found so remove any existing setDecimal(ref decimalValues, "Ship " + name + " station cost", (decimal?)null); setString(ref textValues, "Ship " + name + " station discount", (string)null); } }
/// <summary>Obtain details of a module given its Elite ID</summary> public static Module ModuleFromEliteID(long id) { Module Module = new Module(); Module Template; if (ModulesByEliteID.TryGetValue(id, out Template)) { Module.EDDBID = Template.EDDBID; Module.Name = Template.Name; Module.Class = Template.Class; Module.Grade = Template.Grade; Module.Value = Template.Value; } return Module; }
/// <summary>Find a module in outfitting that matches our existing module and provide its price</summary> private static void SetModuleDetails(string name, Module module, ref Dictionary<string, string> textValues, ref Dictionary<string, int?> intValues, ref Dictionary<string, decimal?> decimalValues) { setString(ref textValues, name, module == null ? null : module.Name); setInt(ref intValues, name + " class", module == null ? (int?)null : module.Class); setString(ref textValues, name + " grade", module == null ? null : module.Grade); setDecimal(ref decimalValues, name + " health", module == null ? (decimal?)null : module.Health); setDecimal(ref decimalValues, name + " cost", module == null ? (decimal?)null : (decimal)module.Cost); setDecimal(ref decimalValues, name + " value", module == null ? (decimal?)null : (decimal)module.Value); if (module != null && module.Cost < module.Value) { decimal discount = Math.Round((1 - (((decimal)module.Cost) / ((decimal)module.Value))) * 100, 1); setDecimal(ref decimalValues, name + " discount", discount > 0.01M ? discount : (decimal?)null); } else { setDecimal(ref decimalValues, name + " discount", null); } }