예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length != 1 || args[0].Equals("help", StringComparison.OrdinalIgnoreCase))
            {
                PrintUsage();
                return;
            }

            string path = args[0];

            if (!File.Exists(path))
            {
                Console.Error.WriteLine($"Error file {path} not found.");
                PrintUsage();
                return;
            }

            SkillPriorityQueue queue = new SkillPriorityQueue(path);

            Build build = queue.GetBuild();

            if (build == null)
            {
                return;
            }

            using (StreamWriter writer = new StreamWriter(new FileStream("Build.txt", FileMode.Create)))
            {
                writer.WriteLine("Initial build:");

                foreach (Special special in EnumHelper.GetEnumValues <Special>())
                {
                    writer.WriteLine($"    {special}: {build.InitialBuild[special]}");
                }

                writer.WriteLine("Perk investment per level:");

                IEnumerable <PerkInstruction> infos = build.BuildOrder;
                for (int i = 0; i < infos.Count(); ++i)
                {
                    PerkInstruction info = infos.ElementAt(i);
                    writer.WriteLine($"    Level {i + 2}: {info.Perk} level {info.PerkLevel}");
                }
            }
        }
예제 #2
0
        public Build GetBuild()
        {
            if (!_good)
            {
                return(null);
            }

            while (_queue.Count > 0)
            {
                GetNextPerk(out PriorityPerkRequest next, out int pos);

                if (IsSpecial(next.Perk))
                {
                    if (_initialSpecialPoints > 0)
                    {
                        _initialSpecialPoints--;
                        Special target = (Special)Enum.Parse(typeof(Special), next.Perk);
                        _initialBuild[target]++;
                        _queue.RemoveAt(pos);
                        //RemoveSpecialsFromQueue(target, _initialBuild[target]);

                        continue;
                    }
                }
                else
                {
                    EnsureSpecialForPerk(next.Perk, next.PerkLevel);
                }

                PerkInstruction pi = new PerkInstruction()
                {
                    Perk = next.Perk, PerkLevel = next.PerkLevel
                };
                _buildOrder.Add(pi);
                _queue.RemoveAt(pos);

                _currentLevel++;
            }

            return(new Build()
            {
                InitialBuild = _initialBuild, BuildOrder = _buildOrder
            });
        }
예제 #3
0
        private void EnsureSpecialForPerk(string perkName, int perkLevel)
        {
            Perk    perk            = GetPerk(perkName);
            Special requiredSpecial = perk.specialPreReq.type;
            int     requiredLevel   = perk.specialPreReq.level;

            int currentLevel = _initialBuild[requiredSpecial] + _investedPoints[requiredSpecial];

            if (currentLevel >= requiredLevel)
            {
                return;
            }

            int diff = requiredLevel - currentLevel;

            while (diff > 0)
            {
                currentLevel = _initialBuild[requiredSpecial] + _investedPoints[requiredSpecial];
                if (_initialSpecialPoints > 0)
                {
                    _initialSpecialPoints--;
                    _initialBuild[requiredSpecial]++;
                }
                else
                {
                    _investedPoints[requiredSpecial]++;
                    PerkInstruction pi = new PerkInstruction()
                    {
                        Perk = requiredSpecial.ToString(), PerkLevel = currentLevel + 1
                    };
                    _buildOrder.Add(pi);
                }

                RemoveSpecialsFromQueue(requiredSpecial, currentLevel + 1);

                diff--;
            }
        }