Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientMessage ¶
type ClientMessage struct {
Type string `json:"type"`
Marbles [][]int `json:"marbles,omitempty"` // [[q,r], ...]
Dir []int `json:"direction,omitempty"`
}
ClientMessage represents a message from the client
type PlayerColor ¶
type PlayerColor int
PlayerColor maps to game.Cell
const ( ColorBlack PlayerColor = PlayerColor(game.Black) ColorWhite PlayerColor = PlayerColor(game.White) )
type Room ¶
type Room struct {
Code string
Game *game.Game
Players [2]*Player // [0] = host (Black), [1] = joiner (White)
// contains filtered or unexported fields
}
Room represents an active game room
type RoomManager ¶
type RoomManager struct {
// contains filtered or unexported fields
}
RoomManager manages all active game rooms
func (*RoomManager) CreateRoom ¶
func (rm *RoomManager) CreateRoom() *Room
CreateRoom creates a new game room with a unique code
func (*RoomManager) GetRoom ¶
func (rm *RoomManager) GetRoom(code string) *Room
GetRoom returns the room with the given code, or nil if not found
func (*RoomManager) RemoveRoom ¶
func (rm *RoomManager) RemoveRoom(code string)
RemoveRoom removes a room from the manager
func (*RoomManager) RemoveRoomIfEmpty ¶
func (rm *RoomManager) RemoveRoomIfEmpty(code string)
RemoveRoomIfEmpty removes a room only if both player slots are nil.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the Abalone HTTP and WebSocket server
func NewServer ¶
func NewServer(webFS http.FileSystem) *Server
NewServer creates a new server with the given filesystem for static assets
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server on the given address
type ServerMessage ¶
type ServerMessage struct {
Type string `json:"type"`
Board map[string]int `json:"board,omitempty"`
Turn string `json:"turn,omitempty"`
Captured map[string]int `json:"captured,omitempty"`
Winner string `json:"winner,omitempty"`
Code string `json:"code,omitempty"`
Color string `json:"color,omitempty"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
}
ServerMessage represents a message from the server