Marco
ff2ec599fe
In order to simplify special moves like en passant or castling for the client, we want to deliver the board state after every move (and not only start square and end square). With PGN we can encode a chess position into a string. This commit implies changes to logic of the pieces' shortnames. This will break the client/server connection (at least for promotions).
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package types
|
|
|
|
import "strings"
|
|
|
|
type PieceShortName string
|
|
|
|
const (
|
|
PawnShortName PieceShortName = "p"
|
|
RookShortName PieceShortName = "r"
|
|
KnightShortName PieceShortName = "n"
|
|
BishopShortName PieceShortName = "b"
|
|
QueenShortName PieceShortName = "q"
|
|
KingShortName PieceShortName = "k"
|
|
|
|
BlackPawnShortName PieceShortName = "p"
|
|
BlackRookShortName PieceShortName = "r"
|
|
BlackKnightShortName PieceShortName = "n"
|
|
BlackBishopShortName PieceShortName = "b"
|
|
BlackQueenShortName PieceShortName = "q"
|
|
BlackKingShortName PieceShortName = "k"
|
|
|
|
WhitePawnShortName PieceShortName = "P"
|
|
WhiteRookShortName PieceShortName = "R"
|
|
WhiteKnightShortName PieceShortName = "N"
|
|
WhiteBishopShortName PieceShortName = "B"
|
|
WhiteQueenShortName PieceShortName = "Q"
|
|
WhiteKingShortName PieceShortName = "K"
|
|
)
|
|
|
|
func (p PieceShortName) String() string {
|
|
return string(p)
|
|
}
|
|
|
|
func (p PieceShortName) ToCommon() PieceShortName {
|
|
commonShortName := strings.ToLower(p.String())
|
|
return PieceShortName(commonShortName)
|
|
}
|