2023-06-12 20:32:31 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
type Coordinate struct {
|
|
|
|
Col int `json:"col"`
|
|
|
|
Row int `json:"row"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Move struct {
|
|
|
|
StartSquare Coordinate `json:"startSquare"`
|
|
|
|
EndSquare Coordinate `json:"endSquare"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PieceClass string
|
|
|
|
|
|
|
|
const (
|
|
|
|
Pawn PieceClass = "pawn"
|
|
|
|
Rook PieceClass = "rook"
|
|
|
|
Knight PieceClass = "knight"
|
|
|
|
Bishop PieceClass = "bishop"
|
|
|
|
Queen PieceClass = "queen"
|
|
|
|
King PieceClass = "king"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ChessColor string
|
|
|
|
|
|
|
|
const (
|
|
|
|
White ChessColor = "white"
|
|
|
|
Black ChessColor = "black"
|
|
|
|
)
|
|
|
|
|
2023-06-14 17:46:46 +00:00
|
|
|
func (c ChessColor) Opposite() ChessColor {
|
|
|
|
if c == White {
|
|
|
|
return Black
|
|
|
|
} else {
|
|
|
|
return White
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-12 20:32:31 +00:00
|
|
|
type Piece struct {
|
|
|
|
Class PieceClass
|
|
|
|
Color ChessColor
|
|
|
|
HasMoved bool //we need this for pawns (first move is special) and rooks+king (for castling)
|
|
|
|
}
|