예제 #1
0
        public override string UseItem(Command command, Room currentRoom)
        {
            string input = command.ThirdWord;

            if (!command.HasThirdWord())
            {
                TextEffects.ColoredMessage("Use it on what?", "DarkRed");
                return(null);
            }
            Room target = currentRoom.GetExit(input);

            if (target == null)
            {
                TextEffects.ColoredMessage("There is door there to unlock!", "DarkRed");
                return(null);
            }
            else if (!target.IsLocked())
            {
                TextEffects.ColoredMessage("That door isn't locked!", "DarkRed");
                return(null);
            }
            else if (!target.UseKey(this))
            {
                TextEffects.ColoredMessage("You fiddle with the key in the lock but you can't seem to unlock it.", "DarkRed");
                return(null);
            }
            return("You put the key in the lock and turn it.\nThe lock opens and the key disappears.");
        }