protected ItemContainer(ItemContainer template) : base(template) { Closed = template.Closed; Closable = template.Closable; MaximumWeight = template.MaximumWeight; }
public override Handler DoGet(ParsedInput input) { // take <item> from <container> if (input.Words.Length == 4) { return(DoGetExtended(input)); } // take <item> if (input.Words.Length == 1) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_WHAT, input.Words[0].ToSentenceCase().ToParagraph())); } if (IsDead) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_PLAYER_IS_DEAD)); } ItemContainer container = null; MESSAGE_ENUM message = MESSAGE_ENUM.PLAYER_GET; // find item in current room Item item = CurrentRoom.Items.Find(input.Words[1]); if (item == null) { // find item in a room container List <Item> containers = CurrentRoom.Items.GetItemsOfType(ITEM_TYPE.CONTAINER_ANY); for (int i = containers.Count() - 1; i >= 0; i--) { container = containers[i] as ItemContainer; item = container.Items.Find(input.Words[1]); if (item != null) { message = MESSAGE_ENUM.PLAYER_GET_FROM_ROOM_CONTAINER; break; } } } if (item == null) { message = MESSAGE_ENUM.PLAYER_GET_FROM_CONTAINER; foreach (EntityHand hand in Hands.Hands) { if (hand.Item == null) { continue; } if (hand.Item.IsType(ITEM_TYPE.CONTAINER_ANY)) { item = container.Items.Find(input.Words[1]); if (item != null) { break; } } } } if (item == null) { item = ContainerSlots.FindItem(input.Words[1]); } if (item == null) { // item not found return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_ITEM)); } // item found; attempt to put in hands if (Hands.Full) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_HANDS_ARE_FULL)); } EntityHand emptyHand = Hands.GetEmptyHand(); emptyHand.Item = item; // if we found in a container, remove from container if (container != null) { container.Items.RemoveItem(item); } // otherwise, remove from room else { CurrentRoom.Items.Remove(item); } return(Handler.HANDLED(message, item.NameWithIndefiniteArticle, container == null ? null : container.NameAsParagraph)); }