public IDictionary <string, object> Refine(Character character, Container sourceContainer, int targetAmount, ProductionDescription productionDescription)
        {
            var materialMultiplier = GetMaterialMultiplier(character);

            //collect availabe materials
            var foundComponents = productionDescription.SearchForAvailableComponents(sourceContainer).ToList();

            //generate a list of the used components
            var itemsUsed = productionDescription.ProcessComponentRequirement(ProductionInProgressType.refine, foundComponents, targetAmount, materialMultiplier);

            //create item
            productionDescription.CreateRefineResult(character.Eid, sourceContainer, targetAmount, character);

            //update / delete components from source container
            ProductionDescription.UpdateUsedComponents(itemsUsed, sourceContainer, character, TransactionType.RefineDelete).ThrowIfError();

            sourceContainer.Save();

            var sourceInformData = sourceContainer.ToDictionary();

            var replyDict = new Dictionary <string, object> {
                { k.sourceContainer, sourceInformData }
            };

            return(replyDict);
        }
Example #2
0
        public Dictionary <string, object> QueryMaterialAndTime(CalibrationProgram calibrationProgram, Character character, int targetDefintion, int lineOrCPRGMaterialPoints, int lineOrCPRGTimePoints, bool forNextRound = false)
        {
            var result = new Dictionary <string, object>();

            if (forNextRound)
            {
                var decalibration = ProductionDataAccess.GetDecalibration(targetDefintion);

                double newMaterialEfficiency = 0;
                double newTimeEfficiency     = 0;

                ProductionLine.GetDecalibratedEfficiencies(lineOrCPRGMaterialPoints, lineOrCPRGTimePoints, decalibration.decrease, ref newMaterialEfficiency, ref newTimeEfficiency);

                lineOrCPRGMaterialPoints = (int)newMaterialEfficiency;
                lineOrCPRGTimePoints     = (int)newTimeEfficiency;
            }

            bool hasBonus;
            var  materialMultiplier = CalculateFinalMaterialMultiplier(character, lineOrCPRGMaterialPoints, targetDefintion, out hasBonus);

            if (calibrationProgram.IsMissionRelated)
            {
                materialMultiplier = materialMultiplier.Clamp(); //never ask more than what we have in the mission
            }

            var materials = ProductionDescription.GetRequiredComponentsInfo(ProductionInProgressType.massProduction, 1, materialMultiplier, calibrationProgram.Components);

            materials.Count.ThrowIfEqual(0, ErrorCodes.WTFErrorMedicalAttentionSuggested);

            var productionTimeSeconds = CalculateFinalProductionTimeSeconds(character, targetDefintion, lineOrCPRGTimePoints);

            var price = CalculateProductionPrice(productionTimeSeconds);

            if (calibrationProgram.IsMissionRelated)
            {
                //mission stuff is fixed
                price = 0;
                productionTimeSeconds = 10;
            }


            result.Add(k.materials, materials);
            result.Add(k.productionTime, productionTimeSeconds);
            result.Add(k.price, price);
            result.Add(k.definition, targetDefintion);
            result.Add(k.materialMultiplier, materialMultiplier);
            result.Add(k.hasBonus, hasBonus);
            result.Add(k.targetQuantity, calibrationProgram.TargetQuantity);
            return(result);
        }
Example #3
0
        public ProductionInProgress StartPrototype(Character character, ProductionDescription productionDescription, Container container, bool useCorporationWallet, out bool hasBonus)
        {
            var foundComponents = productionDescription.SearchForAvailableComponents(container).ToList();

            var materialMultiplier = CalculateMaterialMultiplier(character, productionDescription.definition, out hasBonus);

            var itemsNeeded = productionDescription.ProcessComponentRequirement(ProductionInProgressType.prototype, foundComponents, 1, materialMultiplier);

            //put them to storage
            long[] reservedEids;
            ProductionHelper.ReserveComponents_noSQL(itemsNeeded, StorageEid, container, out reservedEids).ThrowIfError();

            var prototypeTimeSeconds = CalculatePrototypeTimeSeconds(character, productionDescription.definition);

            prototypeTimeSeconds = GetShortenedProductionTime(prototypeTimeSeconds);

            var productionInProgress = ProductionInProgressFactory();

            productionInProgress.amountOfCycles             = 1;
            productionInProgress.baseEID                    = Parent;
            productionInProgress.character                  = character;
            productionInProgress.facilityEID                = Eid;
            productionInProgress.finishTime                 = DateTime.Now.AddSeconds(prototypeTimeSeconds);
            productionInProgress.pricePerSecond             = GetPricePerSecond();
            productionInProgress.ReservedEids               = reservedEids;
            productionInProgress.resultDefinition           = productionDescription.GetPrototypeDefinition();
            productionInProgress.startTime                  = DateTime.Now;
            productionInProgress.totalProductionTimeSeconds = prototypeTimeSeconds;
            productionInProgress.type = ProductionInProgressType.prototype;
            productionInProgress.useCorporationWallet = useCorporationWallet;

            if (!productionInProgress.TryWithdrawCredit())
            {
                if (useCorporationWallet)
                {
                    throw new PerpetuumException(ErrorCodes.CorporationNotEnoughMoney);
                }

                throw new PerpetuumException(ErrorCodes.CharacterNotEnoughMoney);
            }

            return(productionInProgress);
        }
        public IDictionary <string, object> RefineQuery(Character character, int targetDefinition, int targetAmount, ProductionDescription productionDescription)
        {
            var replyDict = new Dictionary <string, object>();

            var materialEfficiency = GetMaterialMultiplier(character);
            var components         = productionDescription.Components
                                     .Where(c => !c.IsSkipped(ProductionInProgressType.refine))
                                     .ToDictionary("c", component => new Dictionary <string, object>
            {
                { k.definition, component.EntityDefault.Definition },
                { k.real, component.EffectiveAmount(targetAmount, materialEfficiency) },
                { k.nominal, component.Amount * targetAmount }
            });

            //these are the nominal and the real amounts
            replyDict.Add(k.components, components);

            //requested amount
            replyDict.Add(k.targetAmount, targetAmount);

            //requested definition
            replyDict.Add(k.targetDefinition, targetDefinition);

            //requested facility
            replyDict.Add(k.facility, Eid);

            return(replyDict);
        }