game

package
v0.0.0-...-80078d4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	ID string

	Players            []*player.Player
	CurrentPlayerIndex int
	// contains filtered or unexported fields
}

Game is a struct that represents the state and connections of a multiplayer ban qi game that the server is hosting.

func NewGame

func NewGame(id string, removeGameChan chan *Game, db *sql.DB) *Game

NewGame returns a newly initialized game struct

func (*Game) CurrentPlayer

func (g *Game) CurrentPlayer() *player.Player

func (*Game) IsTurnOf

func (g *Game) IsTurnOf(p *player.Player) bool

func (*Game) Join

func (g *Game) Join(w http.ResponseWriter, r *http.Request, name string, user *httpauth.UserData) bool

Join causes a connection to join a game as a websocket and player

func (*Game) JoinAi

func (g *Game) JoinAi(ai settings.AiConfig) bool

JoinAi will cause the specified AI to join the game

func (*Game) JoinKibitz

func (g *Game) JoinKibitz(conn *websocket.Conn, name string, user *httpauth.UserData) bool

JoinKibitz will create a new 'player' and add to the group of kibitzers in a game

func (*Game) JoinWs

func (g *Game) JoinWs(conn *websocket.Conn, name string, user *httpauth.UserData, bot bool) bool

JoinWs joins a game with an existing websocket

func (*Game) NextPlayer

func (g *Game) NextPlayer() *player.Player

func (*Game) SwitchPlayers

func (g *Game) SwitchPlayers()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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