DivineRightGame.ItemFactory.ItemFactoryManagers.InventoryItemManager.GetItemWithinPriceRange C# (CSharp) Method

GetItemWithinPriceRange() public method

Creates an item with an optional category costing between a minimum and maximum price
public GetItemWithinPriceRange ( string category, int minimum, int maximum ) : InventoryItem
category string
minimum int
maximum int
return DRObjects.Items.Archetypes.Local.InventoryItem
        public InventoryItem GetItemWithinPriceRange(string category,int minimum, int maximum)
        {
            //Get the entire database
            var database = DatabaseHandling.GetDatabase(Archetype.INVENTORYITEMS);

            var chosenValue = database.Where(d => category == null || category.Equals(d.Value[10]) && Int32.Parse(d.Value[4]) >= minimum && Int32.Parse(d.Value[4]) <= maximum).OrderBy(d => GameState.Random.Next(1000)).Select(d => d.Key).FirstOrDefault();

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

            //Otherwise create the item
            return CreateItem(chosenValue) as InventoryItem;
        }