/// <summary> /// Updates the ValidMoves property of this piece /// </summary> /// <param name="board">Game board</param> public override void UpdateValidMoveList(Board board) { List<Point> possibleMoves = GetMoveList(board); foreach (Point position in possibleMoves) { if (!board.InBounds(position)) possibleMoves.Remove(position); } this.ValidMoves = possibleMoves; }
public void InBoundsTest_Null() { Board target = new Board(); Point point = null; // NullReferenceException is expected bool actual; actual = target.InBounds(point); }
public void InBoundsTest_81() { Board target = new Board(); Point point = new Point(8, 1); // The x coordinant is out of range bool expected = false; //False is expected bool actual; actual = target.InBounds(point); Assert.AreEqual(expected, actual); }
public void InBoundsTest_11() { Board target = new Board(); Point point = new Point(1, 1); // The point (1,1) is in range bool expected = true; //True is expected bool actual; actual = target.InBounds(point); Assert.AreEqual(expected, actual); }
/// <summary> /// Returns a list of possible moves based on the piece direction vector and movement range /// </summary> /// <param name="board">Game board</param> /// <returns>List of Points</returns> protected List<Point> GetMoveList(Board board) { List<Point> moves = new List<Point>(); foreach (Point direction in directionVector) { for (int i = 1; i <= moveReach; i++) { Point point = new Point(this.position.X + direction.X * i, this.position.Y + direction.Y * i); if (board.InBounds(point)) { if (!ForbiddenCollision(point, board)) moves.Add(point); if (!board.GetTile(point).IsEmpty()) break; } } } return moves; }