2023-05-31 21:55:40 +00:00
|
|
|
package usher
|
|
|
|
|
|
|
|
import (
|
2023-06-25 14:11:29 +00:00
|
|
|
"mchess_server/chess"
|
|
|
|
lobbies "mchess_server/lobby_registry"
|
2023-05-31 21:55:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-06-02 19:14:02 +00:00
|
|
|
func (u *Usher) AddPlayerToLobbyAndStartGameIfFull(player *chess.Player, lobby *lobbies.Lobby) {
|
|
|
|
lobby.AddPlayerAndStartGameIfFull(player)
|
2023-05-31 21:55:40 +00:00
|
|
|
}
|