using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Framework.ItemSystem
{
    /// <summary>
    /// A collection of <see cref="ItemDefinition"/> objects. Used to provide
    /// item definitions to other classes, can be accessed using the
    /// <see cref="ItemDefinitionsLocator"/>. 
    /// TODO: May not be need, also partial for no reason?
    /// </summary>
    public partial class ItemDefinitions
    {
        private Dictionary<string, ItemDefinitionlike> itemDefinitions = new Dictionary<string, ItemDefinitionlike>(); 

        public ItemDefinitions()
        {
            //this.itemDefinitions = new Dictionary<string, ItemDefinitionlike>();
        }

        /// <summary>
        /// Adds a new item definition to the collection.
        /// </summary>
        /// <param name="itemDefinition">The item definition.</param>
        public void AddItemDefinition(ItemDefinitionlike itemDefinition)
        {
            this.itemDefinitions.Add(itemDefinition.GetName(), itemDefinition);
        }

        /// <summary>
        /// Gets an item definition by name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">An item definition with name:  + name +  does not exist.</exception>
        public ItemDefinitionlike GetItemDefinition(string name)
        {
            if (this.itemDefinitions.ContainsKey(name))
            {
                return this.itemDefinitions[name];
            }
            else
            {
                throw new ArgumentException("An item definition with name: " + name + " does not exist.");
            }
        }
    }
}
