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); }
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); }