public Module(Module Module) { this.EDName = Module.EDName; this.name = Module.name; this.@class = Module.@class; this.grade = Module.grade; this.value = Module.value; this.ShipId = Module.ShipId; this.mount = Module.mount; this.clipcapacity = Module.clipcapacity; this.hoppercapacity = Module.hoppercapacity; this.EDID = Module.EDID; this.EDDBID = Module.EDDBID; }
private static int addModifications(Module module, byte position, BinaryWriter writer) { int bytesWritten = 0; if (module.modifications != null) { writer.Write(position); bytesWritten++; foreach (Modification modification in module.modifications) { writer.Write((byte)modification.id); bytesWritten++; writer.Write((int)(modification.value * 10000)); bytesWritten += 4; } writer.Write((byte)0xff); bytesWritten++; } return bytesWritten; }
/// <summary> /// There are a number of wrinkles with modifications that we need to fix up when all of the modification /// information has been gathered. See in-code comments for each case /// </summary> public static void FixUpModifications(Module module, Dictionary<int, Modification> modifications) { if (module.EDName.StartsWith("Hpt_ShieldBooster_")) { // Shield boosters are treated internally as straight modifiers, so rather than (for example) // being a 4% boost they are a 104% multiplier. Unfortunately this means that our % modification // is incorrect so we fix it Modification sbModification; if (modifications.TryGetValue(SHIELDBOOST, out sbModification)) { // We do have a boost modification decimal boost; if (module.grade == "E") { boost = 1.04M; } else if (module.grade == "D") { boost = 1.08M; } else if (module.grade == "C") { boost = 1.12M; } else if (module.grade == "B") { boost = 1.16M; } else { boost = 1.2M; } decimal alteredBoost = boost * (1 + sbModification.value) - boost; decimal alteredValue = alteredBoost / (boost - 1); sbModification = new Modification(SHIELDBOOST); sbModification.Modify(alteredValue); modifications.Remove(SHIELDBOOST); modifications.Add(SHIELDBOOST, sbModification); } } Modification jitterModification; if (modifications.TryGetValue(JITTER, out jitterModification)) { // Jitter is in degrees rather than being a percentage, so needs to be /100 decimal value = jitterModification.value / 100; jitterModification = new Modification(JITTER); jitterModification.Modify(value); modifications.Remove(JITTER); modifications.Add(JITTER, jitterModification); } Modification rofModification; if (modifications.TryGetValue(ROF, out rofModification)) { // Although Elite talks about rate of fire, it is internally modelled as burst interval // i.e. the interval between bursts of fire. We've been happily modifying ROF with interval modifiers // until now, so flip it here to provide the right number decimal value = (1.0M / (1 + rofModification.value)) - 1; rofModification = new Modification(ROF); rofModification.Modify(value); modifications.Remove(ROF); modifications.Add(ROF, rofModification); } }
/// <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.EDName = Template.EDName; Module.EDDBID = Template.EDDBID; Module.name = Template.name; Module.@class = Template.@class; Module.grade = Template.grade; Module.value = Template.value; Module.ShipId = Template.ShipId; Module.mount = Template.mount; Module.clipcapacity = Template.clipcapacity; Module.hoppercapacity = Template.hoppercapacity; } return Module; }
/// <summary> /// State if a given module is a PowerPlay module /// </summary> public static bool IsPP(Module module) { return (module.EDName == "Int_ShieldGenerator_Size1_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size2_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size3_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size4_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size5_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size6_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size7_Class5_Strong" || module.EDName == "Int_ShieldGenerator_Size8_Class5_Strong" || module.EDName == "Hpt_PulseLaserBurst_Fixed_Small_Scatter" || module.EDName == "Hpt_Slugshot_Fixed_Large_Range" || module.EDName == "Hpt_DrunkMissileRack_Fixed_Medium" || module.EDName == "Hpt_PlasmaAccelerator_Fixed_Large_Advanced" || module.EDName == "Hpt_Railgun_Fixed_Medium_Burst" ); }
/// <summary>Find a module in outfitting that matches our existing module and provide its price</summary> private static void setShipModuleOutfittingValues(Module existing, List<Module> outfittingModules, string name, ref dynamic vaProxy) { if (existing != null && outfittingModules != null) { foreach (Module Module in outfittingModules) { if (existing.EDDBID == Module.EDDBID) { // Found it vaProxy.SetDecimal(name + " station cost", (decimal?)Module.price); if (Module.price < existing.price) { // And it's cheaper vaProxy.SetDecimal(name + " station discount", existing.price - Module.price); vaProxy.SetText(name + " station discount (spoken)", Translations.Humanize(existing.price - Module.price)); } return; } } } // Not found so remove any existing vaProxy.SetDecimal("Ship " + name + " station cost", (decimal?)null); vaProxy.SetDecimal("Ship " + name + " station discount", (decimal?)null); vaProxy.SetText("Ship " + name + " station discount (spoken)", (string)null); }
/// <summary>Find a module in outfitting that matches our existing module and provide its price</summary> private static void setShipModuleValues(Module module, string name, ref dynamic vaProxy) { vaProxy.SetText(name, module == null ? null : module.name); vaProxy.SetInt(name + " class", module == null ? (int?)null : module.@class); vaProxy.SetText(name + " grade", module == null ? null : module.grade); vaProxy.SetDecimal(name + " health", module == null ? (decimal?)null : module.health); vaProxy.SetDecimal(name + " cost", module == null ? (decimal?)null : (decimal)module.price); vaProxy.SetDecimal(name + " value", module == null ? (decimal?)null : (decimal)module.value); if (module != null && module.price < module.value) { decimal discount = Math.Round((1 - (((decimal)module.price) / ((decimal)module.value))) * 100, 1); vaProxy.SetDecimal(name + " discount", discount > 0.01M ? discount : (decimal?)null); } else { vaProxy.SetDecimal(name + " discount", null); } }