Documentation ¶
Index ¶
- Variables
- type Config
- type Database
- func (d *Database) AddPerson(p *models.Person) error
- func (d *Database) AddPlayer(t *models.Tournament, ps *models.PlayerSummary) error
- func (d *Database) AutoplayMatch(m *models.Match) error
- func (d *Database) ClearTestTournaments() error
- func (d *Database) Close() error
- func (d *Database) CurrentMatch(t *models.Tournament) (*models.Match, error)
- func (d *Database) DisablePerson(id uint) error
- func (d *Database) GetAllRunnerups(t *models.Tournament) ([]*models.PlayerSummary, error)
- func (d *Database) GetCurrentTournament() (*models.Tournament, error)
- func (d *Database) GetLeaderboard() ([]*models.LeaderboardPlayer, error)
- func (d *Database) GetLeaderboardPlayer(id int) (*models.LeaderboardPlayer, error)
- func (d *Database) GetLeague(id uint) (*models.League, error)
- func (d *Database) GetLeagues() ([]*models.League, error)
- func (d *Database) GetMatch(id uint) (*models.Match, error)
- func (d *Database) GetMatches(t *models.Tournament, kind string) ([]*models.Match, error)
- func (d *Database) GetOrCreatePerson(pa *models.PersonAuth) (*models.Person, error, bool)
- func (d *Database) GetOverview(t *models.Tournament) ([]*models.Summary, error)
- func (d *Database) GetPeople(all bool) ([]*models.Person, error)
- func (d *Database) GetPerson(id uint) (*models.Person, error)
- func (d *Database) GetPersonFromFacebook(oauth string) (*models.Person, error)
- func (d *Database) GetPlayerState(m *models.Match, idx int) (*models.PlayerState, error)
- func (d *Database) GetPlayerStates(m *models.Match) ([]*models.PlayerState, error)
- func (d *Database) GetPlayerSummaries(t *models.Tournament) ([]*models.PlayerSummary, error)
- func (d *Database) GetPlayerSummary(t *models.Tournament, pid uint) (*models.PlayerSummary, error)
- func (d *Database) GetPlayoffRunnerups(t *models.Tournament) ([]*models.PlayerSummary, error)
- func (d *Database) GetQueuedPlayers(t *models.Tournament) ([]*models.Person, error)
- func (d *Database) GetScores(t *models.Tournament) ([]*models.Score, error)
- func (d *Database) GetTournament(id uint) (*models.Tournament, error)
- func (d *Database) GetTournamentLeaderboard(tm *models.Tournament) ([]*models.TournamentLeaderboardPlayer, error)
- func (d *Database) GetTournaments() ([]*models.Tournament, error)
- func (d *Database) IsInTournament(t *models.Tournament, p *models.Person) (bool, error)
- func (d *Database) NewTournament(t *models.Tournament) error
- func (d *Database) NextMatch(t *models.Tournament) (*models.Match, error)
- func (d *Database) QueueMessage(msg *messages.IncomingGameMessage) error
- func (d *Database) RemovePlayer(ps *models.PlayerSummary) error
- func (d *Database) ReplayRound() error
- func (d *Database) ResetMatch(m *models.Match) error
- func (d *Database) SaveMatch(m *models.Match) error
- func (d *Database) SavePerson(p *models.Person) error
- func (d *Database) SaveTournament(t *models.Tournament) error
- func (d *Database) StoreMessage(m *models.Match, msg *messages.IncomingGameMessage) error
- func (d *Database) TogglePlayer(t *models.Tournament, id uint) error
- func (d *Database) UsurpTournament(t *models.Tournament, x int) error
- type DatabaseConfig
- type DiscordConfig
- type Listener
- type LogHook
- type Publisher
- type RabbitConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
var ErrNoTourmamentRunning = errors.New("no tournament is running")
var ErrPublisherDisabled = errors.New("publisher is disabled")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Production bool `json:"production"` PerishKey string `json:"perish_key"` Server *ServerConfig `yaml:"server" json:"server"` Database *DatabaseConfig `yaml:"database" json:"database"` Discord *DiscordConfig `yaml:"discord" json:"discord"` Rabbit *RabbitConfig `yaml:"rabbit" json:"rabbit"` Log *zap.Logger `json:"-"` // contains filtered or unexported fields }
func ParseConfig ¶
func ParseConfig() *Config
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
var DB *Database
func NewDatabase ¶
func NewDatabase(c *Config, wb *messages.WebsocketBroker) (*Database, error)
NewDatabase sets up the database reader and writer
func (*Database) AddPlayer ¶
func (d *Database) AddPlayer(t *models.Tournament, ps *models.PlayerSummary) error
AddPlayer adds a player object to the tournament
func (*Database) AutoplayMatch ¶
AutoplayMatch replays an old match on top of an unplayed one
func (*Database) ClearTestTournaments ¶
ClearTestTournaments deletes any tournament that doesn't begin with "DrunkenFall"
func (*Database) CurrentMatch ¶
CurrentMatch returns the currently running match
func (*Database) DisablePerson ¶
DisablePerson disables or re-enables a person
func (*Database) GetAllRunnerups ¶
func (d *Database) GetAllRunnerups(t *models.Tournament) ([]*models.PlayerSummary, error)
GetAllRunnerups gets all the runnerups that aren't already booked into matches
func (*Database) GetCurrentTournament ¶
func (d *Database) GetCurrentTournament() (*models.Tournament, error)
GetCurrentTournament gets the currently running tournament
func (*Database) GetLeaderboard ¶
func (d *Database) GetLeaderboard() ([]*models.LeaderboardPlayer, error)
GetLeaderboard gets the leaderboard
func (*Database) GetLeaderboardPlayer ¶
func (d *Database) GetLeaderboardPlayer(id int) (*models.LeaderboardPlayer, error)
GetLeaderboardPlayer gets a single person from the leaderboard
func (*Database) GetLeagues ¶
GetLeagues gets all the leagues
func (*Database) GetMatches ¶
GetMatches gets a slice of matches based on a kind
func (*Database) GetOrCreatePerson ¶
GetOrCreatePerson gets or creates a new person from a Auth user body
func (*Database) GetOverview ¶
GetOverview gets the overview
func (*Database) GetPersonFromFacebook ¶
GetPersonFromFacebook gets a Person{} from a Facebook auth request
func (*Database) GetPlayerState ¶
GetPlayerState gets the player state for a player
func (*Database) GetPlayerStates ¶
GetPlayerStates gets the players for all players in a match
func (*Database) GetPlayerSummaries ¶
func (d *Database) GetPlayerSummaries(t *models.Tournament) ([]*models.PlayerSummary, error)
GetPlayerSummaries gets all player summaries for a tourmanent
func (*Database) GetPlayerSummary ¶
func (d *Database) GetPlayerSummary(t *models.Tournament, pid uint) (*models.PlayerSummary, error)
GetPlayerSummary gets a single player summary for a tourmanent
func (*Database) GetPlayoffRunnerups ¶
func (d *Database) GetPlayoffRunnerups(t *models.Tournament) ([]*models.PlayerSummary, error)
GetPlayoffRunnerups gets the runnerups in the playoffs
func (*Database) GetQueuedPlayers ¶
GetQueuedPlayers returns a list of all the players that are queued for the tournament
func (*Database) GetTournament ¶
func (d *Database) GetTournament(id uint) (*models.Tournament, error)
GetTournament gets a tournament by id, or returns the cached one if there is one
func (*Database) GetTournamentLeaderboard ¶
func (d *Database) GetTournamentLeaderboard(tm *models.Tournament) ([]*models.TournamentLeaderboardPlayer, error)
GetTournamentLeaderboard gets the leaderboard
func (*Database) GetTournaments ¶
func (d *Database) GetTournaments() ([]*models.Tournament, error)
func (*Database) IsInTournament ¶
IsInTournament returns if the player is in the tournament or not
func (*Database) NewTournament ¶
func (d *Database) NewTournament(t *models.Tournament) error
SaveTournament stores the current state of the tournaments into the db
func (*Database) QueueMessage ¶
func (d *Database) QueueMessage(msg *messages.IncomingGameMessage) error
QueueMessage
func (*Database) RemovePlayer ¶
func (d *Database) RemovePlayer(ps *models.PlayerSummary) error
RemovePlayer removes a player from a tourmament
func (*Database) ReplayRound ¶
ReplayRound replays a single round.
Intended to be run inside of a goroutine - it will replay in real time.
func (*Database) ResetMatch ¶
ResetMatch resets a match
func (*Database) SavePerson ¶
SavePerson stores a person into the DB
func (*Database) SaveTournament ¶
func (d *Database) SaveTournament(t *models.Tournament) error
SaveTournament stores the current state of the tournaments into the db
func (*Database) StoreMessage ¶
StoreMessage stores a message for a match
func (*Database) TogglePlayer ¶
func (d *Database) TogglePlayer(t *models.Tournament, id uint) error
TogglePlayer toggles a player in a tournament
func (*Database) UsurpTournament ¶
func (d *Database) UsurpTournament(t *models.Tournament, x int) error
UsurpTournament adds testing players
type DatabaseConfig ¶
type DatabaseConfig struct { Host string `yaml:"host" json:"host"` Name string `yaml:"name" json:"name"` User string `yaml:"user" json:"user"` Password string `yaml:"password" json:"-"` // JSON disabled to not log the password Verbose bool `yaml:"verbose" json:"verbose"` }
DatabaseConfig unsurprisingly contains the database configuration
type DiscordConfig ¶
type DiscordConfig struct { Key string `yaml:"key" json:"key"` Secret string `yaml:"secret" json:"secret"` Callback string `yaml:"callback" json:"callback"` }
DiscordConfig unsurprisingly contains the Discord configuration
type Listener ¶
type Listener struct { DB *Database // contains filtered or unexported fields }
func NewListener ¶
NewListener sets up a new listener
type LogHook ¶
type LogHook struct {
// contains filtered or unexported fields
}
func (LogHook) AfterQuery ¶
func (l LogHook) AfterQuery(event *pg.QueryEvent)
func (LogHook) BeforeQuery ¶
func (l LogHook) BeforeQuery(event *pg.QueryEvent)
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
func NewPublisher ¶
NewPublisher sets up a new listener
func (*Publisher) Publish ¶
Publish sends a message on the default exchange to the currently configured queue
func (*Publisher) SendTournamentComplete ¶
func (p *Publisher) SendTournamentComplete(t *models.Tournament) error
SendTournamentComplete sends the tournament ended message
type RabbitConfig ¶
type RabbitConfig struct { URL string `yaml:"url" json:"url"` Incoming string `yaml:"incoming" json:"incoming"` Outgoing string `yaml:"outgoing" json:"outgoing"` }
RabbitConfig unsurprisingly contains the RabbitMQ configuration
type ServerConfig ¶
type ServerConfig struct { Port int `yaml:"port" json:"port"` Mode string `yaml:"mode" json:"mode"` }
ServerConfig contains the http server configuration