示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        public override Handler DoDrop(ParsedInput input)
        {
            if (input.Words.Length == 1)
            {
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_WHAT, "Drop".ToParagraph()));
            }
            if (IsDead)
            {
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_PLAYER_IS_DEAD));
            }

            Item item = Hands.GetItem(input.Words[1], true);

            if (item == null)
            {
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_NOT_CARRYING_ITEM));
            }

            CurrentRoom.Items.Add(item);
            return(Handler.HANDLED(MESSAGE_ENUM.PLAYER_DROP, item.NameAsParagraph));
        }