解决房间可选项不可用问题

This commit is contained in:
kercylan98 2023-05-11 14:09:47 +08:00
parent 3f0d185322
commit 0e2e36fde1
1 changed files with 6 additions and 2 deletions

View File

@ -7,11 +7,15 @@ import (
"go.uber.org/zap"
)
func NewRoom[PlayerID comparable, Player game.Player[PlayerID]](guid int64) *Room[PlayerID, Player] {
return &Room[PlayerID, Player]{
func NewRoom[PlayerID comparable, Player game.Player[PlayerID]](guid int64, options ...RoomOption[PlayerID, Player]) *Room[PlayerID, Player] {
room := &Room[PlayerID, Player]{
guid: guid,
players: synchronization.NewMap[PlayerID, Player](),
}
for _, option := range options {
option(room)
}
return room
}
type Room[PlayerID comparable, Player game.Player[PlayerID]] struct {