public OrderSummary GetCompressedOres(ReprocessingSkills reprocessingSkills, MineralList mineralList) { var oreGroups = GetOreGroups(reprocessingSkills); var minerals = GetMinerals(); var optimizedOres = OptimizeOres(minerals, oreGroups, mineralList, reprocessingSkills); var finalOres = optimizedOres.Where(o => o.Qty > 0).ToList(); var currentMinerals = new MineralList(); foreach (var ore in finalOres) { foreach (MineralType mineral in Enum.GetValues(typeof(MineralType))) { currentMinerals[mineral] += ore.GetMineralQty(mineral, reprocessingSkills.CalculateReprocessingRate(ore.ReprocessingType)); } } var generatedMinerals = new List <Mineral>(); foreach (var mineral in minerals) { mineral.Qty = currentMinerals[mineral.MineralType]; mineral.DesiredQty = mineralList[mineral.MineralType]; generatedMinerals.Add(mineral); } return(GetOrderSummary(finalOres, generatedMinerals, mineralList)); }
public override void PrepareOptions(SettingsFeature settingsFeature) { AddOptionIsEnabled(settingsFeature); Options.Add(new OptionSeparator()); Options.Add(new OptionSlider( parentSettings: settingsFeature, id: "AllowedTreeGrowthFractionLevel", label: AllowedTreeGrowthFractionLevelText, defaultValue: 1.0, valueChangedCallback: value => AllowedTreeGrowthFractionLevel = value)); Options.Add(new OptionSlider( parentSettings: settingsFeature, id: "DroneDurabilityThreshold", label: DroneDurabilityThresholdText, defaultValue: 0.1, valueChangedCallback: value => DroneDurabilityThreshold = value)); Options.Add(new OptionSeparator()); Options.Add(new OptionEntityList( parentSettings: settingsFeature, id: "EnabledMineralList", entityList: MineralList.OrderBy(entity => entity.Id), defaultEnabledList: new List <string>(), onEnabledListChanged: enabledList => EnabledMineralList = enabledList)); Options.Add(new OptionSeparator()); Options.Add(new OptionEntityList( parentSettings: settingsFeature, id: "EnabledTreeList", entityList: TreeList.OrderBy(entity => entity.Id), defaultEnabledList: new List <string>(), onEnabledListChanged: enabledList => EnabledTreeList = enabledList)); }
/// <summary> /// Puts the mineral prices. /// </summary> private void PutMineralPrices() { textBoxPriceTritanium.Text = MineralList.Get("Tritanium").Price.ToString("F2"); textBoxPricePyerite.Text = MineralList.Get("Pyerite").Price.ToString("F2"); textBoxPriceMexallon.Text = MineralList.Get("Mexallon").Price.ToString("F2"); textBoxPriceIsogen.Text = MineralList.Get("Isogen").Price.ToString("F2"); textBoxPriceNocxium.Text = MineralList.Get("Nocxium").Price.ToString("F2"); textBoxPriceZydrine.Text = MineralList.Get("Zydrine").Price.ToString("F2"); textBoxPriceMegacyte.Text = MineralList.Get("Megacyte").Price.ToString("F2"); textBoxPriceMorphite.Text = MineralList.Get("Morphite").Price.ToString("F2"); }
public ActionResult OreCalculator(MineralList desiredMinerals, IEnumerable <ItemLookupViewModel> itemList) { var skills = _playerService.GetReprocessingSkills(); var viewModel = new OreListModel { Skills = skills, DesiredMinerals = desiredMinerals, }; if (desiredMinerals.TotalVolume > 0) { viewModel.OreOrderSummary = _itemService.GetCompressedOres(skills, desiredMinerals); } return(View(viewModel)); }
/// <summary> /// Initializes a new instance of the <see cref="CalculatorForm"/> class. /// </summary> public CalculatorForm() { InitializeComponent(); comboStandTax.SelectedIndex = Config <Settings> .Instance.StandTaxe; pictureBoxTritanium.Tag = MineralList.Get("Tritanium"); textBoxPriceTritanium.Tag = MineralList.Get("Tritanium"); pictureBoxPyerite.Tag = MineralList.Get("Pyerite"); textBoxPricePyerite.Tag = MineralList.Get("Pyerite"); pictureBoxMexallon.Tag = MineralList.Get("Mexallon"); textBoxPriceMexallon.Tag = MineralList.Get("Mexallon"); pictureBoxIsogen.Tag = MineralList.Get("Isogen"); textBoxPriceIsogen.Tag = MineralList.Get("Isogen"); pictureBoxNocxium.Tag = MineralList.Get("Nocxium"); textBoxPriceNocxium.Tag = MineralList.Get("Nocxium"); pictureBoxZydrine.Tag = MineralList.Get("Zydrine"); textBoxPriceZydrine.Tag = MineralList.Get("Zydrine"); pictureBoxMegacyte.Tag = MineralList.Get("Megacyte"); textBoxPriceMegacyte.Tag = MineralList.Get("Megacyte"); pictureBoxMorphite.Tag = MineralList.Get("Morphite"); textBoxPriceMorphite.Tag = MineralList.Get("Morphite"); pictureBoxVeldspar.Tag = OreList.Get("Veldspar"); pictureBoxScordite.Tag = OreList.Get("Scordite"); pictureBoxPyroxeres.Tag = OreList.Get("Pyroxeres"); pictureBoxPlagioclase.Tag = OreList.Get("Plagioclase"); pictureBoxOmber.Tag = OreList.Get("Omber"); pictureBoxKernite.Tag = OreList.Get("Kernite"); pictureBoxJaspet.Tag = OreList.Get("Jaspet"); pictureBoxHemorphite.Tag = OreList.Get("Hemorphite"); pictureBoxHedbergite.Tag = OreList.Get("Hedbergite"); pictureBoxGneiss.Tag = OreList.Get("Gneiss"); pictureBoxDarkOchre.Tag = OreList.Get("Dark Ochre"); pictureBoxSpodumain.Tag = OreList.Get("Spodumain"); pictureBoxCrokite.Tag = OreList.Get("Crokite"); pictureBoxBistot.Tag = OreList.Get("Bistot"); pictureBoxArkonor.Tag = OreList.Get("Arkonor"); pictureBoxMercoxit.Tag = OreList.Get("Mercoxit"); PutMineralPrices(); histogram1.ShowLabels = true; histogram1.ShowValues = true; }
private void GetMineralsPricesFromEveCentral() { // Строки: URI и имя локального файла const string webAddress = "http://eve-central.com/api/evemon"; const string localAddress = "EveCentral.xml"; if(LoadXmlData(webAddress, localAddress)) { try { System.Globalization.NumberFormatInfo info = new System.Globalization.NumberFormatInfo { NumberDecimalSeparator = "." }; using(XmlTextReader reader = new XmlTextReader(localAddress)) { Mineral min = null; while(reader.Read()) { switch(reader.NodeType) { case XmlNodeType.Text: { if(min == null) min = MineralList.Get(reader.Value); else { min.Price = Convert.ToDouble(reader.Value, info); min = null; } break; } } } } } catch(XmlException) { } } }
/// <summary> /// Handles the Click event of the btnEveCentral control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BtnEveCentralClick(object sender, EventArgs e) { // Строки: URI и имя локального файла const string webAddress = "http://eve-central.com/api/evemon"; const string localAddress = "EveCentral.xml"; try { // Два объекта для получения информации о предполагаемом скачиваемом xml HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(webAddress); WebClient httpClient = new WebClient(); HttpWebResponse httpWResp = (HttpWebResponse)httpWReq.GetResponse(); // Проверяем, действительно ли по данному адресу находится xml //string type = httpWResp.ContentType.Substring(0, "text/xml".Length); //if (type == "text/xml") //{ // Скачиваем httpClient.DownloadFile(webAddress, localAddress); //} httpWResp.Close(); } catch (WebException ex) { MessageBox.Show(ex.Message); return; } try { System.Globalization.NumberFormatInfo info = new System.Globalization.NumberFormatInfo(); info.NumberDecimalSeparator = "."; using (XmlTextReader reader = new XmlTextReader(localAddress)) { Mineral min = null; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: { if (min == null) { min = MineralList.Get(reader.Value); } else { min.Price = Convert.ToDouble(reader.Value, info); min = null; } break; } } } } } catch (XmlException) { } PutMineralPrices(); }
public ActionResult ParseItems(string textInput, bool useCompressedOres = false, bool buildShips = false, int multiplier = 1) { var inputTests = new [] { new Regex(@"^\[(?<itemName>[^,]+),"), new Regex(@"^(?<itemName>[^\t]+)\t(?<itemQty>[\d,]+)$"), new Regex(@"^(?<itemQty>[\d,]+)x?\s+(?<itemName>[^\t]+)"), new Regex(@"^(?<itemName>.+?)(\sx(?<itemQty>[\d,]+))?$"), new Regex(@"^(?<itemName>[^\d\t]+)"), }; var lines = textInput.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); var mineralList = new MineralList(); var itemList = new List <ItemLookup>(); var invalidLines = new List <string>(); var mineralNames = mineralList.GetMineralNames().ToList(); foreach (var line in lines) { var matchFound = false; foreach (var inputTest in inputTests) { var inputMatch = inputTest.Match(line.Trim()); if (inputMatch.Success) { var itemQty = inputMatch.Groups["itemQty"]; var itemName = inputMatch.Groups["itemName"].Value; var qty = multiplier * (itemQty.Success ? int.Parse(itemQty.Value.Replace(",", "")) : 1); if (useCompressedOres && mineralNames.Contains(itemName)) { mineralList[itemName] += qty; matchFound = true; } else { var item = _itemService.GetItem(itemName); if (item != null) { var itemEntry = itemList.FirstOrDefault(il => il.TypeId == item.typeID); if (itemEntry == null) { itemList.Add(new ItemLookup { TypeId = item.typeID, Qty = qty }); } else { itemEntry.Qty += qty; } matchFound = true; } } break; } } if (!matchFound) { invalidLines.Add(line); } } var skills = _playerService.GetReprocessingSkills(); var viewModel = new OreListModel { Skills = skills, DesiredMinerals = mineralList, TextInput = textInput, InvalidLines = invalidLines, UseCompressedOres = useCompressedOres, Multiplier = multiplier, BuildShips = buildShips, }; if (mineralList.TotalVolume > 0) { var compressedOres = _itemService.GetCompressedOres(skills, mineralList); foreach (var ore in compressedOres.MarketItems) { itemList.Add(new ItemLookup { TypeId = ore.Id, Qty = (int)ore.Qty, }); } } if (itemList.Any()) { viewModel.ItemOrderSummary = _itemService.GetItemPricing(itemList, 300, .02m, 60003760); } viewModel.TextInput = textInput; viewModel.InvalidLines = invalidLines; return(View("OreCalculator", viewModel)); }
public ActionResult GetBlueprintSummary(BlueprintCalculationViewModel viewModel) { var bpLookup = new Dictionary <long, Dictionary <long, BlueprintLookupViewModel> >(); var materialLookup = new Dictionary <long, Dictionary <long, ItemLookupViewModel> >(); var blueprintList = new Dictionary <long, BlueprintLookupViewModel>(); var materialList = new Dictionary <long, ItemLookupViewModel>(); foreach (var blueprint in viewModel.Blueprints) { if (blueprint.Qty <= 0) { continue; } var bpMaterialList = new Dictionary <long, ItemLookupViewModel>(); var bpBlueprintList = new Dictionary <long, BlueprintLookupViewModel>(); GatherBlueprintMaterials(blueprint, viewModel.MfgSystemCostIndex, bpMaterialList, bpBlueprintList); foreach (var kvp in bpMaterialList) { if (!materialList.ContainsKey(kvp.Key)) { materialList.Add(kvp.Key, kvp.Value); } else { materialList[kvp.Key].Qty += kvp.Value.Qty; } } foreach (var kvp in bpBlueprintList) { if (!blueprintList.ContainsKey(kvp.Key)) { blueprintList.Add(kvp.Key, kvp.Value); } else { blueprintList[kvp.Key].Qty += kvp.Value.Qty; } } bpLookup.Add(blueprint.TypeId, bpBlueprintList); materialLookup.Add(blueprint.TypeId, bpMaterialList); } var mineralList = new MineralList(); var mineralNames = mineralList.GetMineralNames().ToList(); var itemList = new List <ItemLookup>(); foreach (var material in materialList.Values) { var item = _itemService.GetItem(material.TypeId); if (viewModel.CompressMinerals && mineralNames.Contains(item.typeName)) { mineralList[item.typeName] += material.Qty; } else { itemList.Add(new ItemLookup { TypeId = material.TypeId, Qty = material.Qty, }); } } foreach (var bpc in blueprintList.Values) { var item = _itemService.GetItem(bpc.TypeId); bpc.Name = item.typeName; } var reprocessingSkills = _playerService.GetReprocessingSkills(); var compressedOreSummary = _itemService.GetCompressedOres(reprocessingSkills, mineralList); var orderSummary = _itemService.GetItemPricing(itemList, 300, .02m, viewModel.PurchaseStationId); var blueprintSummary = new BlueprintCalculationResultsViewModel { OrderSummary = orderSummary, OreSummary = compressedOreSummary, BpcResults = new BpcResultsViewModel { Blueprints = blueprintList.Values.ToList() }, }; foreach (var bp in viewModel.Blueprints) { var blueprintCostAnalysis = new BlueprintCalculationResultViewModel(); var matList = materialLookup[bp.TypeId]; var bpList = bpLookup[bp.TypeId]; var item = _itemService.GetItem(bp.TypeId); blueprintCostAnalysis.TypeId = bp.TypeId; blueprintCostAnalysis.TypeName = item.typeName; blueprintCostAnalysis.Qty = bp.Qty; foreach (var mineral in compressedOreSummary.Minerals) { if (matList.ContainsKey(mineral.Id)) { blueprintCostAnalysis.MaterialPrice += matList[mineral.Id].Qty * mineral.ComparisonPrice; } } foreach (var material in orderSummary.MarketItems) { if (matList.ContainsKey(material.Id)) { blueprintCostAnalysis.MaterialPrice += matList[material.Id].Qty * (material.AveragePrice + material.AverageShippingCost); } } foreach (var bpEntry in bpList.Values) { blueprintCostAnalysis.BlueprintPrice += (decimal)(bpEntry.Qty * bpEntry.JobCost); } blueprintCostAnalysis.TotalPrice = blueprintCostAnalysis.BlueprintPrice + blueprintCostAnalysis.MaterialPrice + bp.BpcPackCost; blueprintSummary.BlueprintResults.Add(blueprintCostAnalysis); } return(PartialView(blueprintSummary)); }
public OrderSummary GetOrderSummary(IEnumerable <MarketItem> items, List <Mineral> minerals, MineralList mineralList) { var itemList = items.ToList(); var perfectPurchasePrice = itemList.Sum(o => Math.Round(o.Pricing.CalculateBestTotal((int)Math.Ceiling(o.Qty)), 2)); var buyAllPurchasePrice = itemList.Sum(o => o.TotalPrice); var totalOreVolume = (decimal)itemList.Sum(o => o.Volume * o.Qty); var sourceStagingShippingCost = itemList.Sum(o => o.AverageShippingCost * (decimal)o.Qty); var mineralBuyAllPurchasePrice = minerals?.Sum(m => m.TotalPrice); var totalMineralVolume = minerals?.Sum(m => m.Volume * m.DesiredQty); var mineralValueRatio = (buyAllPurchasePrice + sourceStagingShippingCost) / mineralBuyAllPurchasePrice; if (minerals != null) { foreach (var mineral in minerals) { if (mineral.Qty == 0) { continue; } mineral.ComparisonTotal = Math.Round(mineral.TotalPrice * mineralValueRatio.Value, 2); mineral.ComparisonPrice = Math.Round(mineral.ComparisonTotal / (decimal)mineral.DesiredQty, 2); } } return(new OrderSummary { MarketItems = itemList, Minerals = minerals, MineralValueRatio = mineralValueRatio, TotalMineralVolume = totalMineralVolume, PurchaseCostBest = perfectPurchasePrice, PurchaseCost = buyAllPurchasePrice, TotalVolume = totalOreVolume, SourceStagingShippingCost = sourceStagingShippingCost, }); }
protected List <OreMinerals> OptimizeOres(List <Mineral> minerals, List <OreGroup> oreGroups, MineralList mineralList, ReprocessingSkills reprocessingSkills) { foreach (var mineral in minerals.OrderBy(o => o.ReprocessingOrder)) { var mineralType = mineral.MineralType; var primaryOreGroup = oreGroups.Single(o => o.ReprocessingType == mineral.PrimaryOreReprocessingType); var desiredMineralQty = mineralList[mineralType]; foreach (var ore in oreGroups.SelectMany(o => o.Ores).Where(o => o.Qty > 0)) { desiredMineralQty -= ore.GetMineralQty(mineralType, ore.ReprocessingRate); } foreach (var order in primaryOreGroup.OptimizedMarketOrders) { if (desiredMineralQty <= 0) { break; } var oreMineralYield = order.AssociatedOre.ReprocessedMinerals[mineralType] * order.AssociatedOre.ReprocessingRate; var desiredOrderQty = Math.Ceiling(Math.Min(order.Volume, desiredMineralQty / oreMineralYield)); desiredMineralQty -= desiredOrderQty * oreMineralYield; primaryOreGroup.Ores.Single(o => o.Id == order.AssociatedOre.Id).Qty += desiredOrderQty; } } return(oreGroups.SelectMany(og => og.Ores.Where(o => o.Qty > 0)).ToList()); }