mchess-server/types/shortname.go

38 lines
1023 B
Go
Raw Permalink 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"
2023-10-12 19:03:12 +00:00
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 {
2023-10-12 19:03:12 +00:00
commonShortName := strings.ToLower(p.String())
return PieceShortName(commonShortName)
}