Example #1
0
        public Affix GetAffix(EquipmentModifiers equipmentModifiers, CurrencyModifiers currencyModifiers, List <Affix> affixes, EquipmentRarity rarity, IRandom random)
        {
            PoolKey key = new PoolKey(equipmentModifiers, currencyModifiers);

            if (!_poolDic.ContainsKey(key))
            {
                _poolDic.Add(key, GenerateAffixPool(equipmentModifiers, currencyModifiers));
            }

            AffixPool pool           = _poolDic[key];
            var       existingGroups = new HashSet <string>(affixes.Select(x => x.Group));

            int affixesCount = rarity == EquipmentRarity.Normal ? 0 :
                               rarity == EquipmentRarity.Magic ? 1 :
                               rarity == EquipmentRarity.Rare ? 3 : 0;

            double prefixSkipAmount = CalculateSkipAmount("prefix", pool.PrefixWeight, pool.PrefixGroupWeights, affixes, affixesCount);
            double suffixSkipAmount = CalculateSkipAmount("suffix", pool.SuffixWeight, pool.SuffixGroupWeights, affixes, affixesCount);

            var targetWeight = random.NextDouble() * (pool.TotalWeight - prefixSkipAmount - suffixSkipAmount);

            return(GetRandomAffixFromPool(pool, targetWeight, existingGroups, prefixSkipAmount, suffixSkipAmount));
        }
Example #2
0
 protected bool Equals(PoolKey other)
 {
     return(EquipmentModifiers.Equals(other.EquipmentModifiers) && CurrencyModifiers.Equals(other.CurrencyModifiers));
 }