解决房间可选项不可用问题
This commit is contained in:
parent
3f0d185322
commit
0e2e36fde1
|
@ -7,11 +7,15 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewRoom[PlayerID comparable, Player game.Player[PlayerID]](guid int64) *Room[PlayerID, Player] {
|
func NewRoom[PlayerID comparable, Player game.Player[PlayerID]](guid int64, options ...RoomOption[PlayerID, Player]) *Room[PlayerID, Player] {
|
||||||
return &Room[PlayerID, Player]{
|
room := &Room[PlayerID, Player]{
|
||||||
guid: guid,
|
guid: guid,
|
||||||
players: synchronization.NewMap[PlayerID, Player](),
|
players: synchronization.NewMap[PlayerID, Player](),
|
||||||
}
|
}
|
||||||
|
for _, option := range options {
|
||||||
|
option(room)
|
||||||
|
}
|
||||||
|
return room
|
||||||
}
|
}
|
||||||
|
|
||||||
type Room[PlayerID comparable, Player game.Player[PlayerID]] struct {
|
type Room[PlayerID comparable, Player game.Player[PlayerID]] struct {
|
||||||
|
|
Loading…
Reference in New Issue