memdb

package
v0.0.0-...-f64dbd0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGameNotFound   = errors.New("game not found")
	ErrGameNotStarted = errors.New("game not started yet")
	ErrPlayerNotFound = errors.New("player not found")
	ErrNameTaken      = errors.New("player name already taken")
)

Functions

This section is empty.

Types

type DB

type DB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(r *rand.Rand) *DB

func (*DB) AddPlayerToGame

func (d *DB) AddPlayerToGame(gID banana.GameID, pID banana.PlayerID) error

Adds a player to a game.

func (*DB) Board

func (d *DB) Board(gID banana.GameID, pID banana.PlayerID) (*banana.Board, error)

func (*DB) Bunch

func (d *DB) Bunch(id banana.GameID) (*banana.Bunch, error)

Loads the bunch for the game with the given ID.

func (*DB) EndGame

func (d *DB) EndGame(id banana.GameID) error

Ends a given game, stops players from adding more to their boards.

func (*DB) Game

func (d *DB) Game(id banana.GameID) (*banana.Game, error)

Loads a game with the given ID.

func (*DB) Games

func (d *DB) Games() ([]*banana.Game, error)

func (*DB) NewGame

func (d *DB) NewGame(name string, creator banana.PlayerID, config *banana.Config) (banana.GameID, error)

Creates a new game with the given name.

func (*DB) Player

func (d *DB) Player(pID banana.PlayerID) (*banana.Player, error)

Loads a player with the given ID.

func (*DB) Players

func (d *DB) Players(id banana.GameID) ([]*banana.Player, error)

Get all the players for a given game.

func (*DB) RegisterPlayer

func (d *DB) RegisterPlayer(name string) (banana.PlayerID, error)

func (*DB) StartGame

func (d *DB) StartGame(gID banana.GameID, players map[banana.PlayerID]*banana.Tiles, bunch *banana.Bunch) error

Starts a game, and sets everyone's initial tile sets.

func (*DB) Tiles

func (d *DB) Tiles(gID banana.GameID, pID banana.PlayerID) (*banana.Tiles, error)

func (*DB) UpdateBoard

func (d *DB) UpdateBoard(gID banana.GameID, pID banana.PlayerID, board *banana.Board) error

Updates a player's board.

func (*DB) UpdateBunch

func (d *DB) UpdateBunch(gID banana.GameID, bunch *banana.Bunch) error

Updates the bunch for the game.

func (*DB) UpdateTiles

func (d *DB) UpdateTiles(gID banana.GameID, pID banana.PlayerID, tiles *banana.Tiles) error

Updates a player's tiles.

Jump to

Keyboard shortcuts

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