bingo

package
v0.0.0-...-adac0c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlayerNameCommand int
	PlayerIDCommand
	PlayersListCommand
	GameConfigCommand
	PlayerBoardCommand
	GameStatusCommand
	GameMoveCommand
	GameScoreIndexCommand
)

Variables

This section is empty.

Functions

func ClearTerminal

func ClearTerminal()

func RenderBoard

func RenderBoard(board [][]uint8)

func RenderServerBoard

func RenderServerBoard(clients *map[*Client]bool)

Types

type Client

type Client struct {
	Id   uint8           `json:"id"`
	Name string          `json:"name"`
	Ip   net.IP          `json:"ip"`
	Conn *websocket.Conn `json:"-"`

	Send chan []byte `json:"-"`
	// contains filtered or unexported fields
}

func (*Client) HandleSocketPing

func (c *Client) HandleSocketPing() error

func (*Client) ReadMessages

func (c *Client) ReadMessages() ([][]byte, bool)

func (*Client) SetSocketReadConfig

func (c *Client) SetSocketReadConfig()

func (*Client) String

func (client *Client) String() string

type Game

type Game struct {
	IsLobbyMode bool
	BoardSize   uint8
	// contains filtered or unexported fields
}

func New

func New(serverIp net.IP) *Game

func (*Game) Run

func (g *Game) Run()

func (*Game) ServeHTTP

func (game *Game) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GameConfig

type GameConfig struct {
	Command     int   `json:"command"`
	IsLobbyMode bool  `json:"is_lobby_mode"`
	BoardSize   uint8 `json:"board_size"`
}

type GameMove

type GameMove struct {
	Command int     `json:"command"`
	Change  uint8   `json:"change"`
	Name    string  `json:"name"`
	Author  *Client `json:"-"`
}

type GameScoreIndex

type GameScoreIndex struct {
	Command int   `json:"command"`
	Score   uint8 `json:"score"`
}

type GameStatus

type GameStatus struct {
	Command  int   `json:"command"`
	PlayerId uint8 `json:"player_id"`
}

type PlayerID

type PlayerID struct {
	Command int   `json:"command"`
	ID      uint8 `json:"id"`
}

type PlayerName

type PlayerName struct {
	Command int    `json:"command"`
	Name    string `json:"name"`
}

type PlayersBoard

type PlayersBoard struct {
	Command int        `json:"command"`
	Board   *[][]uint8 `json:"board"`
}

type PlayersList

type PlayersList struct {
	Command int       `json:"command"`
	Players []*Client `json:"players"`
}

func (PlayersList) RenderLobby

func (p PlayersList) RenderLobby()

type RequestCommand

type RequestCommand struct {
	Command int `json:"command"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL