public void Initialise()
 {
     _currentGame = new Game(null);
     _currentGame.BattleArena = new BattleArenaFactory().Create(5, 5);
     _robot = new RobotFactory().Create(5, 5, StringConstants.East);
     _moveInstructionFactory = new MoveInstructionFactory(new LinearMoveFactory());
 }
예제 #2
0
 public BackwardMove(ILinearMoveFactory linearMoveFactory, Robot robot)
     : base(robot)
 {
     _backwardMoveStrategies = new Dictionary<Heading, Action>()
     {
         { Heading.East, linearMoveFactory.MoveWest(_robot) },
         { Heading.North, linearMoveFactory.MoveSouth(_robot) },
         { Heading.South, linearMoveFactory.MoveNorth(_robot) },
         { Heading.West, linearMoveFactory.MoveEast(_robot) }
     };
 }
예제 #3
0
 public LeftRotationMove(Robot robot)
     : base(robot)
 {
     _rotationMappings = new Dictionary<Heading, Heading>()
     {
         { Heading.East, Heading.North },
         { Heading.North, Heading.West },
         { Heading.South, Heading.East },
         { Heading.West, Heading.South }
     };
 }
예제 #4
0
 public MoveInstruction Create(string moveInstruction, Robot robot)
 {
     Func<Robot, MoveInstruction> createMoveInstruction;
     if(_moveInstructionBuilders.TryGetValue(moveInstruction.ToUpper(), out createMoveInstruction))
     {
         return createMoveInstruction(robot);
     }
     else
     {
         throw new InvalidOperationException("Unknown move specified.");
     }
 }
예제 #5
0
 protected MoveInstruction CreateMove(string type, Robot robot)
 {
     return new MoveInstructionFactory(new LinearMoveFactory()).Create(type, robot);
 }
예제 #6
0
 protected void AssertRobotPosition(int expectedX, int expectedY, Heading expectedHeading, Robot actualRobot)
 {
     Assert.AreEqual(expectedX, actualRobot.XCoordinate);
     Assert.AreEqual(expectedY, actualRobot.YCoordinate);
     Assert.AreEqual(expectedHeading, actualRobot.Direction);
 }
예제 #7
0
 public Action MoveWest(Robot robot)
 {
     return () => robot.MoveTo(robot.XCoordinate - 1, robot.YCoordinate);
 }
예제 #8
0
 public Action MoveSouth(Robot robot)
 {
     return () => robot.MoveTo(robot.XCoordinate, robot.YCoordinate - 1);
 }
예제 #9
0
 protected MoveInstruction(Robot robot)
 {
     _robot = robot;
 }