models

package
v0.0.0-...-906974d Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2015 License: GPL-3.0, GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

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

func LobbyTypeToString(t LobbyType) string

Types

type League

type League string
const (
	LeagueUgc   League = "ugc"
	LeagueEtf2l League = "etf2l"
)

func (*League) String

func (l *League) String() string

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 GetLobbyById

func GetLobbyById(id uint) (*Lobby, *helpers.TPError)

func NewLobby

func NewLobby(mapName string, lobbyType LobbyType, serverInfo ServerRecord, whitelist int) *Lobby

func (*Lobby) AddPlayer

func (lobby *Lobby) AddPlayer(player *Player, slot int) *helpers.TPError

//Add player to lobby

func (*Lobby) AddSpectator

func (lobby *Lobby) AddSpectator(player *Player) *helpers.TPError

func (*Lobby) AfterDelete

func (lobby *Lobby) AfterDelete() error

func (*Lobby) AfterFind

func (lobby *Lobby) AfterFind() error

func (*Lobby) AfterSave

func (lobby *Lobby) AfterSave() error

func (*Lobby) BanPlayer

func (lobby *Lobby) BanPlayer(player *Player)

func (*Lobby) Close

func (lobby *Lobby) Close()

func (*Lobby) GetPlayerIdBySlot

func (lobby *Lobby) GetPlayerIdBySlot(slot int) (uint, error)

func (*Lobby) GetPlayerNumber

func (lobby *Lobby) GetPlayerNumber() int

func (*Lobby) GetPlayerSlot

func (lobby *Lobby) GetPlayerSlot(player *Player) (int, error)

func (*Lobby) IsEveryoneReady

func (lobby *Lobby) IsEveryoneReady() bool

func (*Lobby) IsFull

func (lobby *Lobby) IsFull() bool

func (*Lobby) IsPlayerReady

func (lobby *Lobby) IsPlayerReady(player *Player) (bool, *helpers.TPError)

func (*Lobby) IsSlotFilled

func (lobby *Lobby) IsSlotFilled(slot int) bool

func (*Lobby) IsStarted

func (lobby *Lobby) IsStarted() (bool, *helpers.TPError)

func (*Lobby) ReadyPlayer

func (lobby *Lobby) ReadyPlayer(player *Player) *helpers.TPError

func (*Lobby) RemovePlayer

func (lobby *Lobby) RemovePlayer(player *Player) *helpers.TPError

func (*Lobby) RemoveSpectator

func (lobby *Lobby) RemoveSpectator(player *Player) *helpers.TPError

func (*Lobby) Save

func (lobby *Lobby) Save() error

func (*Lobby) TrySettingUp

func (lobby *Lobby) TrySettingUp() *helpers.TPError

func (*Lobby) UnreadyPlayer

func (lobby *Lobby) UnreadyPlayer(player *Player) *helpers.TPError

type LobbySlot

type LobbySlot struct {
	ID uint
	// Lobby    Lobby
	LobbyId uint
	// Player   Player
	PlayerId uint
	Slot     int
	Ready    bool
}

type LobbyState

type LobbyState int
const (
	LobbyStateInitializing LobbyState = 0
	LobbyStateWaiting      LobbyState = 1
	LobbyStateInProgress   LobbyState = 2
	LobbyStateEnded        LobbyState = 3
)

type LobbyType

type LobbyType int
const (
	LobbyTypeSixes      LobbyType = 0
	LobbyTypeHighlander LobbyType = 1
)

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 GetPlayerBySteamId

func GetPlayerBySteamId(steamid string) (*Player, *helpers.TPError)

func GetPlayerWithStats

func GetPlayerWithStats(steamid string) (*Player, *helpers.TPError)

func NewPlayer

func NewPlayer(steamId string) (*Player, error)

func (*Player) GetLobbyId

func (player *Player) GetLobbyId() (uint, *helpers.TPError)

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 *Player) IsSpectatingId(lobbyid uint) bool

func (*Player) Save

func (player *Player) Save() error

func (*Player) SetSetting

func (player *Player) SetSetting(key string, value string) error

func (*Player) UpdatePlayerInfo

func (player *Player) UpdatePlayerInfo() error

type PlayerSetting

type PlayerSetting struct {
	ID       uint
	Key      string
	Value    string `sql:"size:65535"`
	PlayerID uint
}

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 NewServer

func NewServer() *Server

func (*Server) AllowPlayer

func (s *Server) AllowPlayer(commId string)

func (*Server) DisallowPlayer

func (s *Server) DisallowPlayer(commId string)

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 (s *Server) IsPlayerAllowed(commId string) bool

func (*Server) IsPlayerInServer

func (s *Server) IsPlayerInServer(playerCommId string) (bool, error)

check if the given commId is in the server

func (*Server) KickAll

func (s *Server) KickAll() error

func (*Server) SetAllowedPlayers

func (s *Server) SetAllowedPlayers(commIds []string)

func (*Server) Setup

func (s *Server) Setup() error

func (*Server) SetupObject

func (s *Server) SetupObject() error

func (*Server) Verify

func (s *Server) Verify()

runs each 10 sec

func (*Server) VerifyInfo

func (s *Server) VerifyInfo() error

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

type ServerRecord struct {
	ID           uint
	Host         string
	RconPassword string
}

type Whitelist

type Whitelist int

Jump to

Keyboard shortcuts

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