Documentation ¶
Index ¶
- type Challonge
- func (c *Challonge) Continue(table int) error
- func (c *Challonge) GetTournamentByID(id int) (*Tournament, error)
- func (c *Challonge) GetTournamentList() ([]*Tournament, error)
- func (c *Challonge) InTournamentMode() bool
- func (c *Challonge) LoadTournament(id int, settings *Settings) error
- func (c *Challonge) UnloadTournament()
- func (c *Challonge) UpdateMatchScore(table int) error
- type Config
- type Match
- func (m *Match) IsOnASide() bool
- func (m *Match) Refresh(username string, apiKey string) error
- func (m *Match) ReportWinner(username string, apiKey string, playerID int, scoresCsv string) error
- func (m *Match) SetInProgress(username string, apiKey string) error
- func (m *Match) UpdateScore(username string, apiKey string, scoresCsv string) error
- type MatchResp
- type MatchesResp
- type Participant
- type ParticipantsResp
- type Settings
- type Tournament
- type TournamentResp
- type TournamentsResp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Challonge ¶
type Challonge struct { Tournament *Tournament `json:"tournament"` Settings *Settings `json:"settings"` // PlayersMap is a map of challonge player ids to players in the db. PlayersMap map[int]*models.Player `json:"-"` // CurrentMatches is a map of table number to match. CurrentMatches map[int]*Match `json:"-"` // contains filtered or unexported fields }
Challonge stores the current challonge instance.
func NewChallonge ¶
func NewChallonge(apiKey string, username string, db *gorm.DB, overlay *overlayPkg.Overlay, tables map[int]*state.State) *Challonge
NewChallonge returns a new Challonge.
func (*Challonge) Continue ¶
Continue completes a game, and sets up the next match for the tournament.
func (*Challonge) GetTournamentByID ¶
func (c *Challonge) GetTournamentByID(id int) (*Tournament, error)
GetTournamentByID returns a tournament by id.
func (*Challonge) GetTournamentList ¶
func (c *Challonge) GetTournamentList() ([]*Tournament, error)
GetTournamentList returns a list of incomplete tournaments on Challonge account.
func (*Challonge) InTournamentMode ¶
InTournamentMode returns if a tournament is currently loaded.
func (*Challonge) LoadTournament ¶
loadTournament loads a tournament by id.
func (*Challonge) UnloadTournament ¶
func (c *Challonge) UnloadTournament()
UnloadTournament unsets the current tournament.
func (*Challonge) UpdateMatchScore ¶
UpdateMatchScore updates a match score on challonge.
type Match ¶
type Match struct { ID int `json:"id"` TournamentID int `json:"tournament_id"` State string `json:"state"` Player1ID *int `json:"player1_id"` Player2ID *int `json:"player2_id"` ScoresCsv string `json:"scores_csv"` Round int `json:"round"` Identifier string `json:"identifier"` SuggestedPlayOrder int `json:"suggested_play_order"` UnderwayAt *time.Time `json:"underway_at"` }
Match is a set to be played within a Tournament.
func (*Match) Refresh ¶
Refreshes a match with new data from Challonge. Should only be used when a match was completed.
func (*Match) ReportWinner ¶
ReportWinner reports the winner of the match to challonge.
func (*Match) SetInProgress ¶
SetInProgress sets the match to in progress on Challonge.
type MatchesResp ¶
type MatchesResp []struct { Match Match `json:"match"` }
type Participant ¶
type ParticipantsResp ¶
type ParticipantsResp []struct { Participant Participant `json:"participant"` }
type Settings ¶
type Settings struct { MaxTables int `json:"max_tables"` GameType models.GameType `json:"game_type"` ShowOverlay bool `json:"show_overlay"` ShowFlags bool `json:"show_flags"` ShowFargo bool `json:"show_fargo"` ShowScore bool `json:"show_score"` IsHandicapped bool `json:"is_handicapped"` ASideRaceTo int `json:"a_side_race_to"` BSideRaceTo int `json:"b_side_race_to"` }
type Tournament ¶
type Tournament struct { ID int `json:"id"` Name string `json:"name"` URL string `json:"url"` TournamentType string `json:"tournament_type"` ParticipantsCount int `json:"participants_count"` Rounds int `json:"rounds"` Matches []*Match `json:"matches"` CreatedAt time.Time `json:"created_at"` CompletedAt *time.Time `json:"completed_at"` Participants []*Participant `json:"participants"` }
Tournament is a tournament bracket on the Challonge account.
func (*Tournament) CompleteIfPossible ¶
func (t *Tournament) CompleteIfPossible(username, apiKey string) error
CompleteIfPossible attempts to complete the tournament.
func (*Tournament) CountParallelMatches ¶
func (t *Tournament) CountParallelMatches() int
CountParallelMatches returns a count of the maximum number of matches that could be played in parallel.
func (*Tournament) GetNextMatch ¶
func (t *Tournament) GetNextMatch() *Match
GetNextMatch returns the first incomplete match in the tournament bracket.
func (*Tournament) HasMoreMatches ¶
func (t *Tournament) HasMoreMatches() bool
HasMoreMatches returns if there are more matches that need to be completed in the tournament.
func (*Tournament) RemainingMatches ¶
func (t *Tournament) RemainingMatches() int
RemainingMatches returns the number of matches yet to be played.
func (*Tournament) Validate ¶
func (t *Tournament) Validate() error
Validate checks to make sure the tournament is in a valid format.
type TournamentResp ¶
type TournamentResp struct {
Tournament Tournament `json:"tournament"`
}
type TournamentsResp ¶
type TournamentsResp []struct { Tournament Tournament `json:"tournament"` }