Exemplo n.º 1
0
        public static Dictionary <string, object> GetRequiredComponentsInfo(ProductionInProgressType productionInProgressType, int targetAmount, double materialMultiplier, List <ProductionComponent> components)
        {
            var result  = new Dictionary <string, object>();
            var counter = 0;

            foreach (var component in components)
            {
                if (component.IsSkipped(productionInProgressType))
                {
                    continue;
                }

                var oneComponent = new Dictionary <string, object>
                {
                    { k.definition, component.EntityDefault.Definition }
                };

                //single component
                if (component.IsSingle)
                {
                    oneComponent.Add(k.amount, targetAmount);
                    oneComponent.Add(k.effectiveAmount, 1);
                }
                else
                {
                    oneComponent.Add(k.effectiveAmount, component.EffectiveAmount(targetAmount, materialMultiplier));
                    oneComponent.Add(k.nominalAmount, component.Amount);
                }

                result.Add("c" + counter++, oneComponent);
            }

            return(result);
        }
        public bool IsSkipped(ProductionInProgressType productionInProgressType)
        {
            switch (productionInProgressType)
            {
            case ProductionInProgressType.insurance:
            case ProductionInProgressType.reprocess:
            case ProductionInProgressType.refine:
                return(IsSingle || IsRobotShard);

            case ProductionInProgressType.massProduction:
                return(IsRobotShard);
            }

            return(false);
        }
Exemplo n.º 3
0
        public static IEnumerable <ProductionLiveComponent> ProcessComponentRequirement(ProductionInProgressType productionType, List <ProductionLiveComponent> foundComponents, int targetAmount, double materialMultiplier, List <ProductionComponent> components)
        {
            var itemsNeeded         = new List <ProductionLiveComponent>();
            var componentsMissing   = new Dictionary <string, object>();
            var wasComponentMissing = false;
            var missingCounter      = 0;

            foreach (var component in components)
            {
                var defName = component.EntityDefault.Name;

                if (component.IsSkipped(productionType))
                {
                    continue;
                }

                var realNeededAmount = component.EffectiveAmount(targetAmount, materialMultiplier);
                var componentFound   = false;
                var amountFound      = 0;


                foreach (var foundComponent in foundComponents)
                {
                    if (foundComponent.definition != component.EntityDefault.Definition)
                    {
                        continue;
                    }

                    Logger.Info("checking eid:" + foundComponent.eid + " " + defName + " needed:" + realNeededAmount + " found:" + foundComponent.quantity);

                    if (foundComponent.quantity <= realNeededAmount - amountFound)
                    {
                        Logger.Info("eaten completely: " + foundComponent.eid);

                        //kill it
                        foundComponent.resultQuantity = 0;

                        //increase the total amount we found with the quantity was found in the current item
                        amountFound += foundComponent.quantity;
                    }
                    else
                    {
                        Logger.Info("fraction used: " + foundComponent.eid + " component match successful!");

                        //descrease item's quantity
                        foundComponent.resultQuantity -= realNeededAmount - amountFound;

                        //amount satisfied
                        amountFound += realNeededAmount - amountFound;
                    }

                    itemsNeeded.Add(foundComponent);

                    if (amountFound != realNeededAmount)
                    {
                        continue;
                    }

                    componentFound = true;
                    break;
                }

                if (componentFound)
                {
                    continue;
                }

                wasComponentMissing = true;

                var missingInfo = new Dictionary <string, object>
                {
                    { k.definition, component.EntityDefault.Definition },
                    { k.targetAmount, realNeededAmount },
                    { k.amount, amountFound }
                };

                componentsMissing.Add("m" + missingCounter++, missingInfo);
            }

            wasComponentMissing.ThrowIfTrue(ErrorCodes.RequiredComponentNotFound, gex => gex.SetData(k.missing, componentsMissing));
            return(itemsNeeded);
        }
Exemplo n.º 4
0
        public static void ProductionLogInsert(Character character, int definition, int amount, ProductionInProgressType productionInProgressType, int durationSecs, double price, bool useCorporationWallet)
        {
            var res = Db.Query().CommandText("insert productionlog (characterid,definition,amount, productiontype,durationsecs,price,usecorporationwallet) values (@characterID,@definition,@amount, @type,@duration,@price,@useCorpWallet)")
                      .SetParameter("@characterID", character.Id)
                      .SetParameter("@definition", definition)
                      .SetParameter("@amount", amount)
                      .SetParameter("@type", (int)productionInProgressType)
                      .SetParameter("@duration", durationSecs)
                      .SetParameter("@price", price)
                      .SetParameter("@useCorpWallet", useCorporationWallet)
                      .ExecuteNonQuery();

            if (res != 1)
            {
                Logger.Error("sql insert error in ProductionLogInsert. chid:" + character.Id + " def:" + definition + " amount:" + amount);
            }
        }
Exemplo n.º 5
0
 public IEnumerable <ProductionLiveComponent> ProcessComponentRequirement(ProductionInProgressType productionType, List <ProductionLiveComponent> foundComponents, int targetAmount, double materialMultiplier)
 {
     return(ProductionHelper.ProcessComponentRequirement(productionType, foundComponents, targetAmount, materialMultiplier, Components));
 }