Documentation ¶
Index ¶
- Variables
- func HasPermission(c *gin.Context, lvl int) bool
- func RequestLogger(log *zap.Logger) gin.HandlerFunc
- type AuthResponse
- type EndQualifyingRequest
- type FakeNameResponse
- type HTTPError
- type HTTPResponse
- type LeagueListResponse
- type LeagueResponse
- type MatchesResponse
- type NewRequest
- type PeopleResponse
- type PerishRequest
- type PersonResponse
- type PlayerSummariesResponse
- type ScoreResponse
- type Server
- func (s *Server) AddMessageToQueue(c *gin.Context)
- func (s *Server) AutoplayMatchHandler(c *gin.Context)
- func (s *Server) BuildRouter(wb *messages.WebsocketBroker) *gin.Engine
- func (s *Server) ClearTournamentHandler(c *gin.Context)
- func (s *Server) CreditsHandler(c *gin.Context)
- func (s *Server) DBLoginHandler(c *gin.Context)
- func (s *Server) DisableHandler(c *gin.Context)
- func (s *Server) EndQualifyingHandler(c *gin.Context)
- func (s *Server) FakeNameHandler(c *gin.Context)
- func (s *Server) LeagueHandler(c *gin.Context)
- func (s *Server) LeagueListHandler(c *gin.Context)
- func (s *Server) LogoutHandler(c *gin.Context)
- func (s *Server) MatchesHandler(c *gin.Context)
- func (s *Server) NewHandler(c *gin.Context)
- func (s *Server) OverviewHandler(c *gin.Context)
- func (s *Server) PeopleHandler(c *gin.Context)
- func (s *Server) PerishHandler(c *gin.Context)
- func (s *Server) PersonFromSession(c *gin.Context) (*models.Person, error)
- func (s *Server) PersonHandler(c *gin.Context)
- func (s *Server) PlayerSummariesHandler(c *gin.Context)
- func (s *Server) PlayoffRunnerupsHandler(c *gin.Context)
- func (s *Server) PublishNext(t *models.Tournament) error
- func (s *Server) QueueHandler(c *gin.Context)
- func (s *Server) RegisterHandler(c *gin.Context)
- func (s *Server) ReplayRound(c *gin.Context)
- func (s *Server) RequireJudge() gin.HandlerFunc
- func (s *Server) RunnerupsHandler(c *gin.Context)
- func (s *Server) ScoresHandler(c *gin.Context)
- func (s *Server) Serve() error
- func (s *Server) SetTimeHandler(c *gin.Context)
- func (s *Server) SettingsHandler(c *gin.Context)
- func (s *Server) StartPlayHandler(c *gin.Context)
- func (s *Server) StartTournamentHandler(c *gin.Context)
- func (s *Server) ToggleHandler(c *gin.Context)
- func (s *Server) TournamentHandler(c *gin.Context)
- func (s *Server) TournamentLeaderboardHandler(c *gin.Context)
- func (s *Server) TournamentListHandler(c *gin.Context)
- func (s *Server) UserHandler(c *gin.Context)
- func (s *Server) UsurpTournamentHandler(c *gin.Context)
- type SettingsPostRequest
- type StartPlayResponse
- type SummariesResponse
- type TournamentLeaderboardResponse
- type TournamentListResponse
- type TournamentResponse
Constants ¶
This section is empty.
Variables ¶
var ( CookieStoreName = "user-session" CookieStoreKey = []byte("dtf") )
Setup variables for the cookies.
Functions ¶
func HasPermission ¶
HasPermission checks that the user is allowed to do an action
func RequestLogger ¶
func RequestLogger(log *zap.Logger) gin.HandlerFunc
Types ¶
type AuthResponse ¶
type AuthResponse struct {
Authenticated bool `json:"authenticated"`
}
AuthResponse returns boolean if we are authenticated or not
type EndQualifyingRequest ¶
type FakeNameResponse ¶
type LeagueListResponse ¶
LeagueListResponse is a list of League objects
type LeagueResponse ¶
LeagueResponse is a single League
type MatchesResponse ¶
MatchesResponse is a list of matches
type NewRequest ¶
type NewRequest struct { Name string `json:"name" binding:"required"` ID string `json:"id" binding:"required"` Scheduled time.Time `json:"scheduled" binding:"required"` Cover string `json:"cover"` Fake bool `json:"fake"` Kind string `json:"kind" form:",default=headhunters"` }
NewRequest is the request to make a new tournament
type PeopleResponse ¶
type PeopleResponse struct { People []*models.Person `json:"people"` Leaderboard []*models.LeaderboardPlayer `json:"leaderboard"` }
PeopleResponse is a list of everyone registered in the app, with a leaderboard
type PerishRequest ¶
type PerishRequest struct {
Key string `json:"key"`
}
PerishRequest is the request for the server to go die
type PersonResponse ¶
type PersonResponse struct { Person *models.Person `json:"person"` Leaderboard *models.LeaderboardPlayer `json:"leaderboard"` }
PesonResponse is like PeopleResponse, but for a single person
type PlayerSummariesResponse ¶
type PlayerSummariesResponse struct {
PlayerSummaries []*models.PlayerSummary `json:"player_summaries"`
}
PlayerSummariesResponse is a list PlayerSummary objects
type ScoreResponse ¶
ScoreResponse is a list of Score objects
type Server ¶
Server is an abstraction that runs a web interface
var Global *Server
func NewServer ¶
func NewServer(config *towerfall.Config, db *towerfall.Database, wb *messages.WebsocketBroker) *Server
NewServer instantiates a server with an active database
func (*Server) AddMessageToQueue ¶
AddMessageToQueue godoc @Summary Adds a message into the current match @Description This is a tool to simulate input from the game. @Description It literally just accepts the JSON body of the POST @Tags testing @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/message [post]
func (*Server) AutoplayMatchHandler ¶
AutoplayMatchHandler godoc @Summary Replays a real match on a testing match, completing it in full @Tags testing @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/autoplay/ [get]
func (*Server) BuildRouter ¶
func (s *Server) BuildRouter(wb *messages.WebsocketBroker) *gin.Engine
BuildRouter sets up the routes
func (*Server) ClearTournamentHandler ¶
ClearTournamentHandler godoc @Summary Removes all test tournaments @Description Any tournament that does not start with "DrunkenFall" is removed. @Description Returns a list of the remaining tournaments. @Tags testing @Accept json @Produce json @Success 200 {object} backend.TournamentListResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/ [delete]
func (*Server) CreditsHandler ¶
CreditsHandler godoc @Summary Returns the data needed for the credits roll @Tags tournament @Accept json @Produce json @Success 200 {object} models.Credits @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/credits/ [get]
func (*Server) DBLoginHandler ¶
func (*Server) DisableHandler ¶
DisableHandler godoc @Summary Disables or enables players @Tags user @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /user/disable/{person} [get]
func (*Server) EndQualifyingHandler ¶
EndQualifyingHandler godoc @Summary Sets the cutoff time for the qualifying rounds @Description The cutoff time works so that the tournament will continue to schedule qualifying matches until the timestamp has passed. @Description This is a necessity due to the nature of always scheduling two // matches ahead. @Description Note that the 'time.Time' parameter called 'time' cannot be @Description documented at this time due to a swaggo error. @Tags tournament @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/endqualifying/ [post]
func (*Server) FakeNameHandler ¶
FakeNameHandler returns a fake name for a tournament
func (*Server) LeagueHandler ¶
LeagueHandler godoc @Summary Get a single league @Tags league @Accept json @Produce json @Param id path int true "League ID" @Success 200 {object} backend.LeagueResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /leagues/{id}/ [get]
func (*Server) LeagueListHandler ¶
LeagueListHandler godoc @Summary Get all leagues @Description Returns a list of all leagues, with tournaments. Note that the @Description tournaments are not sorted, because the ORM is very good for such cases. @Tags league @Accept json @Produce json @Success 200 {object} backend.LeagueListResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /leagues/ [get]
func (*Server) LogoutHandler ¶
LogoutHandler godoc @Summary Logs out the user @Tags user @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /user/logout/ [get]
func (*Server) MatchesHandler ¶
MatchesHandler godoc @Summary Gets the matches for a tournament @Tags tournament @Accept json @Produce json @Success 200 {object} backend.MatchesResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/matches/ [get]
func (*Server) NewHandler ¶
NewHandler shows the page to create a new tournament
func (*Server) OverviewHandler ¶
OverviewHandler godoc @Summary Returns the player summaries for all the players in a tournament @Tags tournament @Accept json @Produce json @Success 200 {object} backend.SummariesResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/overview/ [get]
func (*Server) PeopleHandler ¶
PeopleHandler godoc @Summary Returns a list of all the players registered in the app, including the leaderboard @Tags people @Accept json @Produce json @Success 200 {object} backend.PeopleResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /people/ [get]
func (*Server) PerishHandler ¶
LeagueHandler godoc @Summary Exit the application @Description This is used to trigger a restart and upgrade @Tags league @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 403 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /perish/ [post]
func (*Server) PersonFromSession ¶
PersonFromSession returns the Person{} object attached to the session
func (*Server) PersonHandler ¶
PersonHandler godoc @Summary Returns a single player, including their leaderboard data @Tags people @Accept json @Produce json @Success 200 {object} backend.PersonResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /people/{person} [get]
func (*Server) PlayerSummariesHandler ¶
PlayerSummariesHandler godoc @Summary Returns the player summaries for all the players in a tournament @Tags tournament @Accept json @Produce json @Success 200 {object} backend.PlayerSummariesResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/players/ [get]
func (*Server) PlayoffRunnerupsHandler ¶
PlayoffRunnerupsHandler godoc @Summary Returns the current playoff runnerups for a tournament, in playing order @Description The scores are only for the playoffs and not for the full tournament. @Tags tournament @Accept json @Produce json @Success 200 {object} backend.PlayerSummariesResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/runnerups/playoffs/ [get]
func (*Server) PublishNext ¶
func (s *Server) PublishNext(t *models.Tournament) error
PublishNext sends information about the next match to the game
It only does this if the match already has four players. If it does not, it's a semi that needs backfilling, and then the backfilling will make the publish. This should always be called before the match is started, so t.NextMatch() can always safely be used.
func (*Server) QueueHandler ¶
QueueHandler godoc @Summary Returns the current queue @Description TODO(thiderman): Don't return the leaderboard. @Tags tournament @Accept json @Produce json @Success 200 {object} backend.PeopleResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/queue/ [get]
func (*Server) RegisterHandler ¶
RegisterHandler godoc @Summary Adds a new user. @Description If a tournament is currently running, immediately add the user to there. @Tags user @Accept json @Produce json @Success 200 {object} models.Person @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /user/register/ [post]
func (*Server) ReplayRound ¶
ReplayRound godoc @Summary Replays a single round in real time @Description This is a tool to simulate input from the game, real time style. @Tags testing @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/round_replay [get]
func (*Server) RequireJudge ¶
func (s *Server) RequireJudge() gin.HandlerFunc
func (*Server) RunnerupsHandler ¶
RunnerupsHandler godoc @Summary Returns the current runnerups for a tournament, in playing order @Tags tournament @Accept json @Produce json @Success 200 {object} backend.PlayerSummariesResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/runnerups/ [get]
func (*Server) ScoresHandler ¶
ScoresHandler godoc @Summary Returns the player summaries for all the players in a tournament @Tags tournament @Accept json @Produce json @Success 200 {object} backend.ScoreResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/scores/ [get]
func (*Server) SetTimeHandler ¶
SetTimeHandler godoc @Summary Sets the pause time for the next match @Tags tournament @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/time/{minutes} [get]
func (*Server) SettingsHandler ¶
SettingsHandler godoc @Summary Updates settings @Tags user @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /user/settings/ [post]
func (*Server) StartPlayHandler ¶
StartPlayHandler godoc @Summary Sends a message to the game that it is time to start doing whatever is next. @Tags tournament @Accept json @Produce json @Success 200 {object} backend.StartPlayResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.StartPlayResponse @Router /tournaments/{id}/play/ [post]
func (*Server) StartTournamentHandler ¶
StartTournamentHandler godoc @Summary ...it starts tournaments. What. ¯\_(ツ)_/¯ @Tags tournament @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/start/ [get]
func (*Server) ToggleHandler ¶
ToggleHandler godoc @Summary Adds or removes a player from a tournament @Tags tournament @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/toggle/{person} [get]
func (*Server) TournamentHandler ¶
TournamentHandler godoc @Summary Current state of a tournament @Description Gets the entire current state of the tournament @Tags tournament @Accept json @Produce json @Param id path int true "Tournament ID" @Success 200 {object} backend.TournamentResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/ [get]
func (*Server) TournamentLeaderboardHandler ¶
TournamentLeaderboardHandler godoc @Summary Returns a special JSON view of the current leaderboard @Tags tournament @Accept json @Produce json @Success 200 {object} backend.TournamentLeaderboardResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/players/ [get]
func (*Server) TournamentListHandler ¶
TournamentListHandler godoc @Summary State of all tournaments @Description Returns a list of all tournaments @Tags tournament @Accept json @Produce json @Success 200 {object} backend.TournamentListResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/ [get]
func (*Server) UserHandler ¶
UserHandler godoc @Summary Returns data about the current user @Tags user @Accept json @Produce json @Success 200 {object} models.Person @Failure 400 {object} backend.AuthResponse @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /user/ [get]
func (*Server) UsurpTournamentHandler ¶
UsurpTournamentHandler godoc @Summary Adds random players to a tournament @Description Default is to add 8. @Tags testing @Accept json @Produce json @Success 200 {object} backend.HTTPResponse @Failure 400 {object} backend.HTTPError @Failure 404 {object} backend.HTTPError @Failure 500 {object} backend.HTTPError @Router /tournaments/{id}/usurp/ [get]
type SettingsPostRequest ¶
type SettingsPostRequest struct { Name string `json:"name"` Nick string `json:"nick"` Color string `json:"color"` ArcherType int `json:"archer_type"` }
SettingsPostRequest is a settings update, or a new user register
type StartPlayResponse ¶
type StartPlayResponse struct {
Sent bool `json:"sent"`
}
StartPlayResponse tells whether a start_play messages were sent or not
type SummariesResponse ¶
SummariesResponse is a list of Summary objects
type TournamentLeaderboardResponse ¶
type TournamentLeaderboardResponse struct {
Players []*models.TournamentLeaderboardPlayer `json:"players"`
}
TournamentLeaderboardResponse is a list TournamentLeaderboardPlayer objects
type TournamentListResponse ¶
type TournamentListResponse struct {
Tournaments []*models.Tournament `json:"tournaments"`
}
TournamentListResponse is a list of Tournament objects
type TournamentResponse ¶
type TournamentResponse struct { Tournament *models.Tournament `json:"tournament"` Matches []*models.Match `json:"matches"` PlayerSummaries []*models.PlayerSummary `json:"player_summaries"` Runnerups []*models.PlayerSummary `json:"runnerups"` PlayerStates []*models.PlayerState `json:"player_states"` }
TournamentResponse represents a single tournament, with matches, summaries, runnerups and states attached.