stats

package
v0.0.0-...-20301d3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB()

func CountMatchesByDifficulty

func CountMatchesByDifficulty(diff difficulty.Difficulty, after time.Time) (n int64, err error)

func FillPlayersWithELO

func FillPlayersWithELO(players []*GamePlayer)

func GetMatchWithFeedsAsCSV

func GetMatchWithFeedsAsCSV(writer io.Writer) (err error)

func GetMatchesAverageUPS

func GetMatchesAverageUPS(after time.Time) (n float64, err error)

func GetMatchesAverageUPSAll

func GetMatchesAverageUPSAll(after time.Time) (n []float64, err error)

func InsertMatch

func InsertMatch(match *Match) error

func OpenDB

func OpenDB(path string)

func ResetELO

func ResetELO() (err error)

func ShouldUpdateELO

func ShouldUpdateELO() (update bool, err error)

func UpdateELO

func UpdateELO() (err error)

UpdateELO iterates over all matches (from oldest to newest) and updates players' ELO.

Types

type Channel

type Channel struct {
	ID      string  `gorm:"PRIMARY_KEY"`
	History []Match `gorm:"foreignkey:ChannelID"`
}

type EmptyModel

type EmptyModel struct {
	ID uint `gorm:"primaryKey" json:"-"`
}

type Event

type Event struct {
	EmptyModel
	Timestamp time.Time
	EventType EventType
	Payload   string
	MatchID   uint `json:"-"`
}

type EventType

type EventType int64
const (
	GameStart EventType = iota
	GameEnd
	JoinGame
	LeaveGame
	JoinTeam
	LeaveTeam
	PlayerDeath
	DifficultyChange
	WinnerAnnounce
	GameTimeAnnounce
	Feed
)

func (*EventType) Scan

func (p *EventType) Scan(value interface{}) error

func (EventType) Value

func (p EventType) Value() (string, error)

type Evo

type Evo struct {
	North, South float32
	Winner       Force
	ID           uint
}

func GetAllEvo

func GetAllEvo(limit int) (ret []Evo, err error)

type Force

type Force int64
const (
	Unknown Force = iota
	Spectator
	North
	South
)

func (Force) Opposite

func (p Force) Opposite() Force

func (*Force) Scan

func (p *Force) Scan(value interface{}) error

func (Force) Value

func (p Force) Value() (string, error)

type GamePlayer

type GamePlayer struct {
	EmptyModel
	PlayerID  uint    `json:"-"`
	Player    *Player `json:",omitempty"`
	Force     Force
	MatchID   uint   `gorm:"index" json:"-"`
	Match     *Match `json:",omitempty"`
	BeforeELO int
	GainELO   int  `json:",omitempty"`
	TeamID    uint `json:"-"`
}

func QueryPlayerMatchesShort

func QueryPlayerMatchesShort(name string) (gp []*GamePlayer, err error)

type MVPplayer

type MVPplayer struct {
	EmptyModel
	Name  string
	Title string
	Stat  int
}

type MVPquery

type MVPquery struct {
	Name  string
	Stat  int
	Total int
}

func QueryGlobalMVP

func QueryGlobalMVP(title string) (mvp []MVPquery, err error)

type Match

type Match struct {
	Model
	Players      []*GamePlayer `gorm:"foreignkey:MatchID" json:",omitempty"`
	South, North *Team         `gorm:"foreignkey:MatchID" json:",omitempty"`
	Start        time.Time     `gorm:"uniqueIndex" json:",omitempty"`
	End          time.Time     `gorm:"index" json:",omitempty"`
	Length       time.Duration
	Winner       Force
	Difficulty   difficulty.Difficulty `sql:"type:difficulty"`
	Timeline     []*Event              `gorm:"foreignkey:MatchID" json:",omitempty"`
	ChannelID    string                `json:"-"`
}

func GetAllMatchesAfter

func GetAllMatchesAfter(after time.Time) (m []Match, err error)

func QueryMatchAll

func QueryMatchAll() (matches []Match, err error)

func QueryMatchLong

func QueryMatchLong(id int) (match *Match, err error)

func QueryMatchShort

func QueryMatchShort(id int) (m *Match, err error)

func (*Match) String

func (m *Match) String() string

func (*Match) UpdateMatchELO

func (m *Match) UpdateMatchELO()

type MatchPlayerCount

type MatchPlayerCount struct {
	MatchID     uint
	PlayerCount int64
}

func GetAllMatchesPlayerCount

func GetAllMatchesPlayerCount(after time.Time) (n []MatchPlayerCount, err error)

type Model

type Model struct {
	ID uint `gorm:"primaryKey"`
}

type Player

type Player struct {
	EmptyModel
	Name    string        `gorm:"unique"`
	ELO     int           `gorm:"default:800;index:,sort:desc"`
	History []*GamePlayer `gorm:"foreignkey:PlayerID" json:",omitempty"`
}

func QueryPlayerByName

func QueryPlayerByName(name string) (p *Player, err error)

func QueryTopPlayersByELO

func QueryTopPlayersByELO(limit int) (p []*Player, err error)

type Team

type Team struct {
	EmptyModel
	Players     []*GamePlayer `gorm:"foreignkey:TeamID" json:",omitempty"`
	MVPs        []*MVPplayer  `gorm:"many2many:mvp_team;" json:",omitempty"`
	AvgELO      float64
	TotalFeed   science.Feed `gorm:"type:integer[]"`
	FinalEVO    float32
	FinalThreat int
	IsNorth     bool `gorm:"type:bool" json:"-"`
	MatchID     uint `gorm:"index" json:"-"`
}

func (*Team) IsPlayerInTeam

func (team *Team) IsPlayerInTeam(name string) bool

Directories

Path Synopsis
const

Jump to

Keyboard shortcuts

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