public bool Equals(ChessCoordinate c) { if (object.Equals(c, null)) { return(false); } return(this.x == c.x && this.y == c.y); }
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); }
/// <summary> /// Constructor by reference /// </summary> /// <param name="other"></param> public ChessCoordinate(ChessCoordinate other) { this.x = other.x; this.y = other.y; }
/// <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); }
public ChessPosition(ChessPieceType type, ChessCoordinate coord, bool hasMoved = false) { this.type = type; this.coord = coord; this.hasMoved = hasMoved; }