Beispiel #1
0
        public bool Equals(ChessCoordinate c)
        {
            if (object.Equals(c, null))
            {
                return(false);
            }

            return(this.x == c.x && this.y == c.y);
        }
Beispiel #2
0
 public static bool IsWithinRange(this ChessCoordinate chessCoord, int boardSize = ChessSettings.boardSize)
 {
     if (chessCoord.x < 0)
     {
         return(false);
     }
     if (chessCoord.x >= boardSize)
     {
         return(false);
     }
     if (chessCoord.y < 0)
     {
         return(false);
     }
     if (chessCoord.y >= boardSize)
     {
         return(false);
     }
     return(true);
 }
Beispiel #3
0
 /// <summary>
 /// Constructor by reference
 /// </summary>
 /// <param name="other"></param>
 public ChessCoordinate(ChessCoordinate other)
 {
     this.x = other.x;
     this.y = other.y;
 }
Beispiel #4
0
 /// <summary>
 /// Convert chess coordinate into array position
 /// </summary>
 /// <param name="chessCoord"></param>
 /// <param name="boardSize">Specify the chess board size</param>
 /// <returns></returns>
 public static int ToArrayCoord(this ChessCoordinate chessCoord, int boardSize = 8)
 {
     return(chessCoord.y * boardSize + chessCoord.x);
 }
Beispiel #5
0
 public ChessPosition(ChessPieceType type, ChessCoordinate coord, bool hasMoved = false)
 {
     this.type     = type;
     this.coord    = coord;
     this.hasMoved = hasMoved;
 }