diff --git a/ChineseChess.Core/ChessboardPosition.cs b/ChineseChess.Core/ChessboardPosition.cs index 616b848..1be8be5 100644 --- a/ChineseChess.Core/ChessboardPosition.cs +++ b/ChineseChess.Core/ChessboardPosition.cs @@ -2,7 +2,52 @@ { public struct ChessboardPosition { - public byte Col; - public byte Row; + public int Col; + public int Row; + + public ChessboardPosition(int col, int row) + { + Col=col; + Row=row; + } + + public override bool Equals(object obj) + { + return obj is ChessboardPosition pos + && pos.Col == this.Col + && pos.Row == this.Row; + } + + public override int GetHashCode() + { + return Col ^ Row; + } + + public override string ToString() + { + return $"({Row}, {Col})"; + } + + public static bool operator ==(ChessboardPosition left, ChessboardPosition right) + { + return left.Equals(right); + } + + public static bool operator !=(ChessboardPosition left, ChessboardPosition right) + { + return !(left==right); + } + + public static ChessboardPosition operator +(ChessboardPosition left, ChessboardPosition right) + { + return new ChessboardPosition(left.Col + right.Col, left.Row + right.Row); + } + + public static ChessboardPosition operator -(ChessboardPosition left, ChessboardPosition right) + { + return new ChessboardPosition(left.Col - right.Col, left.Row - right.Row); + } + + } } \ No newline at end of file