public MudItem PullItemByName(string name) //note this removes the item from inventory { MudItem item = null; try{ item = Items[name].Pop(); }catch (KeyNotFoundException) {} return(item); }
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); }
public void RemoveItem(MudItem item) { try{ if (GetCountItem(item.Name) == 0) { return; } Items[item.Name].Pop(); }catch (KeyNotFoundException) {} }
public MudItem PeekItemByName(string name) { MudItem item = null; try{ if (Items[name].Count == 0) { return(null); } item = Items[name].Peek(); }catch (KeyNotFoundException) {} return(item); }
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); }