mchess-server/chess/piece_interface.go

31 lines
475 B
Go
Raw Normal View History

package chess
import (
2023-06-25 14:11:29 +00:00
"mchess_server/types"
)
type Piece interface {
2023-06-25 14:11:29 +00:00
GetAllMovesButBlocked(board Board, fromSquare types.Coordinate) []types.Coordinate
GetColor() types.ChessColor
2023-06-25 14:11:29 +00:00
}
func GetPieceForShortName(name types.PieceShortName) Piece {
var piece Piece
switch name {
case 'p':
piece = Pawn{}
case 'q':
piece = Queen{}
case 'k':
piece = King{}
case 'b':
piece = Bishop{}
case 'r':
piece = Rook{}
case 'n':
piece = Knight{}
}
return piece
}