32 lines
561 B
Go
32 lines
561 B
Go
package usher
|
|
|
|
import (
|
|
"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)
|
|
}
|