Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrorParticipantNotEnoughParticipants = errors.New("at least two participants are required to create a bracket") ErrorParticipantEmptyName = errors.New("participant name is empty") )
Functions ¶
This section is empty.
Types ¶
type Match ¶
type Match struct {
ID int
RoundIndex int
MatchIndex int // Index of the match within its round
Participant1 *Participant
Participant2 *Participant
Winner *Participant
NextMatch *Match
}
Match represents a single matchup between two participants.
type Options ¶
type Options struct {
// SeedingRules is a function to define custom seeding logic. (Not yet implemented)
SeedingRules func() error
}
Options defines configuration for tournament generation, like custom seeding rules.
type Participant ¶
Participant represents a competitor in the tournament.
func CreateParticipants ¶
func CreateParticipants(names []string, shuffle bool) ([]*Participant, error)
CreateParticipants takes ordered slice of strings and assigns IDs in ascending order. Mutates the original names array, so duplicate it if you want to keep it as is. If shuffle is set then it uses math/rand to shuffle slice. Returns slice of Participants to be used in NewTournament function.
type Tournament ¶
type Tournament struct {
Name string
Rounds []Round
TournamentType TournamentType
Options *Options
}
Tournament is the root object that contains all data for a tournament event.
func NewTournament ¶
func NewTournament(name string, tournamentType TournamentType, participants []*Participant, options ...Options) (*Tournament, error)
func (*Tournament) PrintAscii ¶
func (t *Tournament) PrintAscii()
PrintAscii displays the current state of the tournament bracket in a text format.
func (*Tournament) SetWinner ¶
func (t *Tournament) SetWinner(roundIndex, matchIndex, winnerID int) error
SetWinner sets the winner of a specific match and advances them to the next round.
type TournamentType ¶
type TournamentType string
TournamentType defines the kind of tournament, e.g., single or double elimination.
const ( SingleElimination TournamentType = "single-elimination" DoubleElimination TournamentType = "double-elimination" // TODO )