public void DegenerateLadderProcessWhenNoFinalLadderImplants()
        {
            var finalImplantTemplates = new[]
            {
                ImplantTemplate.GetImplantTemplate(ImplantSlot.Head, Skill.MatterCrea, Skill.NanoPool, Skill.Tutoring),                      // Intelligence
                ImplantTemplate.GetImplantTemplate(ImplantSlot.LeftWrist, Skill.MultMelee, Skill.RunSpeed, Skill.NanoResist),                // Agility
                ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Skill.OneHandBlunt, ArmorClass.ChemicalAC, ArmorClass.RadiationAC), // Strength
                ImplantTemplate.GetImplantTemplate(ImplantSlot.Waist, ArmorClass.ChemicalAC, MaxHealthOrNano.MaxNano, Skill.BioMetamor)      // Sense
            };

            var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates);

            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Intelligence), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[0]).QL);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[1]).QL);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Strength), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[2]).QL);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Sense), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[3]).QL);

            // Implants should be unequipped right now and stats should be the same as they were before laddering.
            Assert.AreEqual(0, _character.GetAverageImplantQL());
            Assert.AreEqual(0, _character.GetTotalImplantQL());
            Assert.AreEqual(91, _character.GetAbilityValue(Ability.Agility));
            Assert.AreEqual(91, _character.GetAbilityValue(Ability.Stamina));
            Assert.AreEqual(281.4, _character.TreatmentValue);
        }
        public void EquipMaxImplantUnequipsFirst()
        {
            _character.SetAbilityValue(Ability.Agility, 300); // Max sure it's not the limiting factor.
            var lowHead  = Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 20);
            var maxHead1 = _character.GetMaxImplant(lowHead.ImplantTemplate);

            _character.SetImplant(lowHead);
            var maxHead2            = _character.GetMaxImplant(lowHead.ImplantTemplate);
            var impossibleHotswapQL = Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility), _character.TreatmentValue);

            Assert.AreEqual(maxHead1.QL, maxHead2.QL);
            Assert.IsTrue(impossibleHotswapQL > maxHead1.QL);
        }
        public void DegenerateLadderProcessWhenASingleFinalLadderImplant()
        {
            var finalImplantTemplates = new[]
            {
                ImplantTemplate.GetImplantTemplate(ImplantSlot.Head, Skill.QuantumFT, null, Skill.Tutoring),                                 // Agility
                ImplantTemplate.GetImplantTemplate(ImplantSlot.LeftWrist, Skill.MultMelee, Skill.RunSpeed, Skill.NanoResist),                // Agility
                ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Skill.OneHandBlunt, ArmorClass.ChemicalAC, ArmorClass.RadiationAC), // Strength
                ImplantTemplate.GetImplantTemplate(ImplantSlot.Leg, Ability.Agility, Ability.Stamina, null),                                 // Stamina
                ImplantTemplate.GetImplantTemplate(ImplantSlot.Waist, ArmorClass.ChemicalAC, null, Skill.BioMetamor)                         // Stamina
            };

            var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates);

            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Stamina), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants[0].QL);
            Assert.AreEqual(finalImplantTemplates[3], ladderProcess.OrderedFinalImplants[0].ImplantTemplate);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility) + ladderProcess.OrderedFinalImplants[0].ShinyStatIncrease.Value, _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[0]).QL);
            Assert.AreEqual(51, ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[0]).QL);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility) + ladderProcess.OrderedFinalImplants[0].ShinyStatIncrease.Value, _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[1]).QL);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Strength), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[2]).QL);
            Assert.AreEqual(
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Stamina) + ladderProcess.OrderedFinalImplants[0].ShinyStatIncrease.Value, _character.TreatmentValue),
                Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Sense), _character.TreatmentValue),
                ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[4]).QL);

            // Implants should be unequipped right now and stats should be the same as they were before laddering.
            Assert.AreEqual(0, _character.GetAverageImplantQL());
            Assert.AreEqual(0, _character.GetTotalImplantQL());
            Assert.AreEqual(91, _character.GetAbilityValue(Ability.Agility));
            Assert.AreEqual(91, _character.GetAbilityValue(Ability.Stamina));
            Assert.AreEqual(281.4, _character.TreatmentValue);

            // Using the order the ladder process outlines, all equips should be possible and maximal.
            foreach (var finalImplant in ladderProcess.OrderedFinalImplants)
            {
                Assert.IsTrue(_character.CanEquipImplant(finalImplant));
                var maxImplant = _character.EquipMaxImplant(finalImplant.ImplantTemplate);
                Assert.AreEqual(maxImplant, finalImplant);
            }
        }