예제 #1
0
 /// <summary>
 ///     Get Moves In Direction
 /// </summary>
 /// <param name="board"></param>
 /// <param name="coordinate"></param>
 /// <param name="player"></param>
 /// <returns></returns>
 public IList<Coordinate> GetMovesInDirection(Board board, Coordinate coordinate, Player player)
 {
     //Finds all optional move for player
     IList<Coordinate> coordinateList = OptionalMoves(board, coordinate, player);
     if (coordinateList.Count != 0)
     {
         //checks if player is the owner of the piece
         if (board.IsOwner(player, coordinate))
         {
             foreach (Coordinate item in coordinateList.Reverse())
             {
                 //Removing coordinates which are not in the piece direction white - forward and black backword (according to board orientation)
                 if (board.IsBlack(coordinate) && (board.IsSoldier(coordinate)))
                 {
                     if (item.X > coordinate.X)
                     {
                         coordinateList.Remove(item);
                     }
                 }
                 if (board.IsWhite(coordinate) && (board.IsSoldier(coordinate)))
                 {
                     if (item.X < coordinate.X)
                     {
                         coordinateList.Remove(item);
                     }
                 }
             }
         }
     }
     return coordinateList;
 }