mchess-server/api/move.go

34 lines
557 B
Go

package api
import "local/m/mchess_server/types"
type WebsocketMessage struct {
Type MessageType `json:"messageType"`
Move *types.Move `json:"move,omitempty"`
Color *Color `json:"color,omitempty"`
}
type MessageType string
const (
MoveMessage MessageType = "move"
ColorDetermined MessageType = "colorDetermined"
)
type Color string
const (
Black Color = "black"
White Color = "white"
)
func (m WebsocketMessage) IsValidMove() bool {
if m.Type != MoveMessage {
return false
}
if m.Move == nil {
return false
}
return true
}