Example #1
0
        public CraftMetadata Craft(
            List <ICraftingStep> craftingSteps,
            Equipment equipment,
            AffixManager affixManager,
            CancellationToken ct,
            double?currencyLimit)
        {
            CraftMetadata metadata = new CraftMetadata();

            metadata.Result = equipment;
            return(this.Craft(craftingSteps, equipment, affixManager, ct, metadata, currencyLimit));
        }
Example #2
0
        private CraftMetadata UpdateMetadataOnCraft(ICraftingStep craftingStep, CraftMetadata craftMetadata, bool isModified)
        {
            if (!craftMetadata.CraftingStepMetadata.ContainsKey(craftingStep))
            {
                CraftingStepMetadata stepMetadata = new CraftingStepMetadata {
                    TimesVisited = 0, CurrencyAmounts = craftingStep.GetCurrency
                };
                craftMetadata.CraftingStepMetadata.Add(craftingStep, stepMetadata);
            }

            craftMetadata.CraftingStepMetadata[craftingStep].TimesVisited++;

            if (isModified)
            {
                craftMetadata.CraftingStepMetadata[craftingStep].TimesModified++;
            }


            return(craftMetadata);
        }
Example #3
0
        public CraftMetadata Craft(
            List <ICraftingStep> craftingSteps,
            Equipment equipment,
            AffixManager affixManager,
            CancellationToken ct,
            CraftMetadata metadata,
            double?currencyLimit)
        {
            foreach (var craftingStep in craftingSteps)
            {
                if (equipment.Completed)
                {
                    return(metadata);
                }

                if (currencyLimit.HasValue && metadata.SpentCurrency > currencyLimit)
                {
                    return(metadata);
                }

                if (ct.IsCancellationRequested)
                {
                    ct.ThrowIfCancellationRequested();
                }

                bool isModified = craftingStep.Craft(equipment, affixManager);
                UpdateMetadataOnCraft(craftingStep, metadata, isModified);

                var times = 0;
                while (craftingStep.ShouldVisitChildren(equipment, times))
                {
                    metadata = Craft(craftingStep.Children, equipment, affixManager, ct, metadata, currencyLimit);
                    UpdateMetadataOnChildrenVisit(craftingStep, metadata);
                    times++;
                }
            }

            return(metadata);
        }
Example #4
0
 private void UpdateMetadataOnChildrenVisit(ICraftingStep craftingStep, CraftMetadata craftMetadata)
 {
     craftMetadata.CraftingStepMetadata[craftingStep].TimesChildrenVisited++;
 }