public bool HasAllQuestCompletionItems(Quest quest)
        {
            //See if the player has all the items needed to complete the quest here
            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                //Check each item in the player's inventory to see if they have it and enough of it
                if (!Inventory.Any(ii => ii.Details.ID == qci.Details.ID && ii.Quantity >= qci.Quantity))
                {
                    return(false);
                }
            }

            //If we got here then the player must have all the required items and enough of them to complete the quest
            return(true);
        }
Exemple #2
0
        public void AddMonsterRewards(Monster monster, List <Item> loot)
        {
            AddExperiencePoints(monster.RewardExperiencePoints);
            Gold += monster.RewardGold;

            foreach (Item rewardItems in loot)
            {
                if (Inventory.Any(x => x.Details.ID == rewardItems.ID))
                {
                    Inventory.SingleOrDefault(x => x.Details.ID == rewardItems.ID).Quantity += 1;
                }
                else
                {
                    Inventory.Add(new InventoryItem(rewardItems, 1));
                }
            }
        }
        public bool PlayerHasAllQuestCompletionItems(Quest quest)
        {
            // See if the player has all the items needed to complete the quest here
            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                // Check each item in the player's inventory, to see if they have it, and enough of it
                if (!Inventory.Any(ii => ii.Details.ID ==
                                   qci.Details.ID && ii.Quantity >= qci.Quantity))
                {
                    return(false);
                }
                // The quest completion item for this loop must be in inventory, and have enough quantity
            }

            // If we got here, then player must have all the required items, and enough of them, to complete the quest.
            return(true);
        }
Exemple #4
0
        public bool HasItemsForQuest(Quest quest)
        {
            //see if player has all quest items
            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                //check each item in inventory to see if enough of qci is there
                if (!Inventory.Any(ii => ii.Details.ID == qci.Details.ID && ii.Quantity >= qci.Quantity))
                {
                    return(false);
                }
                //if it gets here, there is enough in inventory
                return(true);
            }

            //player does have items in inventory if we get here
            return(true);
        }
Exemple #5
0
        public bool HasAllQuestCompletionItems(Quest quest)
        {
            /*
             * // See if the player has all the items needed to complete the quest here
             * foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
             * {
             *  bool foundItemInPlayersInventory = false;
             *
             *  // Check each item in the player's inventory, to see if they have it, and enough of it
             *  foreach (InventoryItem ii in Inventory)
             *  {
             *      if (ii.Details.ID == qci.Details.ID) // The player has the item in their inventory
             *      {
             *          foundItemInPlayersInventory = true;
             *
             *          if (ii.Quantity < qci.Quantity) // The player does not have enough of this item to complete the quest
             *          {
             *              return false;
             *          }
             *      }
             *  }
             *
             *  // The player does not have any of this quest completion item in their inventory
             *  if (!foundItemInPlayersInventory)
             *  {
             *      return false;
             *  }
             * }
             *
             * // If we got here, then the player must have all the required items, and enough of them, to complete the quest.
             * return true; */
            // See if the player has all the items needed to complete the quest here
            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                // Check each item in the player's inventory, to see if they have it, and enough of it
                if (!Inventory.Any(ii => ii.Details.ID == qci.Details.ID && ii.Quantity >= qci.Quantity))
                {
                    return(false);
                }
            }

            // If we got here, then the player must have all the required items, and enough of them, to complete the quest.
            return(true);
        }
Exemple #6
0
        public bool HasRequiredItemToEnterThisLocation(Location location)
        {
            if (location.ItemRequiredToEnter == null)
            {
                // There is no required item for this location, so return "true"
                return(true);
            }

            // See if the player has the required item in their inventory

            /* foreach (InventoryItem ii in Inventory)
             * {
             *  if (ii.Details.ID == location.ItemRequiredToEnter.ID)
             *  {
             *      // We found the required item, so return "true"
             *      return true;
             *  }
             * }*/
            return(Inventory.Any(ii => ii.Details.ID == location.ItemRequiredToEnter.ID));

            // We didn't find the required item in their inventory, so return "false"
            // return false;
        }
Exemple #7
0
 public bool HasItem(Item item, int quantity) // check if the player has an item(s)
 {
     return(Inventory.Any(ii => ii.Details.ID == item.ID));
 }