Documentation ¶
Index ¶
- Variables
- type FargoHotHandicap
- type FargoHotHandicaps
- type Flag
- type Game
- func (g *Game) DecrementRaceTo() error
- func (g *Game) DecrementScore(playerNum int) error
- func (g *Game) IncrementRaceTo() error
- func (g *Game) IncrementScore(playerNum int) error
- func (g *Game) LoadLatest(table int) *Game
- func (g *Game) Reset() error
- func (g *Game) ResetScore() error
- func (g *Game) Save(completed bool) error
- func (g *Game) SetPlayer(playerNum int, player *Player) error
- func (g *Game) SetPlayerFlag(playerNum int, flag *Flag) error
- func (g *Game) SetPlayerName(playerNum int, name string) error
- func (g *Game) SetRaceTo(raceTo int) error
- func (g *Game) SetTeam(teamNum int, team *Team) error
- func (g *Game) SetType(t GameType) error
- func (g *Game) SetUseFargoHotHandicap(use bool) error
- func (g *Game) SetVsMode(mode GameVsMode) error
- func (g *Game) UnsetPlayer(playerNum int) error
- func (g *Game) WinningPlayerNum() int
- type GameType
- type GameVsMode
- type Player
- type Team
- type TeamPlayer
Constants ¶
This section is empty.
Variables ¶
var ( ErrRaceToInvalid = errors.New("invalid race to amount") ErrRaceToNotFound = errors.New("handicap for race to not found") )
var ( ErrFlagIDInvalid = errors.New("invalid flag id") ErrFlagNotFound = errors.New("flag not found") )
var ( // ErrInvalidPlayerNumber - Invalid player number. ErrInvalidPlayerNumber = errors.New("invalid player number") // ErrInvalidPlayerID - Invalid player ID. ErrInvalidPlayerID = errors.New("invalid player id") // ErrInvalidTeamNumber - Invalid team number. ErrInvalidTeamNumber = errors.New("invalid team number") // ErrInvalidRaceTo - Invalid race to number. ErrInvalidRaceTo = errors.New("invalid race to number") )
var ( ErrPlayerIDInvalid = errors.New("invalid player id") ErrPlayerFargoObservableIDInvalid = errors.New("invalid fargo observable id") ErrPlayerNotFound = errors.New("player not found") ErrPlayerHasIDAlready = errors.New("player already has an id") )
var ( ErrTeamIDInvalid = errors.New("invalid team id") ErrTeamNotFound = errors.New("team not found") )
Functions ¶
This section is empty.
Types ¶
type FargoHotHandicap ¶
type FargoHotHandicap struct { ID uint `json:"id" gorm:"primarykey"` RaceTo int `json:"race_to" gorm:"index"` DifferenceStart uint `json:"difference_start"` DifferenceEnd *uint `json:"difference_end"` WinsHigher uint `json:"wins_higher"` WinsLower uint `json:"wins_lower"` }
FargoHotHandicap is a handicap for the specified race to.
type FargoHotHandicaps ¶
type FargoHotHandicaps []FargoHotHandicap
FargoHotHandicaps are an array of FargoHotHandicap.
func (*FargoHotHandicaps) LoadByRaceTo ¶
func (f *FargoHotHandicaps) LoadByRaceTo(database *gorm.DB, raceTo int) error
LoadByRaceTo loads handicaps for the supplied race to.
type Flag ¶
type Flag struct { ID uint `json:"id,omitempty" gorm:"primarykey"` Country string `json:"country,omitempty" gorm:"size:100"` ImagePath string `json:"image_path,omitempty" gorm:"size:100"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` }
Flag is a country flag for a pool player.
type Game ¶
type Game struct { ID uint `json:"id,omitempty" gorm:"primarykey"` Table int `json:"table" gorm:"column:table_num"` Type GameType `json:"type"` VsMode GameVsMode `json:"vs_mode"` RaceTo int `json:"race_to"` ScoreOne int `json:"score_one"` ScoreTwo int `json:"score_two"` Completed bool `json:"completed"` PlayerOneID *uint `json:"player_one_id,omitempty"` PlayerTwoID *uint `json:"player_two_id,omitempty"` TeamOneID *uint `json:"team_one_id,omitempty"` TeamTwoID *uint `json:"team_two_id,omitempty"` PlayerOne *Player `json:"player_one,omitempty" gorm:"foreignKey:player_one_id"` PlayerTwo *Player `json:"player_two,omitempty" gorm:"foreignKey:player_two_id"` TeamOne *Team `json:"team_one,omitempty" gorm:"foreignKey:team_one_id"` TeamTwo *Team `json:"team_two,omitempty" gorm:"foreignKey:team_two_id"` UseFargoHotHandicap bool `json:"use_fargo_hot_handicap"` FargoHotHandicapID *uint `json:"fargo_hot_handicap_id,omitempty"` FargoHotHandicap *FargoHotHandicap `json:"fargo_hot_handicap,omitempty" gorm:"foreignKey:fargo_hot_handicap_id"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` // contains filtered or unexported fields }
Game is the current state of the game being played.
func (*Game) DecrementRaceTo ¶
DecrementRaceTo decreases the RaceTo of the game by one. Minimum value will always be 1.
func (*Game) DecrementScore ¶
DecrementScore decreases the score for the specified player by one.
func (*Game) IncrementRaceTo ¶
IncrementRaceTo increases the RaceTo of the game by one.
func (*Game) IncrementScore ¶
IncrementScore increases the score for the specified player by one.
func (*Game) LoadLatest ¶
func (*Game) Reset ¶
Reset will reset a game to a new one, while keeping some information about the existing one.
func (*Game) ResetScore ¶
ResetScore resets the current game score.
func (*Game) SetPlayerFlag ¶
SetPlayerFlag sets the flag to the specified player.
func (*Game) SetPlayerName ¶
SetPlayerName sets the name to the specified player.
func (*Game) SetUseFargoHotHandicap ¶
SetUseFargoHotHandicap updates if we are using fargo hot handicap for the current game.
func (*Game) SetVsMode ¶
func (g *Game) SetVsMode(mode GameVsMode) error
SetVsMode changes the current GameVsMode of the game.
func (*Game) UnsetPlayer ¶
UnsetPlayer unsets a player for the specified player num.
func (*Game) WinningPlayerNum ¶
WinningPlayerNum returns the winning player number (1 or 2) or if no winner, returns 0.
type GameType ¶
type GameType uint
GameType is the type of pool gaming being played.
type GameVsMode ¶
type GameVsMode int
GameVsMode is the type of players to be used.
const ( // OneVsOne is one player vs one player. OneVsOne GameVsMode = iota // ScotchDoubles is a team of two players vs a team of two players. ScotchDoubles )
func (GameVsMode) IsValid ¶
func (m GameVsMode) IsValid() bool
IsValid returns if the GameVsMode is valid.
func (GameVsMode) String ¶
func (m GameVsMode) String() string
String returns the human readable version.
type Player ¶
type Player struct { ID uint `json:"id,omitempty" gorm:"primarykey"` Name string `json:"name,omitempty" gorm:"size:100"` FlagID uint `json:"flag_id,omitempty"` Flag *Flag `json:"flag,omitempty" gorm:"foreignKey:flag_id"` FargoID uint `json:"fargo_id,omitempty"` FargoObservableID uint `json:"fargo_observable_id,omitempty"` FargoRating uint `json:"fargo_rating,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` }
Player is a pool player.
func (*Player) LoadByFargoObservableID ¶
LoadByFargoObservableID loads a player by Fargo observable ID.
type Team ¶
type Team struct { ID uint `json:"id,omitempty" gorm:"primarykey"` Name string `json:"name,omitempty" gorm:"size:100"` Players []*TeamPlayer `json:"players,omitempty" gorm:"foreignKey:team_id"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` }
Team is a team of pool players.
type TeamPlayer ¶
type TeamPlayer struct { ID uint `json:"id,omitempty" gorm:"primarykey"` TeamID uint `json:"team_id,omitempty"` PlayerID uint `json:"player_id,omitempty"` Captain bool `json:"captain,omitempty"` Team *Team `json:"team,omitempty"` Player *Player `json:"player,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` }
TeamPlayer is a player on a team.