Documentation
¶
Index ¶
- Constants
- type IRepository
- type IService
- type Model
- type Repository
- type Service
- func (s Service) AddPlayer(p Model) error
- func (s Service) AddPoint(ID string, points int) (Model, error)
- func (s Service) FindByID(ID string) (Model, error)
- func (s Service) GetTeam(team string) []Model
- func (s Service) IsPlayerExist(p *Model) bool
- func (s Service) SetPlayerOnlineStatus(ID string, online bool) (Model, error)
Constants ¶
View Source
const TeamTypeAttacker = "attacker"
Describes attacker team type
View Source
const TeamTypeDefender = "defender"
Describes defender team type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IRepository ¶
type IRepository interface { // Fetches the available players in the system GetPlayers() []Model // Adds a new player to the system AddPlayer(Model) error // Update by ID UpdateByID(ID string, update Model) (Model, error) // Finds a user by ID FindByID(ID string) (Model, error) // Add given amounts of points to a player AddPoint(ID string, points int) (Model, error) }
Describes a repository for the engine
type IService ¶
type IService interface { // Adds a new player AddPlayer(Model) error // Sets a player's online status SetPlayerOnlineStatus(ID string, online bool) (Model, error) // Finds a player by ID FindByID(ID string) (Model, error) // Checks if a given player is already registered or not IsPlayerExist(*Model) bool // Add given amounts of points to a player AddPoint(ID string, points int) (Model, error) // Fetch a given team completely // use Team enums for the string GetTeam(team string) []Model }
Describes a player service interface
func NewService ¶
func NewService(repository IRepository) IService
type Model ¶
type Model struct { // ID of the player ID string // Name of the player Name string // Team of the player. Either "attacker" or "defender" Team string // Current score of the individual player Score int // Online indicator Online bool }
Describes a player in the system who is a user already registered to a given team and (possibly) actively participating in the game
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Engine repository implementation
func (*Repository) AddPlayer ¶
func (r *Repository) AddPlayer(user Model) error
func (*Repository) GetPlayers ¶
func (r *Repository) GetPlayers() []Model
func (*Repository) UpdateByID ¶
func (r *Repository) UpdateByID(ID string, update Model) (Model, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (Service) IsPlayerExist ¶
Click to show internal directories.
Click to hide internal directories.