player

package
v0.0.0-...-2275561 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGameToPlayer

func AddGameToPlayer(db memory.Memory, gameID int64, playerID int64) error

add new game to a player by id

func AddGameToPlayers

func AddGameToPlayers(db memory.Memory, gameID int64, playersID ...int64) (err error)

Add new game

func AssertPlayer

func AssertPlayer(t testing.TB, got, want Player)

func Cmd

func Cmd(db memory.Memory, cmd, text string, p int64, ChatID int64) (r pb.Response, err error)

runs a command by player

func CurrentGame

func CurrentGame(id int64, db memory.Memory) (gameID int64, err error)

returns current game

func Do

func Do(id int64, db memory.Memory, move string, chatID int64) (pb.Response, error)

Move player

func Move

func Move(gameID, playerID int64, text string) (err error)

func NewMessage

func NewMessage(p int64, chatID int64, cmd, text string, db memory.Memory) (r pb.Response, err error)

Types

type NoConnectionError

type NoConnectionError struct{}

func (NoConnectionError) Error

func (n NoConnectionError) Error() string

type NoGamesError

type NoGamesError struct{}

func (NoGamesError) Error

func (n NoGamesError) Error() string

type NoSuchCommandError

type NoSuchCommandError struct {
	// contains filtered or unexported fields
}

func (NoSuchCommandError) Error

func (n NoSuchCommandError) Error() string

type NoSuchPlayerError

type NoSuchPlayerError struct {
	ID int64
}

func (NoSuchPlayerError) Error

func (n NoSuchPlayerError) Error() string

type NoUsernameInDatabaseError

type NoUsernameInDatabaseError struct{}

func (NoUsernameInDatabaseError) Error

type Player

type Player struct {
	ID       int64
	GamesID  []int64 `json:"gamesID"`
	Username string  `json:"username"`
	Rating   int64
}

func MakePlayer

func MakePlayer(db memory.Memory, playerID int64, username string) (player Player)

get or create new player

func NewPlayer

func NewPlayer(ID int64, Username string) Player

func (*Player) AddNewGame

func (p *Player) AddNewGame(gameID int64)

func (*Player) CurrentGame

func (p *Player) CurrentGame() (gameID int64, err error)

Jump to

Keyboard shortcuts

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