Exemple #1
0
        /// <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;
        }
Exemple #2
0
 public void InBoundsTest_Null()
 {
     Board target = new Board();
     Point point = null; // NullReferenceException is expected
     bool actual;
     actual = target.InBounds(point);
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 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);
 }
Exemple #5
0
        /// <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;
        }