Ejemplo n.º 1
0
        private async Task<InventionJob> GetInventionJob(Domains.IndustryJob job, BlueprintInfo t2Print, IEnumerable<Decryptor> decryptors, IEnumerable<MarketPrice> invMatPrices)
        {
            try
            {
                var types = new List<int> { t2Print.Manufacturing.Products.First().TypeId };
                var rawMaterials = await _manufacturingService.GetRawMaterials(new Domains.IndustryJob(t2Print, new Blueprint(1, 0, 0, 1)), 1);
                types.AddRange(rawMaterials.Select(p => p.TypeId).ToList());

                var marketStats = await _apiService.GetMarketStatistics(types, 30000142);

                var baseRuns = t2Print.Manufacturing.Products.First().CategoryId == 6 ? 1 : 10;
                var costOfInvention = job.BlueprintInfo.Invention.Materials.Sum(material => invMatPrices.First().Buy * Convert.ToDecimal(material.Quantity));

                var t2Item = await _staticService.GetProductTypeAsync(t2Print.BlueprintId);
                var t1Item = await _staticService.GetProductTypeAsync(job.BlueprintInfo.BlueprintId);

                var tasks = decryptors.Select(p => CheckDecryptor(p, job, t2Print, costOfInvention, baseRuns, marketStats)).ToList();
                var inventionJob = new InventionJob(t2Item.TypeId, t2Item.TypeName, t1Item.TypeId, t1Item.TypeName, 0, new List<Decryptor>());

                while (tasks.Any())
                {
                    var task = await Task.WhenAny(tasks);
                    inventionJob.Decryptors.Add(await task);
                    tasks.Remove(task);
                }

                return inventionJob;
            }
            catch (Exception e)
            {
                throw new Exception($"Invention of {t2Print.Manufacturing.Products.First().TypeName} failed with message: {e.Message}");
            }
        }
Ejemplo n.º 2
0
 public CopyViewModel(BlueprintInfo blueprintInfo, string typeName)
 {
     TypeId = blueprintInfo.BlueprintId;
     TypeName = typeName;
     CopyTime = blueprintInfo.Copying.Time;
     Skills = blueprintInfo.Copying.Skills;
     Materials = blueprintInfo.Copying.Materials;
 }
Ejemplo n.º 3
0
 private static void CoolName(ActivityData activityData)
 {
     var bi = new BlueprintInfo();
     bi.BlueprintId = activityData.blueprintTypeID;
     bi.MaxProductionLimit = activityData.maxProductionLimit;
     if (activityData.activities.copying != null)
         bi.Copying = GetActivity(activityData.activities.copying);
     if (activityData.activities.invention != null)
         bi.Invention = GetActivity(activityData.activities.invention);
     if (activityData.activities.manufacturing != null)
         bi.Manufacturing =  GetActivity(activityData.activities.manufacturing);
     if (activityData.activities.research_material != null)
         bi.ResearchMaterial = GetActivity(activityData.activities.research_material);
     if (activityData.activities.research_time != null)
         bi.ResearchTime = GetActivity(activityData.activities.research_time);
     _blueprints.Add(bi);
 }
Ejemplo n.º 4
0
 public IndustryJob(BlueprintInfo info, Blueprint print)
 {
     BlueprintInfo = info;
     Blueprint = print;
 }
Ejemplo n.º 5
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}");
            }
            
        }