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()); }
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) } }; }
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 } }; }
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."); } }
protected MoveInstruction CreateMove(string type, Robot robot) { return new MoveInstructionFactory(new LinearMoveFactory()).Create(type, robot); }
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); }
public Action MoveWest(Robot robot) { return () => robot.MoveTo(robot.XCoordinate - 1, robot.YCoordinate); }
public Action MoveSouth(Robot robot) { return () => robot.MoveTo(robot.XCoordinate, robot.YCoordinate - 1); }
protected MoveInstruction(Robot robot) { _robot = robot; }