Documentation ¶
Index ¶
- Variables
- type BanType
- type JSONFields
- type Player
- func (p *Player) Alias() string
- func (player *Player) BanUntil(tim time.Time, t BanType, reason string, bannedBy uint) error
- func (p *Player) DecoratePlayerTags() []string
- func (player *Player) GenAuthKey() string
- func (player *Player) GetActiveBan(banType BanType) (*PlayerBan, error)
- func (player *Player) GetActiveBans() ([]*PlayerBan, error)
- func (player *Player) GetAllBans() ([]*PlayerBan, error)
- func (player *Player) GetLobbyID(excludeInProgress bool) (uint, error)
- func (player *Player) GetSetting(key string) string
- func (player *Player) GetSpectatingIds() ([]uint, error)
- func (p *Player) HasCreatedLobby() bool
- func (p *Player) HasSubscriptionProgram() bool
- func (player *Player) IsBanned(t BanType) bool
- func (player *Player) IsBannedWithTime(t BanType) (bool, time.Time)
- func (p *Player) IsFollowing(channel string) bool
- func (player *Player) IsSpectatingID(lobbyid uint) bool
- func (p *Player) IsSubscribed(channel string) bool
- func (player *Player) NewReport(rtype ReportType, lobbyid uint)
- func (player *Player) Save() error
- func (player *Player) SetExternalLinks()
- func (player *Player) SetMumbleUsername(lobbyType format.Format, slot int)
- func (p *Player) SetPlayerProfile()
- func (p *Player) SetPlayerSummary()
- func (player *Player) SetSetting(key string, value string)
- func (player *Player) Unban(t BanType) error
- func (player *Player) UpdatePlayerInfo() error
- type PlayerBan
- type PlayerStats
- type Report
- type ReportType
Constants ¶
This section is empty.
Variables ¶
var ErrPlayerInReportedSlot = errors.New("Player in reported slot")
var ErrPlayerNotFound = errors.New("Player not found")
Functions ¶
This section is empty.
Types ¶
type JSONFields ¶
type JSONFields struct { PlaceholderLobbiesPlayed *int `sql:"-" json:"lobbiesPlayed"` PlaceholderTags *[]string `sql:"-" json:"tags"` PlaceholderRoleStr *string `sql:"-" json:"role"` //PlaceholderLobbies *[]LobbyData `sql:"-" json:"lobbies"` PlaceholderStats *PlayerStats `sql:"-" json:"stats"` PlaceholderBans []*PlayerBan `sql:"-" json:"bans"` }
these are fields sent to clients and aren't used by Helen (hence ignored by ORM). Use (*Player).SetPlayerProfile and (*Player).SetPlayerSummary to set them. pointers allow un-needed structs to be set to null, so null is sent instead of the zeroed struct
type Player ¶
type Player struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` ProfileUpdatedAt time.Time `json:"-"` StreamStatusUpdatedAt time.Time `json:"-"` SteamID string `sql:"not null;unique" json:"steamid"` // Players steam ID Stats PlayerStats `json:"-"` StatsID uint `json:"-"` // info from steam api Avatar string `json:"avatar"` Profileurl string `json:"profileUrl"` GameHours int `json:"gameHours"` Name string `json:"name"` // Player name Role authority.AuthRole `sql:"default:0" json:"-"` // Role is player by default Settings postgres.Hstore `json:"-"` MumbleUsername string `sql:"unique"` MumbleAuthkey string `sql:"not null;unique" json:"-"` TwitchAccessToken string `json:"-"` TwitchName string `json:"twitchName"` IsStreaming bool `json:"isStreaming"` ExternalLinks postgres.Hstore `json:"external_links,omitempty"` JSONFields }
Player represents a player object
func GetPlayerBySteamID ¶
Get a player object by it's Steam id
func GetPlayerWithStats ¶
Get a player object by it's Steam ID, with the Stats field
func NewPlayer ¶
Create a new player with the given steam id. Use (*Player).Save() to save the player object.
func (*Player) DecoratePlayerTags ¶
func (*Player) GenAuthKey ¶
func (*Player) GetActiveBan ¶
func (*Player) GetActiveBans ¶
func (*Player) GetAllBans ¶
func (*Player) GetLobbyID ¶
Get the ID of the lobby the player occupies a slot in. Only works for lobbies which aren't closed (LobbyStateEnded). If excludeInProgress, exclude lobbies which are in progress
func (*Player) GetSetting ¶
func (*Player) GetSpectatingIds ¶
Get ID(s) of lobbies (which aren't clsoed) the player is spectating
func (*Player) HasCreatedLobby ¶
func (*Player) HasSubscriptionProgram ¶
IsSubscribed returns whether if the player has a Twitch subscription program. The player object should have a valid access token and twitch name
func (*Player) IsBannedWithTime ¶
func (*Player) IsFollowing ¶
IsFollowing returns whether the player has subscribed to the given Twitch channel. The player obejct should have a valid access token and twitch name
func (*Player) IsSpectatingID ¶
Return true if player is spectating a lobby with the given lobby ID
func (*Player) IsSubscribed ¶
IsSubscribed returns whether if the player has subscribed to the given twitch channel. The player object should have a valid access token and twitch name
func (*Player) NewReport ¶
func (player *Player) NewReport(rtype ReportType, lobbyid uint)
func (*Player) SetExternalLinks ¶
func (player *Player) SetExternalLinks()
func (*Player) SetMumbleUsername ¶
func (*Player) SetPlayerProfile ¶
func (p *Player) SetPlayerProfile()
func (*Player) SetPlayerSummary ¶
func (p *Player) SetPlayerSummary()
func (*Player) SetSetting ¶
func (*Player) UpdatePlayerInfo ¶
Retrieve the player's details using the Steam API. The object needs to be saved after this.
type PlayerBan ¶
type PlayerBan struct { gorm.Model PlayerID uint // ID of the player banned Player Player `gorm:"ForeignKey:PlayerID"` BannedByPlayerID uint // ID of the admin/mod who set ban BannedByPlayer Player `gorm:"ForeignKey:BannedByPlayerID"` Type BanType // Ban type Until time.Time // Time until which the ban is valid Reason string // Reason for the ban Active bool `sql:"default:true"` // Whether the ban is active }
PlayerBan represents a player ban
func GetAllActiveBans ¶
func GetAllActiveBans() []*PlayerBan
func GetAllBans ¶
func GetAllBans() []*PlayerBan
func (*PlayerBan) MarshalJSON ¶
type PlayerStats ¶
type PlayerStats struct { ID uint `json:"-"` Total int `sql:"-" json:"lobbiesPlayed"` PlayedSixesCount int `sql:"played_sixes_count",default:"0" json:"playedSixesCount"` PlayedHighlanderCount int `sql:"played_highlander_count",default:"0" json:"playedHighlanderCount"` PlayedFoursCount int `sql:"played_fours_count",json:"playedFoursCount" ` PlayedUltiduoCount int `sql:"played_ultiduo_count",json:"playedUltiduoCount"` PlayedBballCount int `sql:"played_bball_count",json:"playedBballCount"` Scout int `json:"scout"` ScoutHours time.Duration `json:"scoutHours"` Soldier int `json:"soldier"` SoldierHours time.Duration `json:"soldierHours"` Pyro int `json:"pyro"` PyroHours time.Duration `json:"pyroHours"` Engineer int `json:"engineer"` EngineerHours time.Duration `json:"engineerHours"` Heavy int `json:"heavy"` HeavyHours time.Duration `json:"heavyHours"` Demoman int `json:"demoman"` DemoHours time.Duration `json:"demomanHours"` Sniper int `json:"sniper"` SniperHours time.Duration `json:"sniperHours"` Medic int `json:"medic"` MedicHours time.Duration `json:"medicHours"` Spy int `json:"spy"` SpyHours time.Duration `json:"spyHours"` Substitutes int `json:"substitutes"` }
func NewStats ¶
func NewStats() PlayerStats
func (*PlayerStats) IncreaseClassCount ¶
func (ps *PlayerStats) IncreaseClassCount(f format.Format, slot int)
func (*PlayerStats) IncreaseSubCount ¶
func (ps *PlayerStats) IncreaseSubCount()
func (*PlayerStats) PlayedCountIncrease ¶
func (ps *PlayerStats) PlayedCountIncrease(lt format.Format)
func (*PlayerStats) Save ¶
func (ps *PlayerStats) Save()
func (*PlayerStats) TotalLobbies ¶
func (ps *PlayerStats) TotalLobbies() int
type ReportType ¶
type ReportType int
const ( Substitute ReportType = iota //!sub Vote //!repped by other players RageQuit //rage quit )