tournaments

package
v0.0.0-...-9af3b72 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteByUUID

func DeleteByUUID(uuid uuid.UUID) bool

func YellowDaysInSeason

func YellowDaysInSeason(yellowPeriods []YellowPeriod, season int) map[uuid.UUID]int

Types

type Absentee

type Absentee struct {
	Player   uuid.UUID `json:"player"`
	Reported time.Time `json:"reported"`
	Reason   string    `json:"reason"`
}

type Bet

type Bet struct {
	Player     uuid.UUID `json:"player"`
	Prediction Result    `json:"prediction"`
}

type BountyHunters

type BountyHunters map[uuid.UUID][]uuid.UUID

type ByAvgPlace

type ByAvgPlace struct{ PlayerStandings }

func (ByAvgPlace) Less

func (s ByAvgPlace) Less(i, j int) bool

type ByBestPlayer

type ByBestPlayer struct{ PlayerStandings }

func (ByBestPlayer) Less

func (s ByBestPlayer) Less(i, j int) bool

type ByHeadsUp

type ByHeadsUp struct{ PlayerStandings }

func (ByHeadsUp) Less

func (s ByHeadsUp) Less(i, j int) bool

type ByKnockouts

type ByKnockouts struct{ PlayerStandings }

func (ByKnockouts) Less

func (s ByKnockouts) Less(i, j int) bool

type ByNumPlayed

type ByNumPlayed struct{ PlayerStandings }

func (ByNumPlayed) Less

func (s ByNumPlayed) Less(i, j int) bool

type ByPoints

type ByPoints struct{ PlayerStandings }

func (ByPoints) Less

func (s ByPoints) Less(i, j int) bool

type ByWinRatio

type ByWinRatio struct{ PlayerStandings }

func (ByWinRatio) Less

func (s ByWinRatio) Less(i, j int) bool

type ByWinRatioTotal

type ByWinRatioTotal struct{ PlayerStandings }

func (ByWinRatioTotal) Less

func (s ByWinRatioTotal) Less(i, j int) bool

type ByWinnings

type ByWinnings struct{ PlayerStandings }

func (ByWinnings) Less

func (s ByWinnings) Less(i, j int) bool

type ByWinningsOld

type ByWinningsOld struct{ PlayerStandings }

Implements old tie break used in earlier seasons

func (ByWinningsOld) Less

func (s ByWinningsOld) Less(i, j int) bool

type Info

type Info struct {
	Scheduled time.Time `json:"scheduled"`
	MovedFrom time.Time `json:"movedFrom"`
	Stake     int       `json:"stake"`
	Location  uuid.UUID `json:"location"`
	Catering  uuid.UUID `json:"catering"`
	Season    int       `json:"season"`
}

type MonthStats

type MonthStats struct {
	Year         int        `json:"year"`
	Month        time.Month `json:"month"`
	Best         uuid.UUID  `json:"best"`
	Worst        uuid.UUID  `json:"worst"`
	BountyHunter uuid.UUID  `json:"bountyhunter"`
}

type PeriodStats

type PeriodStats struct {
	YellowPeriods []YellowPeriod `json:"yellowPeriods"`
	MonthStats    []*MonthStats  `json:"monthStats"`
}

func SeasonStats

func SeasonStats(seasons []int) *PeriodStats

type PlayerResult

type PlayerResult struct {
	Place      int       `json:"place"`
	When       time.Time `json:"when"`
	NumPlayers int       `json:"numPlayers"`
}

type PlayerResults

type PlayerResults []PlayerResult

func (PlayerResults) BetterThan

func (s PlayerResults) BetterThan(t PlayerResults) bool

func (PlayerResults) Equals

func (s PlayerResults) Equals(t PlayerResults) bool

func (PlayerResults) Len

func (s PlayerResults) Len() int

func (PlayerResults) Less

func (s PlayerResults) Less(i, j int) bool

func (PlayerResults) Swap

func (s PlayerResults) Swap(i, j int)

type PlayerStanding

type PlayerStanding struct {
	Player     uuid.UUID     `json:"uuid"`
	Results    PlayerResults `json:"results"`
	Winnings   int           `json:"winnings"`
	AvgPlace   float64       `json:"avgPlace"`
	Points     int           `json:"points"`
	NumHeadsUp int           `json:"headsUp"`
	NumWins    int           `json:"wins"`
	NumPlayed  int           `json:"played"`
	Enough     bool          `json:"playedEnough"`
	NumTotal   int           `json:"numTotal"`
	Knockouts  int           `json:"knockouts"`
}

func (*PlayerStanding) Equals

func (s *PlayerStanding) Equals(t *PlayerStanding) bool

type PlayerStandings

type PlayerStandings []*PlayerStanding

func BestPlayer

func BestPlayer(tournaments Tournaments) (PlayerStandings, bool)

func BountyHunter

func BountyHunter(tournaments Tournaments) (PlayerStandings, bool)

func NewStandings

func NewStandings(tournaments Tournaments) PlayerStandings

TODO: Split into smaller functions

func WorstPlayer

func WorstPlayer(tournaments Tournaments) (PlayerStandings, bool)

func (PlayerStandings) ByAvgPlace

func (s PlayerStandings) ByAvgPlace()

func (PlayerStandings) ByBestPlayer

func (s PlayerStandings) ByBestPlayer()

func (PlayerStandings) ByHeadsUp

func (s PlayerStandings) ByHeadsUp()

func (PlayerStandings) ByKnockouts

func (s PlayerStandings) ByKnockouts()

func (PlayerStandings) ByNumPlayed

func (s PlayerStandings) ByNumPlayed()

func (PlayerStandings) ByPoints

func (s PlayerStandings) ByPoints()

func (PlayerStandings) ByWinRatio

func (s PlayerStandings) ByWinRatio()

func (PlayerStandings) ByWinRatioTotal

func (s PlayerStandings) ByWinRatioTotal()

func (PlayerStandings) ByWinnings

func (s PlayerStandings) ByWinnings(oldTieBreak bool)

func (PlayerStandings) ByWorstPlayer

func (s PlayerStandings) ByWorstPlayer()

func (PlayerStandings) Combine

func (existingPS PlayerStandings) Combine(newPS PlayerStandings) PlayerStandings

func (PlayerStandings) Duplicate

func (s PlayerStandings) Duplicate() PlayerStandings

func (PlayerStandings) Len

func (s PlayerStandings) Len() int

func (PlayerStandings) Swap

func (s PlayerStandings) Swap(i, j int)

type RedisTournamentStorage

type RedisTournamentStorage struct {
	// contains filtered or unexported fields
}

func NewRedisTournamentStorage

func NewRedisTournamentStorage() *RedisTournamentStorage

func (*RedisTournamentStorage) Delete

func (rts *RedisTournamentStorage) Delete(uuid uuid.UUID) error

func (*RedisTournamentStorage) Load

func (rts *RedisTournamentStorage) Load(uuid uuid.UUID) (*Tournament, error)

func (*RedisTournamentStorage) LoadAll

func (rts *RedisTournamentStorage) LoadAll() (Tournaments, error)

func (*RedisTournamentStorage) LoadBySeason

func (rts *RedisTournamentStorage) LoadBySeason(season int) (Tournaments, error)

func (*RedisTournamentStorage) Store

func (rts *RedisTournamentStorage) Store(t *Tournament) error

type Result

type Result []uuid.UUID

type SeasonTitles

type SeasonTitles struct {
	Season   int `json:"season"`
	Champion struct {
		Uuid     uuid.UUID `json:"uuid"`
		Winnings int       `json:"winnings"`
	} `json:"champion"`
	AvgPlaceWinner struct {
		Uuid     uuid.UUID `json:"uuid"`
		AvgPlace float64   `json:"avgPlace"`
	} `json:"avgPlaceWinner"`
	PointsWinner struct {
		Uuid   uuid.UUID `json:"uuid"`
		Points int       `json:"points"`
	} `json:"pointsWinner"`
	MostYellowDays struct {
		Uuid uuid.UUID `json:"uuid"`
		Days int       `json:"days"`
	} `json:"mostYellowDays"`
	PlayerOfTheYear struct {
		Uuid   uuid.UUID `json:"uuid"`
		Months int       `json:"months"`
	} `json:"playerOfTheYear"`
	LoserOfTheYear struct {
		Uuid   uuid.UUID `json:"uuid"`
		Months int       `json:"months"`
	} `json:"loserOfTheYear"`
	BountyWinner struct {
		Uuid      uuid.UUID `json:"uuid"`
		Knockouts int       `json:"knockouts"`
	} `json:"bountyWinner"`
}

func Titles

func Titles(seasons []int) []*SeasonTitles

type SortedStandings

type SortedStandings struct {
	ByWinnings      PlayerStandings `json:"byWinnings"`
	ByAvgPlace      PlayerStandings `json:"byAvgPlace"`
	ByPoints        PlayerStandings `json:"byPoints"`
	ByHeadsUp       PlayerStandings `json:"byHeadsUp"`
	ByWinRatio      PlayerStandings `json:"byWinRatio"`
	ByWinRatioTotal PlayerStandings `json:"byWinRatioTotal"`
	ByNumPlayed     PlayerStandings `json:"byNumPlayed"`
	ByKnockouts     PlayerStandings `json:"byKnockouts"`
}

func SeasonStandings

func SeasonStandings(season int) *SortedStandings

func TotalStandings

func TotalStandings(seasons []int) *SortedStandings

type Tournament

type Tournament struct {
	UUID          uuid.UUID     `json:"uuid"`
	Info          Info          `json:"info"`
	Noshows       []Absentee    `json:"noshows"`
	Result        Result        `json:"result"`
	Played        bool          `json:"played"`
	Moved         bool          `json:"moved"`
	Bets          []Bet         `json:"bets"`
	BountyHunters BountyHunters `json:"bountyHunters"`
}

func NewTournament

func NewTournament(tdata Info) (*Tournament, error)

Create a Tournament

func TournamentByUUID

func TournamentByUUID(uuid uuid.UUID) (*Tournament, error)

func (*Tournament) AddNoShow

func (t *Tournament) AddNoShow(player uuid.UUID, reason string) error

func (*Tournament) RemoveNoShow

func (t *Tournament) RemoveNoShow(player uuid.UUID) error

func (*Tournament) SetBountyHunters

func (t *Tournament) SetBountyHunters(bh BountyHunters) error

func (*Tournament) SetPlayed

func (t *Tournament) SetPlayed(isPlayed bool) error

func (*Tournament) SetResult

func (t *Tournament) SetResult(result Result) error

func (*Tournament) UpdateInfo

func (t *Tournament) UpdateInfo(tdata Info) error

type TournamentStorage

type TournamentStorage interface {
	Store(*Tournament) error
	Delete(uuid.UUID) error
	Load(uuid.UUID) (*Tournament, error)
	LoadAll() (Tournaments, error)
	LoadBySeason(int) (Tournaments, error)
}

A storage interface for Tournaments

type Tournaments

type Tournaments []*Tournament

func AllTournaments

func AllTournaments() (Tournaments, error)

func TournamentsByPeriod

func TournamentsByPeriod(from time.Time, to time.Time) (Tournaments, error)

func TournamentsBySeason

func TournamentsBySeason(season int) (Tournaments, error)

func (Tournaments) GroupByMonths

func (t Tournaments) GroupByMonths(season int) map[time.Month]Tournaments

func (Tournaments) Len

func (t Tournaments) Len() int

func (Tournaments) Less

func (t Tournaments) Less(i, j int) bool

func (Tournaments) Played

func (t Tournaments) Played() Tournaments

func (Tournaments) Seasons

func (t Tournaments) Seasons() []int

func (Tournaments) Swap

func (t Tournaments) Swap(i, j int)

type YellowPeriod

type YellowPeriod struct {
	From   time.Time `json:"from"`
	To     time.Time `json:"to"`
	Player uuid.UUID `json:"uuid"`
	Active bool      `json:"active"`
}

func YellowPeriods

func YellowPeriods(tournaments Tournaments) []YellowPeriod

Jump to

Keyboard shortcuts

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