tournament

package
v0.0.0-...-782b09f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Asc  = "asc"
	Desc = "desc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Match

type Match struct {
	Home string
	Away string
	// refers to the result of the home team
	Outcome
}

func ParseInput

func ParseInput(input io.Reader) ([]Match, error)

type Outcome

type Outcome int

Outcome refers to the result of a match(win|draw|loss) The value of an outcome is the point(s) earned.

const (
	Loss Outcome = 0
	Draw Outcome = 1
	Win  Outcome = 3
)

type Table

type Table struct {
	Rows []TableRow
}

Table represents the tournament table ranking teams by points earned

func BuildTable

func BuildTable(matches []Match) *Table

func Tally

func Tally(matches []Match) *Table

Tally builds the tournament table from match results and sorts the table based on points earned by teams in descending order. It is a semantic helper. If you want more control, you can build the table with `tournament.BuildTable` and sort the resulting table with Table.Sort in any order(Desc|Asc) that you choose.

func (*Table) Sort

func (t *Table) Sort(order string) *Table

type TableRow

type TableRow struct {
	Team         string
	MatchPlayed  int
	MatchesWon   int
	MatchesDrawn int
	MatchesLost  int
	Points       int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL