示例#1
0
        /// Print out some Help information.
        /// Here we print some stupid, cryptic message and a list of the
        /// command words.
        public bool Execute(Command cmd)
        {
            if (!cmd.hasSecondWord())
            {
                Console.WriteLine(
                    @"You are lost. You are alone.
You wander around at the university.
                             
Your command words are:
   {0}

{1}", commandMapper.AllCommands, Help());
            }
            else if (responses.ContainsKey(cmd.SecondWord))
            {
                Console.WriteLine(responses[cmd.SecondWord].Help());
            }
            else
            {
                Console.WriteLine(
                    @"Unknown command {0}!  Command words are
    {1}", cmd.SecondWord, commandMapper.AllCommands);
            }
            return(false);
        }
示例#2
0
        /// Print out some Help information.
        /// Here we print some stupid, cryptic message and a list of the
        /// command words.
        public bool Execute(Command cmd)
        {
            if (!cmd.hasSecondWord())
            {
                Console.WriteLine(
                    @"You are lost. You are alone.
You wander around at the university.
                             
Your command words are:
   {0}

{1}", CommandMapper.GetAllCommands(), Help());
            }
            else if (details.ContainsKey(cmd.GetSecondWord()))
            {
                Console.WriteLine(details[cmd.GetSecondWord()]);
            }
            else
            {
                Console.WriteLine(
                    @"Unknown command {0}!  Command words are
    {1}", cmd.GetSecondWord(), CommandMapper.GetAllCommands());
            }
            return(false);
        }
 /// "Quit" was entered. Check the rest of the command to see
 /// whether we really quit the game.
 /// Return true, if this command quits the game, false otherwise.
 public bool Execute(Command command)
 {
     if(command.hasSecondWord()) {
     Console.WriteLine("Quit what?");
     return false;
      }
      else {
     return UI.Agree("Do you really want to quit? ");
      }
 }
示例#4
0
 /// "Quit" was entered. Check the rest of the command to see
 /// whether we really quit the game.
 /// Return true, if this command quits the game, false otherwise.
 public bool Execute(Command command)
 {
     if (command.hasSecondWord())
     {
         Console.WriteLine("Quit what?");
         return(false);
     }
     else
     {
         return(UI.Agree("Do you really want to quit? "));
     }
 }
 /// Try to go to one direction. If there is an exit, enter the new
 /// place, otherwise print an error message.
 /// Return false(does not end game)
 public bool Execute(Command command)
 {
     if(!command.hasSecondWord()) {
     // if there is no second word, we don't know where to go...
     Console.WriteLine("Go where?");
     return false;
      }
      string direction = command.SecondWord;
      // Try to leave current place.
      Place nextPlace = game.CurrentPlace.getExit(direction);
      if (nextPlace == null) {
     Console.WriteLine("There is no door!");
      }
      else {
     game.CurrentPlace = nextPlace;
     Console.WriteLine(nextPlace.getLongDescription());
      }
      return false;
 }
        /// Print out some Help information.
        /// Here we print some stupid, cryptic message and a list of the
        /// command words.
        public bool Execute(Command cmd)
        {
            if (!cmd.hasSecondWord()) {
            Console.WriteLine(
               @"You are lost. You are alone.
            You wander around at the university.

            Your command words are:
               {0}

            {1}", commandMapper.AllCommands, Help());
             }
             else if (responses.ContainsKey(cmd.SecondWord)) {
            Console.WriteLine(responses[cmd.SecondWord].Help());
             }
             else {
            Console.WriteLine(
               @"Unknown command {0}!  Command words are
            {1}", cmd.SecondWord, commandMapper.AllCommands);
             }
             return false;
        }
示例#7
0
        /// Print out some Help information.
        /// Here we print some stupid, cryptic message and a list of the 
        /// command words.
        public bool Execute(Command cmd)
        {
            if (!cmd.hasSecondWord()) {
            Console.WriteLine(
            @"You are lost. You are alone.
            You wander around at the university.

            Your command words are:
               {0}

            {1}", CommandMapper.GetAllCommands(), Help());
             }
             else if (details.ContainsKey(cmd.GetSecondWord())) {
            Console.WriteLine(details[cmd.GetSecondWord()]);
             }
             else {
            Console.WriteLine(
            @"Unknown command {0}!  Command words are
            {1}", cmd.GetSecondWord(), CommandMapper.GetAllCommands());
             }
            return false;
        }
示例#8
0
        /// Try to go to one direction. If there is an exit, enter the new
        /// place, otherwise print an error message.
        /// Return false(does not end game)
        public bool Execute(Command command)
        {
            if (!command.hasSecondWord())
            {
                // if there is no second word, we don't know where to go...
                Console.WriteLine("Go where?");
                return(false);
            }
            string direction = command.GetSecondWord();
            // Try to leave current place.
            Place nextPlace = game.GetCurrentPlace().getExit(direction);

            if (nextPlace == null)
            {
                Console.WriteLine("There is no door!");
            }
            else
            {
                game.SetCurrentPlace(nextPlace);
                Console.WriteLine(nextPlace.getLongDescription());
            }
            return(false);
        }