Ejemplo n.º 1
0
        private async Task<Decryptor> CheckDecryptor(Decryptor decryptor, Domains.IndustryJob job, BlueprintInfo t2Print, decimal costOfInvention, int baseRuns, IEnumerable<MarketPrice> materialPrices)
        {
            try
            {
                var probability = await job.GetInventionSuccessProbability(5, 5, 5, decryptor.ProbabilityModifier);

                if (decryptor.TypeId > 0)
                    costOfInvention += decryptor.Price;

                var runs = baseRuns + decryptor.MaxRunModifier;

                var t2Job = new Domains.IndustryJob(t2Print, new Blueprint { MaterialEfficiency = 2 + decryptor.MaterialEfficiencyModifier });

                var materials = await _manufacturingService.GetRawMaterials(t2Job, 1);

                var itemCost = materials.Sum(mat => materialPrices.First(p => p.TypeId == mat.TypeId).Buy * mat.Quantity);

                var inventionCostPerRun = costOfInvention / runs * probability * (decimal)t2Print.Manufacturing.Products.First().Quantity;

                var dec = new Decryptor(decryptor.TypeId, decryptor.TypeName, decryptor.ProbabilityModifier,
                    decryptor.MaxRunModifier, decryptor.MaterialEfficiencyModifier, decryptor.TimeEfficiencyModifier,
                    decryptor.Price);

                dec.ProfitPerInvention = materialPrices.First(p => p.TypeId == t2Print.Manufacturing.Products.First().TypeId).Buy - inventionCostPerRun - itemCost;
                dec.ME = 2 + decryptor.MaterialEfficiencyModifier;
                dec.TE = 4 + decryptor.TimeEfficiencyModifier;
                dec.Runs = runs;

                return dec;
            }
            catch (Exception e)
            {
                throw new Exception($"{t2Print.Manufacturing.Products.First().TypeName} Failed with {decryptor.TypeName} with message: {e.Message}");
            }
            
        }