Esempio n. 1
0
        private void EvaluateArmorSet(IEquipment[] equips, ISolverData data, List <ArmorSetSearchResult> results)
        {
            if (SolverUtils.IsAnyFullArmorSet(equips))
            {
                if (DataUtility.AreOnSameFullArmorSet(equips) == false)
                {
                    searchEquipmentsObjectPool.PutObject(equips);
                    return;
                }
            }

            ArmorSetSearchResult searchResult = IsArmorSetMatching(data.Weapon, equips);

            Interlocked.Increment(ref currentCombinations);

            if (searchResult.IsMatch)
            {
                searchResult.ArmorPieces = new IArmorPiece[]
                {
                    (IArmorPiece)equips[0],
                    (IArmorPiece)equips[1],
                    (IArmorPiece)equips[2],
                    (IArmorPiece)equips[3],
                    (IArmorPiece)equips[4],
                };
                searchResult.Charm = (ICharmLevel)equips[5];

                lock (results)
                    results.Add(searchResult);
            }

            searchEquipmentsObjectPool.PutObject(equips);
        }
Esempio n. 2
0
        private ArmorSetSearchResult IsArmorSetMatching(
            int[] weaponSlots, IEquipment[] equipments,
            SolverDataJewelModel[] matchingJewels,
            IAbility[] desiredAbilities
            )
        {
            List <ArmorSetJewelResult> requiredJewels = jewelResultObjectPool.GetObject();

            int[] availableSlots = availableSlotsObjectPool.GetObject();

            void OnArmorSetMismatch()
            {
                requiredJewels.Clear();
                jewelResultObjectPool.PutObject(requiredJewels);

                for (int i = 0; i < availableSlots.Length; i++)
                {
                    availableSlots[i] = 0;
                }
                availableSlotsObjectPool.PutObject(availableSlots);
            }

            if (IsAnyFullArmorSet(equipments))
            {
                if (DataUtility.AreOnSameFullArmorSet(equipments) == false)
                {
                    OnArmorSetMismatch();
                    return(ArmorSetSearchResult.NoMatch);
                }
            }

            if (weaponSlots != null)
            {
                foreach (int slotSize in weaponSlots)
                {
                    if (slotSize > 0)
                    {
                        availableSlots[slotSize - 1]++;
                    }
                }
            }

            foreach (IEquipment equipment in equipments)
            {
                if (equipment == null)
                {
                    continue;
                }

                foreach (int slotSize in equipment.Slots)
                {
                    availableSlots[slotSize - 1]++;
                }
            }

            foreach (IAbility ability in desiredAbilities)
            {
                int armorAbilityTotal = 0;

                if (IsAbilityMatchingArmorSet(ability, equipments))
                {
                    continue;
                }

                foreach (IEquipment equipment in equipments)
                {
                    if (equipment != null)
                    {
                        foreach (IAbility a in equipment.Abilities)
                        {
                            if (a.Skill.Id == ability.Skill.Id)
                            {
                                armorAbilityTotal += a.Level;
                            }
                        }
                    }
                }

                int remaingAbilityLevels = ability.Level - armorAbilityTotal;

                if (remaingAbilityLevels > 0)
                {
                    bool isAll = true;

                    foreach (int x in availableSlots)
                    {
                        if (x > 0)
                        {
                            isAll = false;
                            break;
                        }
                    }

                    if (isAll)
                    {
                        OnArmorSetMismatch();
                        return(ArmorSetSearchResult.NoMatch);
                    }

                    foreach (SolverDataJewelModel j in matchingJewels)
                    {
                        // bold assumption, will be f****d if they decide to create jewels with multiple skills
                        IAbility a = j.Jewel.Abilities[0];

                        if (a.Skill.Id == ability.Skill.Id)
                        {
                            int requiredJewelCount = remaingAbilityLevels / a.Level;

                            if (j.Available < requiredJewelCount)
                            {
                                OnArmorSetMismatch();
                                return(ArmorSetSearchResult.NoMatch);
                            }

                            if (ConsumeSlots(availableSlots, j.Jewel.SlotSize, requiredJewelCount) == false)
                            {
                                OnArmorSetMismatch();
                                return(ArmorSetSearchResult.NoMatch);
                            }

                            remaingAbilityLevels -= requiredJewelCount * a.Level;

                            requiredJewels.Add(new ArmorSetJewelResult {
                                Jewel = j.Jewel, Count = requiredJewelCount
                            });

                            break;
                        }
                    }

                    if (remaingAbilityLevels > 0)
                    {
                        OnArmorSetMismatch();
                        return(ArmorSetSearchResult.NoMatch);
                    }
                }
            }

            return(new ArmorSetSearchResult
            {
                IsMatch = true,
                Jewels = requiredJewels,
                SpareSlots = availableSlots
            });
        }