mchess-server/types/shortname.go

38 lines
1.0 KiB
Go
Raw Normal View History

2023-06-25 14:11:29 +00:00
package types
import "strings"
2023-07-03 17:32:39 +00:00
type PieceShortName string
2023-06-25 14:11:29 +00:00
const (
2023-07-03 17:32:39 +00:00
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"
2023-06-25 14:11:29 +00:00
)
2023-07-03 17:32:39 +00:00
func (p PieceShortName) String() string {
return string(p)
}
func (p PieceShortName) ToCommon() PieceShortName {
commonShortName := strings.ToLower(p.String())
return PieceShortName(commonShortName)
}