Beispiel #1
0
        private void Subtract(MappedEquipment equipment)
        {
            if (equipment.Equipment == null)
            {
                return;
            }
            foreach (MappedSkill skill in equipment.Skills)
            {
                RemainingSkills[skill.MappedId] += skill.Level;
            }

            foreach (int slot in equipment.Equipment.Slots)
            {
                Slots[slot]--;
            }

            foreach (MappedSkillPart part in equipment.SkillParts)
            {
                ArmorSetSkillGrant grant = Grants[part.MappedId];
                if (grant.Progress == grant.Part.Requirement)
                {
                    foreach (MappedSkill grantedAbility in grant.Part.Skills)
                    {
                        RemainingSkills[grantedAbility.MappedId] += grantedAbility.Level;
                    }
                }
                grant.Progress--;
            }
        }
Beispiel #2
0
        private MappedEquipment[][] MapAllEquipment(IList <IList <IEquipment> > allEquipment, IDictionary <int, int> desiredDict, MappingResults results, bool createNullEquipments)
        {
            var allMapped = new MappedEquipment[allEquipment.Count][];

            for (int i = 0; i < allEquipment.Count; i++)
            {
                IList <IEquipment> equipments = allEquipment[i];
                allMapped[i] = MapEquipments(equipments, desiredDict, results, createNullEquipments);
            }
            return(allMapped);
        }
Beispiel #3
0
        public MappedEquipment[] MapSupersets(IList <SupersetInfo> supersets, MappingResults existingResults)
        {
            IDictionary <int, int> desiredDict = existingResults.DesiredAbilities.ToDictionary(x => x.SkillId, x => x.MappedId);
            var equipments = supersets.Select(x => x.Equipment).ToList();

            MappedEquipment[] mappedEquipments = MapEquipments(equipments, desiredDict, existingResults, false);
            for (int i = 0; i < mappedEquipments.Length; i++)
            {
                MappedEquipment equipment     = mappedEquipments[i];
                int             maxSkills     = supersets[i].MaxSkills;
                int             abilityLevels = equipment.Skills.Sum(x => x.Level);
                equipment.SkillDebt = abilityLevels - maxSkills;
            }
            return(mappedEquipments);
        }
Beispiel #4
0
        private MappedEquipment[] MapEquipments(IList <IEquipment> equipments, IDictionary <int, int> desiredDict, MappingResults results, bool createNullEquipment)
        {
            int startingIndex = 0;
            int count         = equipments.Count;

            if (createNullEquipment)
            {
                startingIndex = 1;
                count++;
            }
            var mappedEquipments = new MappedEquipment[count];

            if (createNullEquipment)
            {
                var nullEquipment = new MappedEquipment();
                nullEquipment.Skills     = new MappedSkill[0];
                nullEquipment.SkillParts = new MappedSkillPart[0];
                mappedEquipments[0]      = nullEquipment;
            }
            for (int j = startingIndex; j < count; j++)
            {
                IEquipment equipment       = equipments[j - startingIndex];
                var        mappedEquipment = new MappedEquipment();
                mappedEquipments[j]       = mappedEquipment;
                mappedEquipment.Equipment = equipment;
                mappedEquipment.Skills    = equipment.Abilities
                                            .Where(x => desiredDict.ContainsKey(x.Skill.Id))
                                            .Select(x => results.DesiredAbilities[desiredDict[x.Skill.Id]].CopyWithLevel(x.Level))
                                            .ToArray();
                mappedEquipment.SkillParts = new MappedSkillPart[0];
                if (equipment.Type == EquipmentType.Charm)
                {
                    continue;
                }
                var armor = (IArmorPiece)equipment;
                if (armor.ArmorSetSkills == null)
                {
                    continue;
                }
                var containedPartIDs = new HashSet <int>(armor.ArmorSetSkills.SelectMany(x => x.Parts).Select(x => x.Id));
                mappedEquipment.SkillParts = results.SetParts.Where(x => containedPartIDs.Contains(x.Part.Id)).ToArray();
            }
            return(mappedEquipments);
        }
Beispiel #5
0
 public void Replace(int index, MappedEquipment replacement)
 {
     Subtract(Equipments[index]);
     Add(replacement);
     Equipments[index] = replacement;
 }
Beispiel #6
0
        public bool TryGetSearchResult(Combination combination, bool hasSuperset, out ArmorSetSearchResult result)
        {
            result = new ArmorSetSearchResult();

            bool skillSummingSuccess = SkillSummingCutoff(combination);

            if (!skillSummingSuccess)
            {
                return(false);
            }

            result.Jewels = new List <ArmorSetJewelResult>();
            int[] totalSlots      = (int[])combination.Slots.Clone();
            int[] remainingLevels = (int[])combination.RemainingSkills.Clone();

            foreach (MappedJewel mappedJewel in combination.Jewels)
            {
                MappedSkill ability    = mappedJewel.Skill;
                int         mappedId   = ability.MappedId;
                int         needLevels = remainingLevels[mappedId];
                if (needLevels <= 0)
                {
                    continue;
                }

                bool jewelSlottingSuccess = TrySlotJewels(mappedJewel, totalSlots, remainingLevels, out ArmorSetJewelResult jewelResult);
                if (!jewelSlottingSuccess)
                {
                    return(false);
                }
                result.Jewels.Add(jewelResult);
            }

            if (hasSuperset)
            {
                bool skillDebtSuccess = SkillDebtCutoff(combination, totalSlots);
                if (!skillDebtSuccess)
                {
                    return(false);
                }
            }

            bool success = remainingLevels.All(x => x <= 0);

            if (!success)
            {
                return(false);
            }

            bool excludedCheckPass = CheckForExcludedSkills(combination);

            if (!excludedCheckPass)
            {
                return(false);
            }

            result.SpareSlots = new int[CutoffSearchConstants.Slots];
            for (int i = 0; i < CutoffSearchConstants.Slots; i++)
            {
                result.SpareSlots[i] = totalSlots[i + 1];
            }

            result.ArmorPieces = new List <IArmorPiece>(CutoffSearchConstants.ArmorTypes);
            for (int i = 0; i < CutoffSearchConstants.ArmorTypes; i++)
            {
                MappedEquipment equipment = combination.Equipments[i];
                if (equipment.Equipment != null)
                {
                    result.ArmorPieces.Add((IArmorPiece)equipment.Equipment);
                }
            }

            result.IsMatch = true;
            result.Charm   = (ICharmLevel)combination.Equipments[CutoffSearchConstants.ArmorTypes].Equipment;
            return(true);
        }