mchess-server/lobby_registry/lobby.go

34 lines
561 B
Go
Raw Normal View History

package lobby_registry
import (
"local/m/mchess_server/chess"
"github.com/google/uuid"
)
type Lobby struct {
uuid uuid.UUID
players []*chess.Player
}
func NewEmptyLobbyByUUID(uuid uuid.UUID) *Lobby {
return &Lobby{uuid: uuid}
}
func (w *Lobby) AddPlayer(player *chess.Player) {
w.players = append(w.players, player)
player.JoinedLobby <- true
}
func (w *Lobby) IsFull() bool {
return len(w.players) == 2
}
func (l *Lobby) GetPlayer1() *chess.Player {
return l.players[0]
}
func (l *Lobby) GetPlayer2() *chess.Player {
return l.players[1]
}