player

package
v0.0.0-...-61e3c9a Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPerson      = errors.New("model: player has to be a valid person")
	ErrPlayerUpdateFailed = errors.New("model: player update failed")
)
View Source
var (
	ErrPlayerNotFound      = errors.New("repository: the player was not found")
	ErrPlayerAlreadyExists = errors.New("repository: player already exists")
	ErrPlayerHasNoUpdates  = errors.New("repository: failed to update player")
)

Functions

This section is empty.

Types

type Player

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

Player is a aggregate that combines all entities needed to represent a player.

func NewPlayer

func NewPlayer(p core.Person) (*Player, error)

NewPlayer is a factory to create a new Player aggregate.

func NewPlayerFromEvents

func NewPlayerFromEvents(events []core.Event) *Player

NewFromEvents is a helper method that creates a new player from a series of events.

func (*Player) Activate

func (p *Player) Activate() error

Activate activates player.

func (*Player) Apply

func (p *Player) Apply(e core.Event, new bool)

Apply applies player events to the player aggregate.

func (*Player) AssignTeam

func (p *Player) AssignTeam(t core.Group) error

AssignTeam assigns team to player.

func (*Player) Deactivate

func (p *Player) Deactivate() error

Deactivate deactivates player.

func (Player) Events

func (p Player) Events() []core.Event

Events returns the uncommitted events from the player aggregate.

func (*Player) GetEntity

func (p *Player) GetEntity() core.Person

GetEntity returns the player root core.

func (*Player) GetID

func (p *Player) GetID() uuid.UUID

GetID returns the player root ID.

func (*Player) GetName

func (p *Player) GetName() string

GetName returns the name of the player.

func (*Player) GetTeams

func (p *Player) GetTeams() (teams []core.Group)

GetTeams returns a player's teams.

func (*Player) IsActivated

func (p *Player) IsActivated() bool

IsActivated returns whether the player is activated.

func (*Player) UnassignTeam

func (p *Player) UnassignTeam(t core.Group) error

UnassignTeam unassigns team from player.

func (Player) Version

func (p Player) Version() int

Version returns the last version of the aggregate before changes.

type PlayerActivated

type PlayerActivated struct {
	ID uuid.UUID `json:"id"`
}

PlayerActivated event.

func (PlayerActivated) EventName

func (e PlayerActivated) EventName() string

type PlayerCreated

type PlayerCreated struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

PlayerCreated event.

func (PlayerCreated) EventName

func (e PlayerCreated) EventName() string

type PlayerDeactivated

type PlayerDeactivated struct {
	ID uuid.UUID `json:"id"`
}

PlayerDeactivated event.

func (PlayerDeactivated) EventName

func (e PlayerDeactivated) EventName() string

type PlayerRepository

type PlayerRepository interface {
	Get(core.Person) (*Player, error)
	GetTeams(core.Person) ([]core.Group, error)
	Add(*Player) error
	Update(*Player) error
}

PlayerRepository defines the interface for the player repository.

type TeamAssignedToPlayer

type TeamAssignedToPlayer struct {
	ID       uuid.UUID `json:"id"`
	TeamId   uuid.UUID `json:"team_id"`
	TeamName string    `json:"team_name"`
}

TeamAssignedToPlayer event.

func (TeamAssignedToPlayer) EventName

func (e TeamAssignedToPlayer) EventName() string

type TeamUnassignedFromPlayer

type TeamUnassignedFromPlayer struct {
	ID       uuid.UUID `json:"id"`
	TeamId   uuid.UUID `json:"team_id"`
	TeamName string    `json:"team_name"`
}

TeamUnassignedFromPlayer event.

func (TeamUnassignedFromPlayer) EventName

func (e TeamUnassignedFromPlayer) EventName() string

Jump to

Keyboard shortcuts

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