コード例 #1
0
        public static float GetPowerLevelEstimateOfItem(Item item)
        {
            if (item == null)
            {
                return(0);
            }

            if (Cached.Instance.ITEM_POWER_LVL.ContainsKey(item.ItemID))
            {
                return(Cached.Instance.ITEM_POWER_LVL[item.ItemID]);
            }

            GearType type = ItemUtils.GetGearType(item);

            if (type == null)
            {
                return(0);
            }

            float highestPrice = type.GetAllItems().Max(x => x.Value);

            //Log.Debug("Highest value gear: " + highestPrice);

            float currentPrice = item.Value;

            float priceMulti = currentPrice / highestPrice;


            float highestDurability = type.GetAllItems().Where(x => !x.IsIndestructible).Max(x => x.MaxDurability);

            //Log.Debug("Highest durab gear: " + highestDurability);

            float currentDurability = item.MaxDurability;

            float durabilityMulti = currentDurability / highestDurability;

            if (item.IsIndestructible)
            {
                durabilityMulti = 1F + 0.2F; // indestructable items are usually super rare op ones
            }

            float result = (durabilityMulti + priceMulti) / 2F;

            Cached.Instance.ITEM_POWER_LVL.Add(item.ItemID, result);

            return(result);
        }