Пример #1
0
        protected override void Run()
        {
            var workingCharacter = new Character(_character);

            var basicLadderProcess               = new BasicLadderProcess(workingCharacter, _finalImplantTemplates, _unavailableImplantSlots);
            var ladderImplantTemplatesToLadder   = basicLadderProcess.OrderedLadderImplants.Select(i => i.ImplantTemplate);
            var ladderImplantsBasicLadderProcess = new BasicLadderProcess(workingCharacter, ladderImplantTemplatesToLadder, _unavailableImplantSlots);

            foreach (var orderedLadderLadderImplant in ladderImplantsBasicLadderProcess.OrderedLadderImplants)
            {
                workingCharacter.SetImplant(orderedLadderLadderImplant, isSlotKnownToBeEmpty: true);
                _orderedLadderImplants.Add(orderedLadderLadderImplant);
            }

            foreach (var orderedLadderImplant in ladderImplantsBasicLadderProcess.OrderedFinalImplants)
            {
                workingCharacter.SetImplant(orderedLadderImplant, isSlotKnownToBeEmpty: false);
                _orderedLadderImplants.Add(orderedLadderImplant);
            }

            var trialDegenerateLadderProcess = new DegenerateLadderProcess(workingCharacter, _finalImplantTemplates);

            if (trialDegenerateLadderProcess.TotalFinalImplantQL > basicLadderProcess.TotalFinalImplantQL)
            {
                TotalFinalImplantQL   = trialDegenerateLadderProcess.TotalFinalImplantQL;
                _orderedFinalImplants = trialDegenerateLadderProcess.OrderedFinalImplants;
            }
            else
            {
                TotalFinalImplantQL    = basicLadderProcess.TotalFinalImplantQL;
                _orderedLadderImplants = basicLadderProcess.OrderedLadderImplants.ToList();
                _orderedFinalImplants  = basicLadderProcess.OrderedFinalImplants;
            }
        }
Пример #2
0
        protected override void Run()
        {
            var workingCharacter = new Character(_character);

            while (true)
            {
                Implant nextLadderImplant = null;

                foreach (var emptyLadderImplantSlot in _availableLadderImplantSlots
                         .Where(workingCharacter.IsImplantSlotEmpty))
                {
                    foreach (var relevantLadderImplantGroup in emptyLadderImplantSlot.LadderImplantGroups
                             .Where(g => !g.IsSupersededByOtherLadderImplantGroups(workingCharacter)))
                    {
                        var trialLadderImplantTemplate = relevantLadderImplantGroup.GetBestImplantTemplate(workingCharacter);
                        var trialLadderImplant         = workingCharacter
                                                         .EquipMaxImplant(trialLadderImplantTemplate, isSlotKnownToBeEmpty: true);
                        var trialDegenerateLadderProcess = new DegenerateLadderProcess(workingCharacter, _finalImplantTemplates);
                        int trialTotalFinalImplantQL     = trialDegenerateLadderProcess.TotalFinalImplantQL;
                        var trialOrderedFinalImplants    = trialDegenerateLadderProcess.OrderedFinalImplants;

                        if (trialTotalFinalImplantQL > TotalFinalImplantQL
                            // The old application used this heuristic: if we've found an implant useful for laddering, and
                            // we've found another 'just as good' that adds more treatment, prefer the one adding more treatment.
                            || (nextLadderImplant != null &&
                                trialTotalFinalImplantQL == TotalFinalImplantQL &&
                                trialLadderImplant.TotalTreatmentIncrease > nextLadderImplant.TotalTreatmentIncrease))
                        {
                            TotalFinalImplantQL   = trialTotalFinalImplantQL;
                            _orderedFinalImplants = trialOrderedFinalImplants;
                            nextLadderImplant     = trialLadderImplant;
                        }

                        workingCharacter.UnequipImplant(trialLadderImplant.ImplantSlot);
                    }
                }

                if (nextLadderImplant != null)
                {
                    workingCharacter.SetImplant(nextLadderImplant, isSlotKnownToBeEmpty: true);
                    _orderedLadderImplants.Add(nextLadderImplant);
                }
                else
                {
                    break;
                }
            }

            // Avoid unnecessary ladder implants if the degenerate ladder process is just as good. It's convenient
            // for this check to come after the above, because the above implicitly guarantees we'll try at least 2
            // ladder implants deep (as long as 2+ slots are available) by virtue of TotalFinalImplantQL being
            // initialized to 0. This is important to handle the case where treatment and ability reqs are in perfect
            // balance w / each other s.t. only 1 ladder implant doesn't help at all. Doing this is only relevant
            // if we found < 2 ladder implants. If we found >= 2, it's because the 2nd ladder implant actually does help.
            if (_orderedLadderImplants.Count < 2)
            {
                workingCharacter = new Character(_character);

                var baseDegenerateLadderProcess = new DegenerateLadderProcess(workingCharacter, _finalImplantTemplates);
                int baseTotalFinalImplantQL     = baseDegenerateLadderProcess.TotalFinalImplantQL;
                var baseOrderedFinalImplants    = baseDegenerateLadderProcess.OrderedFinalImplants;

                if (baseTotalFinalImplantQL >= TotalFinalImplantQL)
                {
                    TotalFinalImplantQL = baseTotalFinalImplantQL;
                    _orderedLadderImplants.Clear();
                    _orderedFinalImplants = baseOrderedFinalImplants;
                }
            }
        }