Documentation
¶
Index ¶
- Constants
- func ActionHandler(player *Player, action string, payload json.RawMessage) error
- func MapIntToRank(rankInt int) string
- func ServerFailMsg[V any](action string, payload V) ([]byte, error)
- func ServerSuccessMsg[V any](action string, payload V) ([]byte, error)
- type Card
- type ClientMessage
- type CreateRoomPayload
- type CreateRoomResponse
- type Game
- type GameStack
- type GenericErrorResponse
- type Hub
- type HubStore
- type JoinRoomResponse
- type LeaveRoomResponse
- type MakeMovePayload
- type Player
- type PlayerWithMove
- type PlayerWithScore
- type RegisterPlayerResponse
- type ResultResponse
- type Room
- type RoomPayload
- type ServerMessage
- type SetNamePayload
- type StartGameResponse
- type Store
- func (s *Store) CreateRoom(room *Room)
- func (s *Store) DeleteRoom(id uuid.UUID) error
- func (s *Store) GetPlayerById(id uuid.UUID) (*Player, error)
- func (s *Store) GetRoomById(id uuid.UUID) (*Room, error)
- func (s *Store) JoinRoom(id uuid.UUID, playerId uuid.UUID) error
- func (s *Store) LeaveRoom(id uuid.UUID, playerId uuid.UUID) error
- func (s *Store) RegisterPlayer(player *Player)
- func (s *Store) SetPlayerName(id uuid.UUID, name string) error
- func (s *Store) UnregisterPlayer(id uuid.UUID) error
Constants ¶
View Source
const ( CREATE_ROOM = "CREATE_ROOM" JOIN_ROOM = "JOIN_ROOM" LEAVE_ROOM = "LEAVE_ROOM" SET_NAME = "SET_NAME" START_GAME = "START_GAME" MOVE = "MOVE" END_GAME = "END_GAME" )
View Source
const ONGOING = "ONGOING"
View Source
const (
REGISTER = "REGISTER"
)
Variables ¶
This section is empty.
Functions ¶
func ActionHandler ¶
func ActionHandler(player *Player, action string, payload json.RawMessage) error
func MapIntToRank ¶
Types ¶
type Card ¶
func MapIntToCard ¶
S: 0 -> 12 D: 13 -> 25 C: 26 -> 38 H: 39 -> 51
type ClientMessage ¶
type ClientMessage struct {
Action string `json:"action"`
Payload json.RawMessage `json:"payload"`
}
type CreateRoomPayload ¶
type CreateRoomResponse ¶
type GameStack ¶
type GameStack struct {
// contains filtered or unexported fields
}
func NewGameStack ¶
func NewGameStack() *GameStack
func (*GameStack) GetAllGames ¶
type GenericErrorResponse ¶
type GenericErrorResponse struct {
Error string `json:"error"`
}
type Hub ¶
type Hub struct {
Store HubStore
Register chan *websocket.Conn
Unregister chan uuid.UUID
SetName chan SetNamePayload
CreateRoom chan CreateRoomPayload
JoinRoom chan RoomPayload
LeaveRoom chan RoomPayload
StartGame chan RoomPayload
MakeMove chan MakeMovePayload
}
type HubStore ¶
type HubStore interface {
RegisterPlayer(player *Player)
GetPlayerById(id uuid.UUID) (*Player, error)
UnregisterPlayer(id uuid.UUID) error
SetPlayerName(id uuid.UUID, name string) error
CreateRoom(room *Room)
GetRoomById(id uuid.UUID) (*Room, error)
DeleteRoom(id uuid.UUID) error
JoinRoom(id uuid.UUID, playerId uuid.UUID) error
LeaveRoom(id uuid.UUID, playerId uuid.UUID) error
}
type JoinRoomResponse ¶
type LeaveRoomResponse ¶
type MakeMovePayload ¶
type PlayerWithMove ¶
type PlayerWithScore ¶
type RegisterPlayerResponse ¶
type ResultResponse ¶
type RoomPayload ¶
type ServerMessage ¶
type SetNamePayload ¶
type StartGameResponse ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) CreateRoom ¶
func (*Store) RegisterPlayer ¶
Click to show internal directories.
Click to hide internal directories.