Beispiel #1
0
        public MudItem PullItemByName(string name)        //note this removes the item from inventory
        {
            MudItem item = null;

            try{
                item = Items[name].Pop();
            }catch (KeyNotFoundException) {}
            return(item);
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            MudItem other = obj as MudItem;

            if (other == null)
            {
                return(false);
            }
            return(this.Description == other.Description && this.Name == other.Name && this.MaxCount == other.MaxCount);
        }
Beispiel #3
0
 public void RemoveItem(MudItem item)
 {
     try{
         if (GetCountItem(item.Name) == 0)
         {
             return;
         }
         Items[item.Name].Pop();
     }catch (KeyNotFoundException) {}
 }
Beispiel #4
0
        public MudItem PeekItemByName(string name)
        {
            MudItem item = null;

            try{
                if (Items[name].Count == 0)
                {
                    return(null);
                }
                item = Items[name].Peek();
            }catch (KeyNotFoundException) {}
            return(item);
        }
Beispiel #5
0
        public bool AddItem(MudItem item)
        {
            int itemCount = 0;

            try{
                itemCount = Items[item.Name.ToLower()].Count;
            }catch (KeyNotFoundException) {
                Items.Add(item.Name.ToLower(), new Stack <MudItem>());
            }
            if (itemCount >= item.MaxCount)
            {
                return(false);
            }

            Items[item.Name.ToLower()].Push(item);
            return(true);
        }