mchess-server/usher/usher.go

32 lines
577 B
Go
Raw Normal View History

package usher
import (
"local/m/mchess_server/chess"
lobbies "local/m/mchess_server/lobby_registry"
)
type Usher struct {
}
var instance *Usher
func NewUsher() *Usher {
return &Usher{}
}
func GetUsher() *Usher {
if instance == nil {
instance = NewUsher()
}
return instance
}
func (u *Usher) WelcomeNewPlayer(player *chess.Player) *lobbies.Lobby {
lobby := lobbies.GetLobbyRegistry().GetLobbyForPlayer()
return lobby
}
func (u *Usher) AddPlayerToLobbyAndStartGameIfFull(player *chess.Player, lobby *lobbies.Lobby) {
lobby.AddPlayerAndStartGameIfFull(player)
}