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
        protected override ArmorSetSearchResult IsArmorSetMatching(IEquipment weapon, IEquipment[] equipments)
        {
            List <ArmorSetJewelResult> requiredJewels = jewelResultObjectPool.GetObject();

            int[] availableSlots = availableSlotsObjectPool.GetObject();

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

                ReturnSlotsArray(availableSlots);
            }

            SolverUtils.AccumulateAvailableSlots(weapon, availableSlots);

            foreach (IEquipment equipment in equipments)
            {
                SolverUtils.AccumulateAvailableSlots(equipment, availableSlots);
            }

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

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

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

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

                int remaingAbilityLevels = ability.Level - armorAbilityTotal;

                if (remaingAbilityLevels <= 0)
                {
                    continue;
                }

                if (SolverUtils.AreAllSlotsUsed(availableSlots))
                {
                    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)
                    {
                        continue;
                    }

                    int requiredJewelCount = remaingAbilityLevels / a.Level; // This will turn into a bug with jewels providing skill with level 2 or more.

                    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
            });
        }