GetBuyInfo() public method

public GetBuyInfo ( ) : IBuyItemInfo[]
return IBuyItemInfo[]
Ejemplo n.º 1
0
 public void OnSold(BaseVendor vendor, int amount)
 {
     if (EconomyItem)
     {
         foreach (var bii in vendor.GetBuyInfo().OfType <GenericBuyInfo>())
         {
             if (bii.Type == m_Type || (m_Type == typeof(UncutCloth) && bii.Type == typeof(Cloth)) || (m_Type == typeof(Cloth) && bii.Type == typeof(UncutCloth)))
             {
                 bii.TotalSold += amount;
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void OnBought(Mobile buyer, BaseVendor vendor, IEntity entity, int amount)
        {
            if (EconomyItem)
            {
                foreach (var bii in vendor.GetBuyInfo().OfType <GenericBuyInfo>())
                {
                    if (bii.Type == m_Type || (m_Type == typeof(UncutCloth) && bii.Type == typeof(Cloth)) || (m_Type == typeof(Cloth) && bii.Type == typeof(UncutCloth)))
                    {
                        bii.TotalBought += amount;
                    }
                }
            }

            EventSink.InvokeValidVendorPurchase(new ValidVendorPurchaseEventArgs(buyer, vendor, entity, m_Price));
        }
        public static int GetPriceFromVendor(BaseVendor vendor, Type itemType)
        {
            IBuyItemInfo[] buyInfo = vendor.GetBuyInfo();

            for (int i = 0; i < buyInfo.Length; ++i)
            {
                IBuyItemInfo buyItem = (IBuyItemInfo)buyInfo[i];
                GenericBuyInfo gbi = (GenericBuyInfo)buyItem;

                if (gbi.Type == itemType)
                    return buyItem.Price;
            }

            return 0;
        }
Ejemplo n.º 4
0
        public int GetSellPriceFor(Item item, BaseVendor vendor)
        {
            int price = 0;

            m_Table.TryGetValue(item.GetType(), out price);

            if (vendor != null && BaseVendor.UseVendorEconomy)
            {
                IBuyItemInfo buyInfo = vendor.GetBuyInfo().OfType <GenericBuyInfo>().FirstOrDefault(info => info.EconomyItem && info.Type == item.GetType());

                if (buyInfo != null)
                {
                    int sold = buyInfo.TotalSold;
                    price = (int)(buyInfo.Price * .75);

                    return(Math.Max(1, price));
                }
            }

            if (item is BaseArmor)
            {
                BaseArmor armor = (BaseArmor)item;

                if (armor.Quality == ItemQuality.Low)
                {
                    price = (int)(price * 0.60);
                }
                else if (armor.Quality == ItemQuality.Exceptional)
                {
                    price = (int)(price * 1.25);
                }

                price += 100 * (int)armor.Durability;

                price += 100 * (int)armor.ProtectionLevel;

                if (price < 1)
                {
                    price = 1;
                }
            }
            else if (item is BaseWeapon)
            {
                BaseWeapon weapon = (BaseWeapon)item;

                if (weapon.Quality == ItemQuality.Low)
                {
                    price = (int)(price * 0.60);
                }
                else if (weapon.Quality == ItemQuality.Exceptional)
                {
                    price = (int)(price * 1.25);
                }

                price += 100 * (int)weapon.DurabilityLevel;

                price += 100 * (int)weapon.DamageLevel;

                if (price < 1)
                {
                    price = 1;
                }
            }
            else if (item is BaseBeverage)
            {
                int price1 = price, price2 = price;

                if (item is Pitcher)
                {
                    price1 = 3;
                    price2 = 5;
                }
                else if (item is BeverageBottle)
                {
                    price1 = 3;
                    price2 = 3;
                }
                else if (item is Jug)
                {
                    price1 = 6;
                    price2 = 6;
                }

                BaseBeverage bev = (BaseBeverage)item;

                if (bev.IsEmpty || bev.Content == BeverageType.Milk)
                {
                    price = price1;
                }
                else
                {
                    price = price2;
                }
            }

            return(price);
        }
Ejemplo n.º 5
0
        public int GetSellPriceFor(Item item, BaseVendor vendor)
        {
            int price;

            m_Table.TryGetValue(item.GetType(), out price);

            if (vendor != null && BaseVendor.UseVendorEconomy)
            {
                IBuyItemInfo buyInfo = null;

                var infos = vendor.GetBuyInfo();

                for (var index = 0; index < infos.Length; index++)
                {
                    IBuyItemInfo info = infos[index];

                    if (info is GenericBuyInfo gbi && gbi.EconomyItem && gbi.Type == item.GetType())
                    {
                        buyInfo = gbi;
                        break;
                    }
                }

                if (buyInfo != null)
                {
                    int sold = buyInfo.TotalSold;

                    price = (int)(buyInfo.Price * .75);

                    return(Math.Max(1, price));
                }
            }

            if (item is BaseArmor armor)
            {
                if (armor.Quality == ItemQuality.Low)
                {
                    price = (int)(price * 0.60);
                }
                else if (armor.Quality == ItemQuality.Exceptional)
                {
                    price = (int)(price * 1.25);
                }

                price += 5 * armor.ArmorAttributes.DurabilityBonus;

                if (price < 1)
                {
                    price = 1;
                }
            }
            else if (item is BaseWeapon weapon)
            {
                if (weapon.Quality == ItemQuality.Low)
                {
                    price = (int)(price * 0.60);
                }
                else if (weapon.Quality == ItemQuality.Exceptional)
                {
                    price = (int)(price * 1.25);
                }

                price += 100 * weapon.WeaponAttributes.DurabilityBonus;

                price += 10 * weapon.Attributes.WeaponDamage;

                if (price < 1)
                {
                    price = 1;
                }
            }
            else if (item is BaseBeverage bev)
            {
                int price1 = price, price2 = price;

                if (bev is Pitcher)
                {
                    price1 = 3;
                    price2 = 5;
                }
                else if (bev is BeverageBottle)
                {
                    price1 = 3;
                    price2 = 3;
                }
                else if (bev is Jug)
                {
                    price1 = 6;
                    price2 = 6;
                }

                if (bev.IsEmpty || bev.Content == BeverageType.Milk)
                {
                    price = price1;
                }
                else
                {
                    price = price2;
                }
            }

            return(price);
        }