示例#1
0
        static void doWork(string typeName, TextWriter writer)
        {
            Logger.Log.InfoFormat("Processing {0}", typeName);

            Logger.Log.InfoFormat("Retrieving materials...");

            var          baseMats  = InventionCalc.ProductionBaseMaterials(typeName);
            var          extraMats = InventionCalc.ProductionExtraMaterials(typeName);
            EVEBlueprint bp        = InventionCalc.GetBlueprint(typeName);

            var mats = baseMats.ToList();

            mats.AddRange(extraMats);

            mats = InventionCalc.AdjustForME(mats, bp.MaterialEfficiency).OrderBy(x => x.item.TypeName).OrderByDescending(x => x.quantity).Where(x => x.item.IsSkill == false).ToList();

            Logger.Log.InfoFormat("Done.");

            decimal?manufactureCost = InventionCalc.GetMaterialCosts(mats);

            IEnumerable <EVEMaterial> inventionReqs = InventionCalc.GetInventionRequirements(typeName);

            decimal?inventionCost = InventionCalc.GetMaterialCosts(inventionReqs);

            double inventionChance = InventionCalc.GetBaseInventionChance(typeName) * (1.0 + 0.04) * (1 + 8 * 0.02);

            decimal?successfulInventionCost = inventionCost / (decimal)inventionChance / (decimal)bp.NumRuns;

            decimal?resultPrice = PricesHelper.JitaSellPrice(EVECache.GetItem(typeName));

            if (resultPrice.HasValue && inventionCost.HasValue && manufactureCost.HasValue)
            {
                decimal profitPerRun = (resultPrice - successfulInventionCost - manufactureCost).Value;

                decimal productionTime = (decimal)(Math.Ceiling((double)(bp.BaseProductionTime * 2.0m * 0.8m * 0.75m * bp.NumRuns) / (12.0 * 60.0 * 60.0)) * 12.0 * 60.0 * 60.0);

                decimal profitPerDay = 60 * 60 * 24 / (productionTime / bp.NumRuns) * profitPerRun;

                writer.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", typeName, inventionCost, inventionChance, successfulInventionCost, manufactureCost, resultPrice.Value, profitPerRun, profitPerDay, productionTime));
            }

            Logger.Log.Debug("Processing completed.");
        }
        public static decimal?GetMaterialCosts(IEnumerable <EVEMaterial> materials)
        {
            decimal result       = 0;
            bool    unknownPrice = false;

            foreach (EVEMaterial m in materials)
            {
                decimal?price = PricesHelper.JitaSellPrice(m.item);
                if (price.HasValue)
                {
                    result += price.Value * (decimal)m.damage * m.quantity;
                }
                else
                {
                    unknownPrice = true;
                }
            }

            return(unknownPrice ? (decimal?)null : result);
        }