mchess-server/usher/usher.go

32 lines
561 B
Go
Raw Normal View History

package usher
import (
2023-06-25 14:11:29 +00:00
"mchess_server/chess"
lobbies "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)
}