示例#1
0
        public string Execute(TextAdventureEngine engine, string[] parts)
        {
            var directionLabel = string.Empty;

            if (RightSynonyms.Contains(parts.Last()))
            {
                engine.CurrentOrientation = DirectionCalculator.TurnRight(engine.CurrentOrientation);
                directionLabel            = "right";
            }

            if (LeftSynonyms.Contains(parts.Last()))
            {
                engine.CurrentOrientation = DirectionCalculator.TurnLeft(engine.CurrentOrientation);
                directionLabel            = "left";
            }

            if (BackwardsSynonyms.Contains(parts.Last()))
            {
                engine.CurrentOrientation = DirectionCalculator.Reverse(engine.CurrentOrientation);
                directionLabel            = "around";
            }

            return(directionLabel == string.Empty
                ? "I don't understand which way you want me to turn."
                : $"You turn {directionLabel}.");
        }
示例#2
0
 public void ReturnWestWhenTurnedLeftFromNorth()
 {
     Assert.Equal(DirectionCalculator.West, DirectionCalculator.TurnLeft(DirectionCalculator.North));
 }