Documentation ¶
Index ¶
- Constants
- Variables
- func DividePlayoffPlayers(ps []*PlayerSummary) ([][]*PlayerSummary, error)
- type Arrows
- type Credits
- type LeaderboardPlayer
- type League
- type Levels
- type Match
- type Person
- type PersonAuth
- type Player
- type PlayerState
- type PlayerSummary
- type Position
- type Round
- type Score
- type ScoreSummary
- type Summary
- type Tournament
- type TournamentLeaderboardPlayer
Constants ¶
const ( QUALIFYING = "qualifying" PLAYOFF = "playoff" FINAL = "final" SPECIAL = "special" )
const ( PermissionProducer = 100 PermissionCommentator = 50 PermissionJudge = 30 PermissionPlayer = 10 )
Userlevels. Designed so that we can insert new ones in between them.
Variables ¶
var AllColors = []interface{}{
"green",
"blue",
"pink",
"orange",
"white",
"yellow",
"cyan",
"purple",
"red",
}
AllColors is a list of the available player colors
var ErrFacebookAlreadyExists = errors.New("facebook user already exists")
var ErrPlayerDisabled = errors.New("player is disabled")
var (
ErrPublishDisconnected = errors.New("not connected; will not publish")
)
var ErrPublishIncompleteMatch = errors.New("cannot publish match without four players")
Functions ¶
func DividePlayoffPlayers ¶
func DividePlayoffPlayers(ps []*PlayerSummary) ([][]*PlayerSummary, error)
DividePlayoffPlayers divides the playoff players into four buckets based on their score
The input is expected to be sorted with score descending
Types ¶
type Arrows ¶
type Arrows []int
List of integers where one item is an arrow type as described in the arrow types above.
type Credits ¶
type Credits struct { Executive *Person `json:"executive"` Producers []*Person `json:"producers"` Players []*Person `json:"players"` ArchersHarmed int `json:"archers_harmed"` }
Credits represents the data structure needed to display the credits
type LeaderboardPlayer ¶
type LeaderboardPlayer struct { PersonID int `json:"person_id"` Shots int `json:"shots" sql:",notnull"` Sweeps int `json:"sweeps" sql:",notnull"` Kills int `json:"kills" sql:",notnull"` Self int `json:"self" sql:",notnull"` Matches int `json:"matches" sql:",notnull"` Tournaments int `json:"tournaments" sql:",notnull"` TotalScore int `json:"total_score" sql:",notnull"` SkillScore int `json:"skill_score" sql:",notnull"` // contains filtered or unexported fields }
type League ¶
type League struct { ID uint `json:"id"` Title string `json:"title"` Description string `json:"description"` Started time.Time `json:"started"` Ended time.Time `json:"ended"` Tournaments []*Tournament `json:"tournaments"` }
League represents a league
type Match ¶
type Match struct { ID uint `json:"id"` TournamentID uint `json:"tournament_id"` Players []*Player `json:"players"` Kind string `json:"kind"` Index int `json:"index" sql:",notnull"` Length int `json:"length"` Title string `json:"name"` // TODO(thiderman): Should be "title" Round uint `json:"round"` Pause time.Duration `json:"pause"` Scheduled time.Time `json:"scheduled"` Started time.Time `json:"started"` Ended time.Time `json:"ended"` Level string `json:"level"` Ruleset string `json:"ruleset"` Log *zap.Logger `sql:"-" json:"-"` }
Match represents a game being played
type Person ¶
type Person struct { ID uint `json:"id" sql:",pk"` Name string `json:"name"` Nick string `json:"nick"` PreferredColor string `json:"preferred_color"` ArcherType int `json:"archer_type"` AvatarURL string `json:"avatar_url"` Userlevel int `json:"userlevel"` Disabled bool `json:"disabled" sql:",notnull"` DisplayNames []string `sql:",array" json:"display_names"` HighestPosition *Position `json:"highest_position"` }
A Person is someone having a role in the tournament
func LoadPerson ¶
LoadPerson loads a person from the database
func (*Person) RemoveCookies ¶
RemoveCookies ...
func (*Person) Score ¶
func (p *Person) Score() *ScoreSummary
Score gets the score of the Person
Returned as a map of the total score and an array of maps - one per tournament participated in.
type PersonAuth ¶
type PersonAuth struct { TableName struct{} `sql:"people_auth"` ID uint `json:"id" sql:",pk"` PersonID uint `json:"person_id"` Provider string `json:"provider"` RemoteID string `json:"remote_id"` AvatarURL string `json:"avatar_url"` Nick string `json:"nick"` Name string `json:"name"` AccessToken string `json:"access_token"` }
type Player ¶
type Player struct { ID uint `json:"id"` MatchID uint `sql:",pk" json:"match_id"` PersonID uint `json:"person_id"` Index int `json:"index" sql:",notnull"` Nick string `json:"nick"` Color string `json:"color"` PreferredColor string `json:"preferred_color"` ArcherType int `json:"archer_type" sql:",notnull"` Shots int `json:"shots" sql:",notnull"` Sweeps int `json:"sweeps" sql:",notnull"` Kills int `json:"kills" sql:",notnull"` Self int `json:"self" sql:",notnull"` MatchScore int `json:"match_score" sql:",notnull"` TotalScore int `json:"total_score" sql:",notnull"` DisplayNames []string `sql:",array" json:"display_names"` }
Player is a representation of one player in a match
func (*Player) NumericColor ¶
NumericColor is the numeric representation of the color the player has
func (*Player) Summary ¶
func (p *Player) Summary() PlayerSummary
Summary resturns a Summary{} object for the player
type PlayerState ¶
type PlayerState struct { ID uint `json:"id"` PlayerID uint `json:"player_id"` RoundID uint `json:"round_id"` Index int `json:"index" sql:",notnull"` Arrows Arrows `json:"arrows" sql:",array"` Shield bool `json:"shield" sql:",notnull"` Wings bool `json:"wings" sql:",notnull"` Hat bool `json:"hat" sql:",notnull"` Invisible bool `json:"invisible" sql:",notnull"` Speed bool `json:"speed" sql:",notnull"` Alive bool `json:"alive" sql:",notnull"` Lava bool `json:"lava" sql:",notnull"` Killer int `json:"killer" sql:",notnull"` Up int `json:"up" sql:",notnull"` Down int `json:"down" sql:",notnull"` }
func NewPlayerState ¶
func NewPlayerState() *PlayerState
type PlayerSummary ¶
type PlayerSummary struct { ID uint `json:"id"` TournamentID uint `json:"-"` PersonID uint `json:"person_id"` Shots int `json:"shots" sql:",notnull"` Sweeps int `json:"sweeps" sql:",notnull"` Kills int `json:"kills" sql:",notnull"` Self int `json:"self" sql:",notnull"` Matches int `json:"matches" sql:",notnull"` TotalScore int `json:"score" sql:",notnull"` // TODO(thiderman): Should be "total_score" SkillScore int `json:"skill_score" sql:",notnull"` QualifyingPosition int `json:"qualifying_position"` // contains filtered or unexported fields }
A PlayerSummary is a tournament-wide summary of the scores a player has
func NewPlayerSummary ¶
func NewPlayerSummary(ps *Person) *PlayerSummary
NewPlayerSummary returns a new instance of a tournament player
type Score ¶
type Score struct { TournamentID uint `json:"tournament_id"` MatchID uint `json:"match_id"` Title string `json:"title"` PlayerID uint `json:"player_id"` Nick string `json:"nick"` Color string `json:"color"` Kills int `json:"kills"` Sweeps int `json:"sweeps"` Self int `json:"self"` Shots int `json:"shots"` Matches int `json:"matches"` TotalScore int `json:"total_score"` MatchScore int `json:"match_score"` }
A Score is a representation of the SQL type of the same name
type ScoreSummary ¶
type ScoreSummary struct { Totals score Tournaments map[string]score }
ScoreSummary is a collection of scores for a Person
type Summary ¶
type Summary struct { Position uint `json:"position"` SummaryID uint `json:"summary_id"` PersonID uint `json:"person_id"` TournamentID uint `json:"tournament_id"` Nick string `json:"nick"` Kills int `json:"kills"` Sweeps int `json:"sweeps"` Self int `json:"self"` Shots int `json:"shots"` Matches int `json:"matches"` TotalScore int `json:"total_score"` SkillScore int `json:"skill_score"` }
A Summary is a representation of the SQL type of the same name
type Tournament ¶
type Tournament struct { ID uint `json:"id"` Name string `json:"name"` Slug string `json:"slug"` Opened time.Time `json:"opened"` Scheduled time.Time `json:"scheduled"` Started time.Time `json:"started"` QualifyingEnd time.Time `json:"qualifying_end"` Ended time.Time `json:"ended"` Color string `json:"color"` Cover string `json:"cover"` Length int `json:"length"` FinalLength int `json:"final_length"` LeagueID int `json:"league_id"` Kind string `json:"kind"` Log *zap.Logger `sql:"-" json:"-"` }
Tournament represents a tournament
func NewTournament ¶
func NewTournament(name, id, cover, kind string, scheduledStart time.Time) (*Tournament, error)
NewTournament returns a completely new Tournament
func (*Tournament) EndQualifyingRounds ¶
func (t *Tournament) EndQualifyingRounds(ts time.Time)
EndQualifyingRounds marks when the qualifying rounds end
func (*Tournament) GetCredits ¶
func (t *Tournament) GetCredits() (*Credits, error)
GetCredits returns the credits object needed to display the credits roll.
func (*Tournament) IsRunning ¶
func (t *Tournament) IsRunning() bool
IsRunning returns boolean true if the tournament is running or not
func (*Tournament) StartTournament ¶
func (t *Tournament) StartTournament() error
StartTournament will generate the tournament.
type TournamentLeaderboardPlayer ¶
type TournamentLeaderboardPlayer struct { Nick string `json:"nick"` Shots int `json:"shots" sql:",notnull"` Sweeps int `json:"sweeps" sql:",notnull"` Kills int `json:"kills" sql:",notnull"` Self int `json:"self" sql:",notnull"` Matches int `json:"matches" sql:",notnull"` TotalScore int `json:"total_score" sql:",notnull"` SkillScore int `json:"skill_score" sql:",notnull"` }