public bool HasAllTheseItems(List <ItemQuantity> items) { foreach (ItemQuantity item in items) { if (Inventory.Count(i => i.ItemTypeID == item.ItemID) < item.Quantity) { return(false); } } return(true); }
//methods public bool HasAllTheseItems(List <ItemQuantity> itemQuantities) { foreach (ItemQuantity itemQuantity in itemQuantities) { if (Inventory.Count(i => i.Name == ItemFactory.CreateGameItem(itemQuantity.ItemId).Name) < itemQuantity.Quantity) { return(false); } } return(true); }
public bool HasAllTheseItems(List <ItemQuantity> items) // this function check if the player has all the items required to complete the quest { // function accepts a list of ItemQuantity objects and looks through the playr's inventory foreach (ItemQuantity item in items) { if (Inventory.Count(i => i.ItemTypeID == item.ItemID) < item.Quantity) //if the count of items is less than the number required in the parameter, the function returns false; if the player has a large enough quantity for all the items passed into the function it will return true { return(false); } } return(true); }
public bool HasAllTheseItems(List <ItemQuantity> items) { foreach (ItemQuantity item in items) { //Count how many items player has in their inventory where the ItemID matches. //If the count is less than the count of the passed in parameter, return false //as player does not have enough items. if (Inventory.Count(i => i.ItemTypeID == item.ItemID) < item.Quantity) { return(false); } } //If we get through all the items in the list and we haven't returned false for any, //player has enough items so return true. return(true); }