Documentation ¶
Index ¶
- Constants
- Variables
- func InitServerConfigs() error
- func LobbyTypeToString(t LobbyType) string
- type League
- type Lobby
- func (lobby *Lobby) AddPlayer(player *Player, slot int) *helpers.TPError
- func (lobby *Lobby) AddSpectator(player *Player) *helpers.TPError
- func (lobby *Lobby) AfterDelete() error
- func (lobby *Lobby) AfterFind() error
- func (lobby *Lobby) AfterSave() error
- func (lobby *Lobby) BanPlayer(player *Player)
- func (lobby *Lobby) Close()
- func (lobby *Lobby) GetPlayerIdBySlot(slot int) (uint, error)
- func (lobby *Lobby) GetPlayerNumber() int
- func (lobby *Lobby) GetPlayerSlot(player *Player) (int, error)
- func (lobby *Lobby) IsEveryoneReady() bool
- func (lobby *Lobby) IsFull() bool
- func (lobby *Lobby) IsPlayerReady(player *Player) (bool, *helpers.TPError)
- func (lobby *Lobby) IsSlotFilled(slot int) bool
- func (lobby *Lobby) IsStarted() (bool, *helpers.TPError)
- func (lobby *Lobby) ReadyPlayer(player *Player) *helpers.TPError
- func (lobby *Lobby) RemovePlayer(player *Player) *helpers.TPError
- func (lobby *Lobby) RemoveSpectator(player *Player) *helpers.TPError
- func (lobby *Lobby) Save() error
- func (lobby *Lobby) TrySettingUp() *helpers.TPError
- func (lobby *Lobby) UnreadyPlayer(player *Player) *helpers.TPError
- type LobbySlot
- type LobbyState
- type LobbyType
- type Player
- func (player *Player) GetLobbyId() (uint, *helpers.TPError)
- func (player *Player) GetSetting(key string) (PlayerSetting, error)
- func (player *Player) GetSettings() ([]PlayerSetting, error)
- func (player *Player) IsSpectatingId(lobbyid uint) bool
- func (player *Player) Save() error
- func (player *Player) SetSetting(key string, value string) error
- func (player *Player) UpdatePlayerInfo() error
- type PlayerSetting
- type PlayerStats
- type Server
- func (s *Server) AllowPlayer(commId string)
- func (s *Server) DisallowPlayer(commId string)
- func (s *Server) End()
- func (s *Server) ExecConfig(config *ServerConfig) error
- func (s *Server) IsPlayerAllowed(commId string) bool
- func (s *Server) IsPlayerInServer(playerCommId string) (bool, error)
- func (s *Server) KickAll() error
- func (s *Server) SetAllowedPlayers(commIds []string)
- func (s *Server) Setup() error
- func (s *Server) SetupObject() error
- func (s *Server) Verify()
- func (s *Server) VerifyInfo() error
- type ServerConfig
- type ServerRecord
- type Whitelist
Constants ¶
View Source
const ( ConfigsPath = "/configs/" MapsFile = "maps.json" )
View Source
const ( // etf2l Etf2lInitConfig = "/etf2l/etf2l.cfg" Etf2lBaseSixesConfig = "/etf2l/etf2l_6v6.cfg" Etf2lBaseHighlanderConfig = "/etf2l/etf2l_9v9.cfg" // ugc UgcBaseSixesConfig = "/ugc/ugc_6v_base.cfg" UgcBaseHighlanderConfig = "/ugc/ugc_HL_base.cfg" )
pre config list
Variables ¶
View Source
var FormatMap = map[LobbyType]string{ LobbyTypeSixes: "Sixes", LobbyTypeHighlander: "Highlander", }
View Source
var Leagues = [...]League{ LeagueUgc, LeagueEtf2l, }
valid leagues
View Source
var LobbyServerMap = make(map[uint]*Server)
View Source
var LobbyServerSettingUp = make(map[uint]time.Time)
View Source
var MapsData map[string]map[string]map[League]string
MapsData holds the map + config list from maps.json
View Source
var TypePlayerCount = map[LobbyType]int{ LobbyTypeSixes: 6, LobbyTypeHighlander: 9, }
Functions ¶
func InitServerConfigs ¶
func InitServerConfigs() error
func LobbyTypeToString ¶
Types ¶
type Lobby ¶
type Lobby struct { gorm.Model MapName string State LobbyState Type LobbyType Slots []LobbySlot Server *Server `sql:"-"` // server ServerInfo ServerRecord ServerInfoID uint Whitelist Whitelist //whitelist.tf ID Spectators []Player `gorm:"many2many:spectators_players_lobbies"` BannedPlayers []Player `gorm:"many2many:banned_players_lobbies"` CreatedByID uint CreatedBy Player }
Given Lobby IDs are unique, we'll use them for mumble channel names
func NewLobby ¶
func NewLobby(mapName string, lobbyType LobbyType, serverInfo ServerRecord, whitelist int) *Lobby
func (*Lobby) AfterDelete ¶
func (*Lobby) GetPlayerNumber ¶
func (*Lobby) IsEveryoneReady ¶
func (*Lobby) IsPlayerReady ¶
func (*Lobby) IsSlotFilled ¶
func (*Lobby) RemoveSpectator ¶
func (*Lobby) TrySettingUp ¶
type LobbyState ¶
type LobbyState int
const ( LobbyStateInitializing LobbyState = 0 LobbyStateWaiting LobbyState = 1 LobbyStateInProgress LobbyState = 2 LobbyStateEnded LobbyState = 3 )
type Player ¶
type Player struct { gorm.Model SteamId string `sql:"unique"` // Players steam ID Stats PlayerStats StatsID uint // info from steam api Avatar string Profileurl string GameHours int Name string // Player name Settings []PlayerSetting }
func (*Player) GetSetting ¶
func (player *Player) GetSetting(key string) (PlayerSetting, error)
func (*Player) GetSettings ¶
func (player *Player) GetSettings() ([]PlayerSetting, error)
func (*Player) IsSpectatingId ¶
func (*Player) UpdatePlayerInfo ¶
type PlayerSetting ¶
type PlayerStats ¶
type PlayerStats struct { ID uint PlayedSixesCount int `sql:"played_sixes_count",default:"0"` PlayedHighlanderCount int `sql:"played_highlander_count",default:"0"` }
func NewPlayerStats ¶
func NewPlayerStats() PlayerStats
func (*PlayerStats) PlayedCountGet ¶
func (ps *PlayerStats) PlayedCountGet(lt LobbyType) int
func (*PlayerStats) PlayedCountIncrease ¶
func (ps *PlayerStats) PlayedCountIncrease(lt LobbyType)
func (*PlayerStats) PlayedCountSet ¶
func (ps *PlayerStats) PlayedCountSet(lt LobbyType, value int)
type Server ¶
type Server struct { Map string // lobby map Name string // server name League League Type LobbyType // 9v9 6v6 4v4... LobbyId uint Players []TF2RconWrapper.Player // current number of players in the server AllowedPlayers map[string]bool Config *ServerConfig // config that should run before the lobby starts Ticker verifyTicker // timer that will verify() Rcon *TF2RconWrapper.TF2RconConnection Info ServerRecord ServerPassword string // will store the new server password from the lobby }
func (*Server) AllowPlayer ¶
func (*Server) DisallowPlayer ¶
func (*Server) End ¶
func (s *Server) End()
TODO: get end event from logs `World triggered "Game_Over"`
func (*Server) ExecConfig ¶
func (s *Server) ExecConfig(config *ServerConfig) error
func (*Server) IsPlayerAllowed ¶
func (*Server) IsPlayerInServer ¶
check if the given commId is in the server
func (*Server) SetAllowedPlayers ¶
func (*Server) SetupObject ¶
func (*Server) VerifyInfo ¶
type ServerConfig ¶
type ServerConfig struct { Name string // example: HL_stopwatch League League // ugc, etf2l... Type LobbyType // 9v9, 6v6... Data string // config file's text Map string }
configs.json
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
func (*ServerConfig) Get ¶
func (c *ServerConfig) Get() (string, error)
func (*ServerConfig) GetMapConfig ¶
func (c *ServerConfig) GetMapConfig(mapName string) (string, error)
func (*ServerConfig) GetName ¶
func (c *ServerConfig) GetName() (string, error)
func (*ServerConfig) IsLeagueValid ¶
func (c *ServerConfig) IsLeagueValid() bool
func (*ServerConfig) IsLobbyTypeValid ¶
func (c *ServerConfig) IsLobbyTypeValid() bool
type ServerRecord ¶
Click to show internal directories.
Click to hide internal directories.