/// 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); }
/// 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; }
/// 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; }
/// 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); }