2023-06-20 21:53:54 +00:00
|
|
|
package chess
|
|
|
|
|
|
|
|
import (
|
2023-06-25 14:11:29 +00:00
|
|
|
"mchess_server/types"
|
2023-06-20 21:53:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Piece interface {
|
2023-06-25 14:11:29 +00:00
|
|
|
GetAllMovesButBlocked(board Board, fromSquare types.Coordinate) []types.Coordinate
|
2023-06-20 21:53:54 +00:00
|
|
|
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
|
2023-06-20 21:53:54 +00:00
|
|
|
}
|