public override Handler DoOpen(ParsedInput input) { if (input.Words.Length == 1) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_WHAT, "Open".ToParagraph())); } if (IsDead) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_PLAYER_IS_DEAD)); } ItemContainer container = ContainerSlots.GetContainer(input.Words[1]); if (container == null) { container = Hands.GetItem(input.Words[1], false, ITEM_TYPE.CONTAINER_ANY) as ItemContainer; } if (container == null) { container = CurrentRoom.Items.Find(input.Words[1], ITEM_TYPE.CONTAINER_ANY) as ItemContainer; } if (container == null) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_ITEM)); } if (!container.Closed) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_CONTAINER_ALREADY_OPEN, container.NameAsParagraph)); } container.Closed = false; return(Handler.HANDLED(MESSAGE_ENUM.PLAYER_OPEN, container.NameAsParagraph)); }
public override Handler DoPut(ParsedInput input) { // TODO: put <item> on <surface> //// put <item> in <container> if (input.Words.Length < 4) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } if (input.Words[2] != "in") { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } if (IsDead) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_PLAYER_IS_DEAD)); } // TODO: put <item> in MY <container> // if (input.Words.Length == 5 && input.Words[3] == "my") { return Handler.HANDLED(MESSAGE_ENUM.ERROR_NEED_TO_IMPLEMENT); } // must be holding item // don't remove item here Item item = Hands.GetItem(input.Words[1], false); if (item == null) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_NOT_CARRYING_ITEM)); } MESSAGE_ENUM message = MESSAGE_ENUM.PLAYER_PUT_IN_PLAYER_CONTAINER; ItemContainer container = ContainerSlots.GetContainer(input.Words[3]); if (container == null) { container = Hands.GetItem(input.Words[3], false, ITEM_TYPE.CONTAINER_ANY) as ItemContainer; } if (container == null || container.Equals(item)) { message = MESSAGE_ENUM.PLAYER_PUT_IN_GROUND_CONTAINER; container = CurrentRoom.Items.Find(input.Words[3], ITEM_TYPE.CONTAINER_ANY) as ItemContainer; } if (container == null) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } if (container.Closed) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_CONTAINER_CLOSED, container.NameAsParagraph)); } item = Hands.GetItem(input.Words[1], true); container.Items.Add(item); return(Handler.HANDLED(message, item.NameAsParagraph, container.NameAsParagraph)); }
protected override Handler DoLook(string strWord1, string strWord2, string strWord3) { // TODO: strWord2 could be ordinal OR "my" if (strWord1 == "at") { return(DoLook(strWord2, strWord3)); } if (strWord1 == "in") { int ordinal; if (Statics.OrdinalStringToInt.TryGetValue(strWord2, out ordinal)) { return(DoLookInContainer(strWord3, ordinal)); } else if (strWord2 == "my") { // TODO: fix GetItem to look for BOTH types of container here EntityHand hand = Hands.GetHandWithItem(strWord3); if (hand.Item != null) { if ((hand.Item.Type & ITEM_TYPE.CONTAINER_ANY) != hand.Item.Type) { // matched input with a hand, but hand is not holding a container return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } // hand is holding requested container ItemContainer handContainer = hand.Item as ItemContainer; if (handContainer.Closed) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_CONTAINER_CLOSED, handContainer.NameAsParagraph)); } return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, handContainer.ItemsParagraph)); } // hands didn't work; check container slots ItemContainer equippedContainer = ContainerSlots.GetContainer(strWord3); if (equippedContainer != null) { if (equippedContainer.Closed) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_CONTAINER_CLOSED, equippedContainer.NameAsParagraph)); } return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, equippedContainer.ItemsParagraph)); } return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } } return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); }
protected override Handler DoLook(string strWord) { // look hands - special case if (strWord == "hands") { return(DoLookHands(null)); } // TODO: consider more specific strings for held or equipped items Item item = CurrentRoom.Items.Find(strWord); if (item != null) { return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, (item.Description).ToParagraph())); } item = Hands.GetItem(strWord, false); if (item != null) { return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, (item.Description).ToParagraph())); } item = Body.GetItem(strWord, false); if (item != null) { return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, (item.Description).ToParagraph())); } item = ContainerSlots.GetContainer(strWord); //GetItem(strWord, false); if (item != null) { return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, (item.Description).ToParagraph())); } EntityNPCBase npc = CurrentRoom.NPCs.Find(strWord); if (npc != null) { return(Handler.HANDLED(MESSAGE_ENUM.BASE_STRING, npc.LookParagraph)); } return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); }
public override Handler DoClose(ParsedInput input) { if (input.Words.Length == 1) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_WHAT, "Close".ToParagraph())); } if (IsDead) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_PLAYER_IS_DEAD)); } // TODO: close MY <container> //if (input.Words.Length == 3 && input.Words[1] == "my") { return Handler.HANDLED(MESSAGE_ENUM.ERROR_NEED_TO_IMPLEMENT); } ItemContainer container = ContainerSlots.GetContainer(input.Words[1]); if (container == null) { container = Hands.GetItem(input.Words[1], false, ITEM_TYPE.CONTAINER_ANY) as ItemContainer; } if (container == null) { container = CurrentRoom.Items.Find(input.Words[1], ITEM_TYPE.CONTAINER_ANY) as ItemContainer; } if (container == null) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_ITEM)); } if (container.Closed) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_CONTAINER_ALREADY_CLOSED, container.NameAsParagraph)); } if (!container.Closable) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_CONTAINER_NOT_CLOSABLE, container.NameAsParagraph)); } container.Closed = true; return(Handler.HANDLED(MESSAGE_ENUM.PLAYER_CLOSE, container.NameAsParagraph)); }