Example #1
0
        public void Go(string direction)
        {
            var areaInDirection = CurrentArea.GetNeighbor(direction);

            if (areaInDirection == null)
            {
                System.Console.WriteLine($"{this.Name} doesn't see anything {direction}..");
            }
            else
            {
                CurrentArea = areaInDirection;
                System.Console.WriteLine($"Ye, ok. Im at {CurrentArea.Name}");
            }
        }
Example #2
0
 /// <summary>
 /// Processes the go command.
 /// </summary>
 /// <param name="parts">Parts.</param>
 private static void ProcessGoCommand(string[] parts)
 {
     // If the user has not indicated where to go...
     if (parts.Length == 1)
     {
         PrintLineWarning("Go where?");
     }
     else
     {
         // try to find the neighbor the user has indicated.
         try
         {
             // move to that area if the command is understood.
             CurrentArea = CurrentArea.GetNeighbor(parts[1]);
         }
         catch (WorldException e)
         {
             // if GetNeighbor throws and exception, print the explanation.
             PrintLineDanger(e.Message);
         }
     }
 }