/// Constructor for objects of class Helper
 public Helper(Dictionary<string, Response> responses,
             CommandMapper commandMapper)
 {
     this.responses = responses;
      this.commandMapper = commandMapper;
      CommandName = "help";
 }
示例#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);
        }
示例#3
0
 /// Constructor for objects of class Helper
 public Helper(Dictionary <string, Response> responses,
               CommandMapper commandMapper)
 {
     this.responses     = responses;
     this.commandMapper = commandMapper;
     CommandName        = "help";
 }
示例#4
0
        /// Given a command: process (that is: Execute) the command.
        /// Return true If the command ends the game, false otherwise.
        private bool processCommand(Command command)
        {
            string cmd = command.GetCommandWord();

            if (!CommandMapper.isCommand(cmd))
            {
                Console.WriteLine("I don't know what you mean...");
                return(false);
            }
            bool toQuit;

            if (cmd == "help")
            {
                toQuit = helper.Execute(command);
            }
            else if (cmd == "go")
            {
                toQuit = goer.Execute(command);
            }
            else
            {
                toQuit = quitter.Execute(command);
            }
            return(toQuit);
        }
示例#5
0
        private Dictionary<string, Place> places; //places can be found by name

        #endregion Fields

        #region Constructors

        /// Create the game and initialise its internal map.
        public Game()
        {
            places = Place.createPlaces("place_data.txt");
             CurrentPlace = places["outside"];
             commandMapper = new CommandMapper(this);
        }
示例#6
0
 /// Create the game and initialise its internal map.
 public Game()
 {
     places        = Place.createPlaces("place_data.txt");
     CurrentPlace  = places["outside"];
     commandMapper = new CommandMapper(this);
 }