Example #1
0
        public RefineResults Run(RefineSimulationParameters parameters, RefineCosts costs)
        {
            var refiner = new Refiner(parameters.Item, parameters.StartingLevel, parameters.RefineSteps);
            var counts  = new RefineCounts();

            for (int i = 0; i < parameters.Attempts; i++)
            {
                refiner.Item.ItemState   = ItemState.Valid;
                refiner.Item.RefineLevel = parameters.StartingLevel;

                while (refiner.Item.RefineLevel < parameters.SuccessLevel && refiner.Item.ItemState == ItemState.Valid)
                {
                    var method = parameters.RefineSteps[refiner.Item.RefineLevel];
                    refiner.RefineItem();

                    TickRefineCounts(counts, method, refiner.Item);

                    if (refiner.Item.ItemState == ItemState.Broken)
                    {
                        counts.BrokenItems++;
                        if (parameters.RepairOnBroken)
                        {
                            refiner.Item.ItemState = ItemState.Valid;
                            counts.RepairedItems++;
                        }
                        else // Downgrade
                        {
                            refiner.Item.RefineLevel = 9;
                            refiner.Item.ItemState   = ItemState.Valid;
                        }
                    }
                }

                if (refiner.Item.RefineLevel == parameters.SuccessLevel && refiner.Item.ItemState == ItemState.Valid)
                {
                    counts.Successes++;
                }

                counts.Attempts++;
            }

            return(BuildRefineResults(parameters.Item, counts, costs));
        }
Example #2
0
        public List <RefineResults> Run()
        {
            var simParameters = new RefineSimulationParameters
            {
                Attempts       = Attempts,
                RepairOnBroken = true,
                StartingLevel  = Item.SafeLevel,
                SuccessLevel   = 10,
                Item           = Item
            };

            var refineCombinations = GetRefineCombinations();
            var costs = new RefineCosts()
            {
                ItemCost = ItemCost
            };

            var resultHistory = new List <RefineResults>();
            var runner        = new RefineSimulationRunner();

            for (int i = 0; i < refineCombinations.Count; i++)
            {
                Console.WriteLine($"Computing combination {i + 1} of {refineCombinations.Count}");

                var refineSteps = GetDefaultRefineSteps();
                for (int j = 0; j < refineCombinations[i].Count; j++)
                {
                    refineSteps[j + simParameters.StartingLevel] = refineCombinations[i][j];
                }

                simParameters.RefineSteps = refineSteps;
                var results = runner.Run(simParameters, costs);
                results.RefineSteps = refineCombinations[i];

                resultHistory.Add(results);
            }

            return(resultHistory);
        }
Example #3
0
        private RefineResults BuildRefineResults(IRefinableItem item, RefineCounts counts, RefineCosts costs)
        {
            var results = new RefineResults();

            results.Successes     = counts.Successes;
            results.Attempts      = counts.Attempts;
            results.RepairedItems = counts.RepairedItems;
            results.BrokenItems   = counts.BrokenItems;

            results.RefinedItemCost = costs.ItemCost;

            foreach (var prop in counts.GetType().GetProperties().Where(x => x.Name.Contains("Consumed")))
            {
                results.ConsumableCounts.Add(prop.Name.Replace("Consumed", ""), (long)prop.GetValue(counts));
            }

            foreach (var prop in counts.GetType().GetProperties().Where(x => x.Name.Contains("Services")))
            {
                results.NpcRefineCounts.Add(prop.Name.Replace("Services", ""), (long)prop.GetValue(counts));
            }

            foreach (var kvp in results.ConsumableCounts.Where(x => x.Value > 0))
            {
                results.ConsumableCosts.Add(kvp.Key, kvp.Value * costs.ConsumableCosts[kvp.Key]);
            }

            foreach (var kvp in results.NpcRefineCounts.Where(x => x.Value > 0))
            {
                results.NpcRefineCosts.Add(kvp.Key, kvp.Value * costs.NpcRefineCosts[kvp.Key]);
            }

            switch (item)
            {
            case LevelOneWeapon _:
                results.NpcRepairCost = results.RepairedItems * (500000 + 2 * costs.ConsumableCosts["Bradium"] + 10 * costs.ConsumableCosts["Oridecon"] + 5 * costs.ConsumableCosts["GoldCoin"]);
                break;

            case LevelTwoWeapon _:
                results.NpcRepairCost = results.RepairedItems * (5000000 + 5 * costs.ConsumableCosts["Bradium"] + 25 * costs.ConsumableCosts["Oridecon"] + 10 * costs.ConsumableCosts["GoldCoin"]);
                break;

            case LevelThreeWeapon _:
                results.NpcRepairCost = results.RepairedItems * (40000000 + 40 * costs.ConsumableCosts["Bradium"] + 80 * costs.ConsumableCosts["Oridecon"] + 50 * costs.ConsumableCosts["GoldCoin"]);
                break;

            case LevelFourWeapon _:
                results.NpcRepairCost = results.RepairedItems * (50000000 + 50 * costs.ConsumableCosts["Bradium"] + 100 * costs.ConsumableCosts["Oridecon"] + 75 * costs.ConsumableCosts["GoldCoin"]);
                break;

            case Armor _:
                results.NpcRepairCost = results.RepairedItems * (5000000 + 5 * costs.ConsumableCosts["Carnium"] + 50 * costs.ConsumableCosts["Elunium"] + 10 * costs.ConsumableCosts["GoldCoin"]);
                break;
            }

            return(results);
        }