entity

package
v0.0.0-...-3e4fb85 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStartNoTeams        = errors.New("cannot start game without a single team")
	ErrStartIncompleteTeam = errors.New("cannot start game with incomplete team")
)

Functions

This section is empty.

Types

type Player

type Player struct {
	ID          string
	Name        string
	GravatarUrl string

	Room *Room
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(
	log zerolog.Logger,
	socket gamesvc.GameService_JoinServer,
	proto *gamesvc.Player,
	room *Room,
) *Player

func (*Player) Chan

func (p *Player) Chan() <-chan *gamesvc.Message

func (*Player) SendError

func (p *Player) SendError(err string) error

func (*Player) SendMsg

func (p *Player) SendMsg(msg *gamesvc.Message) error

func (*Player) Start

func (p *Player) Start(ctx context.Context) error

func (*Player) ToProto

func (p *Player) ToProto() *gamesvc.Player

type Room

type Room struct {
	Id        string
	Name      string
	LeaderId  string
	IsPublic  bool
	Langugage string
	Password  *string
	Lobby     []*Player
	Teams     []*Team
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(
	log zerolog.Logger,
	roomID, leaderID string,
	req *gamesvc.CreateRoomRequest,
) *Room

func (*Room) AggregationChan

func (r *Room) AggregationChan() chan tuple.T2[*gamesvc.Message, *Player]

func (*Room) AnnounceChange

func (r *Room) AnnounceChange() error

func (*Room) Cancel

func (r *Room) Cancel()

func (*Room) Ctx

func (r *Room) Ctx() context.Context

func (*Room) Do

func (r *Room) Do(fn func(r *Room))

Do queues for execution. It's async method.

func (*Room) FindTeamWithPlayer

func (r *Room) FindTeamWithPlayer(playerID string) (*Team, bool)

func (*Room) GetAllPlayers

func (r *Room) GetAllPlayers() []*Player

func (*Room) GetProto

func (r *Room) GetProto() *gamesvc.Room

func (*Room) HasPlayer

func (r *Room) HasPlayer(playerID string) bool

func (*Room) IsEmpty

func (r *Room) IsEmpty() bool

func (*Room) RemovePlayer

func (r *Room) RemovePlayer(playerID string) bool

func (*Room) Start

func (r *Room) Start()

type Team

type Team struct {
	ID   string
	Name string

	PlayerA *Player
	PlayerB *Player
}

func (*Team) OponentOf

func (t *Team) OponentOf(playerID string) (*Player, bool)

func (*Team) ToProto

func (t *Team) ToProto() *gamesvc.Team

Jump to

Keyboard shortcuts

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