Documentation ¶
Index ¶
- Constants
- Variables
- type CancelOwnerEventHandle
- type ChangePlayerLimitEventHandle
- type CreateEventHandle
- type Helper
- func (slf *Helper[PID, P, R]) CancelOwner()
- func (slf *Helper[PID, P, R]) GetOwner() P
- func (slf *Helper[PID, P, R]) GetPlayer(playerId PID) P
- func (slf *Helper[PID, P, R]) GetPlayerCount() int
- func (slf *Helper[PID, P, R]) GetPlayerIDs() []PID
- func (slf *Helper[PID, P, R]) GetPlayerLimit() int
- func (slf *Helper[PID, P, R]) GetPlayerRoomHelpers(playerId PID) map[int64]*Helper[PID, P, R]
- func (slf *Helper[PID, P, R]) GetPlayerRooms(playerId PID) map[int64]R
- func (slf *Helper[PID, P, R]) GetPlayers() map[PID]P
- func (slf *Helper[PID, P, R]) GetRemainder() int
- func (slf *Helper[PID, P, R]) HasOwner() bool
- func (slf *Helper[PID, P, R]) HasPlayer(playerId PID) bool
- func (slf *Helper[PID, P, R]) IsEmpty() bool
- func (slf *Helper[PID, P, R]) IsFull() bool
- func (slf *Helper[PID, P, R]) IsOwner(playerId PID) bool
- func (slf *Helper[PID, P, R]) Join(player P) error
- func (slf *Helper[PID, P, R]) KickOut(executor, kicked PID, reason string) error
- func (slf *Helper[PID, P, R]) Leave(player P)
- func (slf *Helper[PID, P, R]) Room() R
- func (slf *Helper[PID, P, R]) SetOwner(playerId PID)
- func (slf *Helper[PID, P, R]) SetPlayerLimit(limit int)
- type Info
- type Manager
- func (slf *Manager[PID, P, R]) CancelOwner(roomId int64)
- func (slf *Manager[PID, P, R]) CreateRoom(room R, options ...Option[PID, P, R])
- func (slf *Manager[PID, P, R]) Exist(guid int64) bool
- func (slf *Manager[PID, P, R]) ExistPlayer(id PID) bool
- func (slf *Manager[PID, P, R]) GetHelper(room R) *Helper[PID, P, R]
- func (slf *Manager[PID, P, R]) GetOwner(roomId int64) (player P)
- func (slf *Manager[PID, P, R]) GetPlayer(id PID) P
- func (slf *Manager[PID, P, R]) GetPlayerCount() int
- func (slf *Manager[PID, P, R]) GetPlayerRoom(id PID) []R
- func (slf *Manager[PID, P, R]) GetPlayerRoomCount(id PID) int
- func (slf *Manager[PID, P, R]) GetPlayerRoomHelpers(playerId PID) (helpers map[int64]*Helper[PID, P, R])
- func (slf *Manager[PID, P, R]) GetPlayerRooms(playerId PID) (rooms map[int64]R)
- func (slf *Manager[PID, P, R]) GetPlayers() *concurrent.BalanceMap[PID, P]
- func (slf *Manager[PID, P, R]) GetRoom(guid int64) R
- func (slf *Manager[PID, P, R]) GetRoomCount() int
- func (slf *Manager[PID, P, R]) GetRoomPlayer(roomId int64, playerId PID) P
- func (slf *Manager[PID, P, R]) GetRoomPlayerCount(guid int64) int
- func (slf *Manager[PID, P, R]) GetRoomPlayerLimit(guid int64) int
- func (slf *Manager[PID, P, R]) GetRoomPlayers(guid int64) map[PID]P
- func (slf *Manager[PID, P, R]) GetRooms() map[int64]R
- func (slf *Manager[PID, P, R]) GetSeatInfo(roomId int64) *Seat[PID, P, R]
- func (slf *Manager[PID, P, R]) HasOwner(roomId int64) bool
- func (slf *Manager[PID, P, R]) InRoom(guid int64, id PID) bool
- func (slf *Manager[PID, P, R]) IsOwner(roomId int64, playerId PID) bool
- func (slf *Manager[PID, P, R]) Join(roomId int64, player P) error
- func (slf *Manager[PID, P, R]) KickOut(roomId int64, executor, kicked PID, reason string) error
- func (slf *Manager[PID, P, R]) Leave(roomId int64, player P)
- func (slf Manager) OnCancelOwnerEvent(room R, oldOwner P)
- func (slf Manager) OnChangePlayerLimitEvent(room R, oldLimit, newLimit int)
- func (slf Manager) OnPlayerJoinRoomEvent(room R, player P)
- func (slf Manager) OnPlayerKickedOutEvent(room R, executor, kicked P, reason string)
- func (slf Manager) OnPlayerLeaveRoomEvent(room R, player P)
- func (slf Manager) OnPlayerSeatCancelEvent(room R, player P, seat int)
- func (slf Manager) OnPlayerSeatChangeEvent(room R, player P, oldSeat, newSeat int)
- func (slf Manager) OnPlayerSeatSetEvent(room R, player P, seat int)
- func (slf Manager) OnPlayerUpgradeOwnerEvent(room R, executor, newOwner P)
- func (slf Manager) OnRoomCreateEvent(room R, helper *Helper[PID, P, R])
- func (slf Manager) RegCancelOwnerEvent(handle CancelOwnerEventHandle[PID, P, R])
- func (slf Manager) RegCancelOwnerEventWithRoom(room R, handle CancelOwnerEventHandle[PID, P, R])
- func (slf Manager) RegChangePlayerLimitEvent(handle ChangePlayerLimitEventHandle[PID, P, R])
- func (slf Manager) RegChangePlayerLimitEventWithRoom(room R, handle ChangePlayerLimitEventHandle[PID, P, R])
- func (slf Manager) RegPlayerJoinRoomEvent(handle PlayerJoinRoomEventHandle[PID, P, R])
- func (slf Manager) RegPlayerJoinRoomEventWithRoom(room R, handle PlayerJoinRoomEventHandle[PID, P, R])
- func (slf Manager) RegPlayerKickedOutEvent(handle PlayerKickedOutEventHandle[PID, P, R])
- func (slf Manager) RegPlayerKickedOutEventWithRoom(room R, handle PlayerKickedOutEventHandle[PID, P, R])
- func (slf Manager) RegPlayerLeaveRoomEvent(handle PlayerLeaveRoomEventHandle[PID, P, R])
- func (slf Manager) RegPlayerLeaveRoomEventWithRoom(room R, handle PlayerLeaveRoomEventHandle[PID, P, R])
- func (slf Manager) RegPlayerSeatCancelEvent(handle PlayerSeatCancelEventHandle[PID, P, R])
- func (slf Manager) RegPlayerSeatCancelEventWithRoom(room R, handle PlayerSeatCancelEventHandle[PID, P, R])
- func (slf Manager) RegPlayerSeatChangeEvent(handle PlayerSeatChangeEventHandle[PID, P, R])
- func (slf Manager) RegPlayerSeatChangeEventWithRoom(room R, handle PlayerSeatChangeEventHandle[PID, P, R])
- func (slf Manager) RegPlayerSeatSetEvent(handle PlayerSeatSetEventHandle[PID, P, R])
- func (slf Manager) RegPlayerSeatSetEventWithRoom(room R, handle PlayerSeatSetEventHandle[PID, P, R])
- func (slf Manager) RegPlayerUpgradeOwnerEvent(handle PlayerUpgradeOwnerEventHandle[PID, P, R])
- func (slf Manager) RegPlayerUpgradeOwnerEventWithRoom(room R, handle PlayerUpgradeOwnerEventHandle[PID, P, R])
- func (slf Manager) RegRoomCreateEvent(handle CreateEventHandle[PID, P, R])
- func (slf *Manager[PID, P, R]) ReleaseRoom(guid int64)
- func (slf *Manager[PID, P, R]) SetOwner(roomId int64, owner PID)
- func (slf *Manager[PID, P, R]) SetPlayerLimit(roomId int64, limit int)
- type Option
- type PlayerJoinRoomEventHandle
- type PlayerKickedOutEventHandle
- type PlayerLeaveRoomEventHandle
- type PlayerSeatCancelEventHandle
- type PlayerSeatChangeEventHandle
- type PlayerSeatSetEventHandle
- type PlayerUpgradeOwnerEventHandle
- type Room
- type Seat
- func (slf *Seat[PlayerID, P, R]) AddSeat(id PlayerID)
- func (slf *Seat[PlayerID, P, R]) GetFirstSeat() int
- func (slf *Seat[PlayerID, P, R]) GetNextSeat(seat int) int
- func (slf *Seat[PlayerID, P, R]) GetNextSeatVacancy(seat int) int
- func (slf *Seat[PlayerID, P, R]) GetPlayerIDWithSeat(seat int) (id PlayerID)
- func (slf *Seat[PlayerID, P, R]) GetPlayerWithSeat(seat int) (player P)
- func (slf *Seat[PlayerID, P, R]) GetPrevSeat(seat int) int
- func (slf *Seat[PlayerID, P, R]) GetPrevSeatVacancy(seat int) int
- func (slf *Seat[PlayerID, P, R]) GetSeat(id PlayerID) int
- func (slf *Seat[PlayerID, P, R]) GetSeatInfo() []*PlayerID
- func (slf *Seat[PlayerID, P, R]) GetSeatInfoMap() map[int]PlayerID
- func (slf *Seat[PlayerID, P, R]) GetSeatInfoMapVacancy() map[int]*PlayerID
- func (slf *Seat[PlayerID, P, R]) GetSeatInfoWithPlayerIDMap() map[PlayerID]int
- func (slf *Seat[PlayerID, P, R]) GetSeatPlayerCount() int
- func (slf *Seat[PlayerID, P, R]) HasSeat(id PlayerID) bool
- func (slf *Seat[PlayerID, P, R]) IsNoSeat(id PlayerID) bool
- func (slf *Seat[PlayerID, P, R]) RemoveSeat(id PlayerID)
- func (slf *Seat[PlayerID, P, R]) SetSeat(id PlayerID, seat int) int
Constants ¶
const (
NoSeat = -1 // 无座位
)
Variables ¶
var ( // ErrRoomNotExist 房间不存在 ErrRoomNotExist = errors.New("room not exist") // ErrRoomPlayerFull 房间人数已满 ErrRoomPlayerFull = errors.New("room player full") // ErrPlayerNotInRoom 玩家不在房间中 ErrPlayerNotInRoom = errors.New("player not in room") // ErrRoomOrPlayerNotExist 房间不存在或玩家不在房间中 ErrRoomOrPlayerNotExist = errors.New("room or player not exist") )
Functions ¶
This section is empty.
Types ¶
type CancelOwnerEventHandle ¶
type CancelOwnerEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, oldOwner P)
CancelOwnerEventHandle 取消房主事件处理函数
type ChangePlayerLimitEventHandle ¶
type ChangePlayerLimitEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, oldLimit, newLimit int)
ChangePlayerLimitEventHandle 改变房间人数上限事件处理函数
type CreateEventHandle ¶ added in v0.0.23
type CreateEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, helper *Helper[PID, P, R])
CreateEventHandle 房间创建事件处理函数
type Helper ¶ added in v0.0.22
type Helper[PID comparable, P game.Player[PID], R Room] struct { *Seat[PID, P, R] // contains filtered or unexported fields }
Helper 易于快捷使用的房间助手
func NewHelper ¶ added in v0.0.22
func NewHelper[PID comparable, P game.Player[PID], R Room](manager *Manager[PID, P, R], room R) *Helper[PID, P, R]
NewHelper 创建房间助手
func (*Helper[PID, P, R]) CancelOwner ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) CancelOwner()
CancelOwner 取消房主
func (*Helper[PID, P, R]) GetOwner ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) GetOwner() P
GetOwner 获取房主
func (*Helper[PID, P, R]) GetPlayer ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) GetPlayer(playerId PID) P
GetPlayer 获取玩家
func (*Helper[PID, P, R]) GetPlayerCount ¶ added in v0.0.22
GetPlayerCount 获取房间中的玩家数量
func (*Helper[PID, P, R]) GetPlayerIDs ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) GetPlayerIDs() []PID
GetPlayerIDs 获取房间中的所有玩家ID
func (*Helper[PID, P, R]) GetPlayerLimit ¶ added in v0.0.22
GetPlayerLimit 获取房间中的玩家数量上限
func (*Helper[PID, P, R]) GetPlayerRoomHelpers ¶ added in v0.0.22
GetPlayerRoomHelpers 获取玩家所在的所有房间助手
func (*Helper[PID, P, R]) GetPlayerRooms ¶ added in v0.0.22
GetPlayerRooms 获取玩家所在的所有房间
func (*Helper[PID, P, R]) GetPlayers ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) GetPlayers() map[PID]P
GetPlayers 获取房间中的所有玩家
func (*Helper[PID, P, R]) GetRemainder ¶ added in v0.0.22
GetRemainder 获取房间还可以容纳多少玩家
func (*Helper[PID, P, R]) Leave ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) Leave(player P)
Leave 离开房间
func (*Helper[PID, P, R]) SetOwner ¶ added in v0.0.22
func (slf *Helper[PID, P, R]) SetOwner(playerId PID)
SetOwner 设置房主
func (*Helper[PID, P, R]) SetPlayerLimit ¶ added in v0.0.22
SetPlayerLimit 设置房间中的玩家数量上限
type Info ¶ added in v0.0.22
type Info[PlayerID comparable, P game.Player[PlayerID], R Room] struct { // contains filtered or unexported fields }
type Manager ¶
type Manager[PID comparable, P game.Player[PID], R Room] struct { // contains filtered or unexported fields }
Manager 房间管理器
func NewManager ¶
func NewManager[PID comparable, P game.Player[PID], R Room]() *Manager[PID, P, R]
NewManager 创建房间管理器
func (*Manager[PID, P, R]) CancelOwner ¶
CancelOwner 取消房主
func (*Manager[PID, P, R]) CreateRoom ¶
CreateRoom 创建房间
func (*Manager[PID, P, R]) ExistPlayer ¶
ExistPlayer 检查玩家是否在任一房间内
func (*Manager[PID, P, R]) GetPlayer ¶
func (slf *Manager[PID, P, R]) GetPlayer(id PID) P
GetPlayer 获取玩家
func (*Manager[PID, P, R]) GetPlayerCount ¶
GetPlayerCount 获取玩家数量
func (*Manager[PID, P, R]) GetPlayerRoom ¶
func (slf *Manager[PID, P, R]) GetPlayerRoom(id PID) []R
GetPlayerRoom 获取玩家所在房间
func (*Manager[PID, P, R]) GetPlayerRoomCount ¶
GetPlayerRoomCount 获取玩家所在房间数量
func (*Manager[PID, P, R]) GetPlayerRoomHelpers ¶ added in v0.0.22
func (slf *Manager[PID, P, R]) GetPlayerRoomHelpers(playerId PID) (helpers map[int64]*Helper[PID, P, R])
GetPlayerRoomHelpers 获取玩家所在的房间助手
func (*Manager[PID, P, R]) GetPlayerRooms ¶ added in v0.0.22
GetPlayerRooms 获取玩家所在的房间
func (*Manager[PID, P, R]) GetPlayers ¶
func (slf *Manager[PID, P, R]) GetPlayers() *concurrent.BalanceMap[PID, P]
GetPlayers 获取所有玩家
func (*Manager[PID, P, R]) GetRoomCount ¶
GetRoomCount 获取房间数量
func (*Manager[PID, P, R]) GetRoomPlayer ¶
GetRoomPlayer 获取房间中的玩家
func (*Manager[PID, P, R]) GetRoomPlayerCount ¶
GetRoomPlayerCount 获取房间中玩家数量
func (*Manager[PID, P, R]) GetRoomPlayerLimit ¶
GetRoomPlayerLimit 获取房间中的玩家数量上限
func (*Manager[PID, P, R]) GetRoomPlayers ¶
GetRoomPlayers 获取房间中的玩家
func (*Manager[PID, P, R]) GetSeatInfo ¶
GetSeatInfo 获取座位信息
func (Manager) OnCancelOwnerEvent ¶
func (slf Manager) OnCancelOwnerEvent(room R, oldOwner P)
OnCancelOwnerEvent 取消房主时将立即执行被注册的事件处理函数
func (Manager) OnChangePlayerLimitEvent ¶
func (slf Manager) OnChangePlayerLimitEvent(room R, oldLimit, newLimit int)
OnChangePlayerLimitEvent 修改玩家上限时将立即执行被注册的事件处理函数
func (Manager) OnPlayerJoinRoomEvent ¶
func (slf Manager) OnPlayerJoinRoomEvent(room R, player P)
OnPlayerJoinRoomEvent 玩家进入房间时将立即执行被注册的事件处理函数
func (Manager) OnPlayerKickedOutEvent ¶
func (slf Manager) OnPlayerKickedOutEvent(room R, executor, kicked P, reason string)
OnPlayerKickedOutEvent 玩家被踢出房间时将立即执行被注册的事件处理函数
func (Manager) OnPlayerLeaveRoomEvent ¶
func (slf Manager) OnPlayerLeaveRoomEvent(room R, player P)
OnPlayerLeaveRoomEvent 玩家离开房间时将立即执行被注册的事件处理函数
func (Manager) OnPlayerSeatCancelEvent ¶
func (slf Manager) OnPlayerSeatCancelEvent(room R, player P, seat int)
OnPlayerSeatCancelEvent 玩家座位取消时将立即执行被注册的事件处理函数
func (Manager) OnPlayerSeatChangeEvent ¶
func (slf Manager) OnPlayerSeatChangeEvent(room R, player P, oldSeat, newSeat int)
OnPlayerSeatChangeEvent 玩家座位改变时将立即执行被注册的事件处理函数
func (Manager) OnPlayerSeatSetEvent ¶
func (slf Manager) OnPlayerSeatSetEvent(room R, player P, seat int)
OnPlayerSeatSetEvent 玩家座位设置时将立即执行被注册的事件处理函数
func (Manager) OnPlayerUpgradeOwnerEvent ¶
func (slf Manager) OnPlayerUpgradeOwnerEvent(room R, executor, newOwner P)
OnPlayerUpgradeOwnerEvent 玩家成为房主时将立即执行被注册的事件处理函数
func (Manager) OnRoomCreateEvent ¶ added in v0.0.23
func (slf Manager) OnRoomCreateEvent(room R, helper *Helper[PID, P, R])
OnRoomCreateEvent 房间创建时将立即执行被注册的事件处理函数
func (Manager) RegCancelOwnerEvent ¶
func (slf Manager) RegCancelOwnerEvent(handle CancelOwnerEventHandle[PID, P, R])
RegCancelOwnerEvent 取消房主时将立即执行被注册的事件处理函数
func (Manager) RegCancelOwnerEventWithRoom ¶
func (slf Manager) RegCancelOwnerEventWithRoom(room R, handle CancelOwnerEventHandle[PID, P, R])
RegCancelOwnerEventWithRoom 取消房主时将立即执行被注册的事件处理函数
func (Manager) RegChangePlayerLimitEvent ¶
func (slf Manager) RegChangePlayerLimitEvent(handle ChangePlayerLimitEventHandle[PID, P, R])
RegChangePlayerLimitEvent 修改玩家上限时将立即执行被注册的事件处理函数
func (Manager) RegChangePlayerLimitEventWithRoom ¶
func (slf Manager) RegChangePlayerLimitEventWithRoom(room R, handle ChangePlayerLimitEventHandle[PID, P, R])
RegChangePlayerLimitEventWithRoom 修改玩家上限时将立即执行被注册的事件处理函数
func (Manager) RegPlayerJoinRoomEvent ¶
func (slf Manager) RegPlayerJoinRoomEvent(handle PlayerJoinRoomEventHandle[PID, P, R])
RegPlayerJoinRoomEvent 玩家进入房间时将立即执行被注册的事件处理函数
func (Manager) RegPlayerJoinRoomEventWithRoom ¶
func (slf Manager) RegPlayerJoinRoomEventWithRoom(room R, handle PlayerJoinRoomEventHandle[PID, P, R])
RegPlayerJoinRoomEventWithRoom 玩家进入房间时将立即执行被注册的事件处理函数
func (Manager) RegPlayerKickedOutEvent ¶
func (slf Manager) RegPlayerKickedOutEvent(handle PlayerKickedOutEventHandle[PID, P, R])
RegPlayerKickedOutEvent 玩家被踢出房间时将立即执行被注册的事件处理函数
func (Manager) RegPlayerKickedOutEventWithRoom ¶
func (slf Manager) RegPlayerKickedOutEventWithRoom(room R, handle PlayerKickedOutEventHandle[PID, P, R])
RegPlayerKickedOutEventWithRoom 玩家被踢出房间时将立即执行被注册的事件处理函数
func (Manager) RegPlayerLeaveRoomEvent ¶
func (slf Manager) RegPlayerLeaveRoomEvent(handle PlayerLeaveRoomEventHandle[PID, P, R])
RegPlayerLeaveRoomEvent 玩家离开房间时将立即执行被注册的事件处理函数
func (Manager) RegPlayerLeaveRoomEventWithRoom ¶
func (slf Manager) RegPlayerLeaveRoomEventWithRoom(room R, handle PlayerLeaveRoomEventHandle[PID, P, R])
RegPlayerLeaveRoomEventWithRoom 玩家离开房间时将立即执行被注册的事件处理函数
func (Manager) RegPlayerSeatCancelEvent ¶
func (slf Manager) RegPlayerSeatCancelEvent(handle PlayerSeatCancelEventHandle[PID, P, R])
RegPlayerSeatCancelEvent 玩家座位取消时将立即执行被注册的事件处理函数
func (Manager) RegPlayerSeatCancelEventWithRoom ¶
func (slf Manager) RegPlayerSeatCancelEventWithRoom(room R, handle PlayerSeatCancelEventHandle[PID, P, R])
RegPlayerSeatCancelEventWithRoom 玩家座位取消时将立即执行被注册的事件处理函数
func (Manager) RegPlayerSeatChangeEvent ¶
func (slf Manager) RegPlayerSeatChangeEvent(handle PlayerSeatChangeEventHandle[PID, P, R])
RegPlayerSeatChangeEvent 玩家座位改变时将立即执行被注册的事件处理函数
func (Manager) RegPlayerSeatChangeEventWithRoom ¶
func (slf Manager) RegPlayerSeatChangeEventWithRoom(room R, handle PlayerSeatChangeEventHandle[PID, P, R])
RegPlayerSeatChangeEventWithRoom 玩家座位改变时将立即执行被注册的事件处理函数
- 当玩家之前没有座位时,oldSeat 为 NoSeat
func (Manager) RegPlayerSeatSetEvent ¶
func (slf Manager) RegPlayerSeatSetEvent(handle PlayerSeatSetEventHandle[PID, P, R])
RegPlayerSeatSetEvent 玩家座位设置时将立即执行被注册的事件处理函数
func (Manager) RegPlayerSeatSetEventWithRoom ¶
func (slf Manager) RegPlayerSeatSetEventWithRoom(room R, handle PlayerSeatSetEventHandle[PID, P, R])
RegPlayerSeatSetEventWithRoom 玩家座位设置时将立即执行被注册的事件处理函数
func (Manager) RegPlayerUpgradeOwnerEvent ¶
func (slf Manager) RegPlayerUpgradeOwnerEvent(handle PlayerUpgradeOwnerEventHandle[PID, P, R])
RegPlayerUpgradeOwnerEvent 玩家成为房主时将立即执行被注册的事件处理函数
func (Manager) RegPlayerUpgradeOwnerEventWithRoom ¶
func (slf Manager) RegPlayerUpgradeOwnerEventWithRoom(room R, handle PlayerUpgradeOwnerEventHandle[PID, P, R])
RegPlayerUpgradeOwnerEventWithRoom 玩家成为房主时将立即执行被注册的事件处理函数
func (Manager) RegRoomCreateEvent ¶ added in v0.0.23
func (slf Manager) RegRoomCreateEvent(handle CreateEventHandle[PID, P, R])
RegRoomCreateEvent 房间创建时将立即执行被注册的事件处理函数
func (*Manager[PID, P, R]) ReleaseRoom ¶
ReleaseRoom 释放房间
func (*Manager[PID, P, R]) SetPlayerLimit ¶
SetPlayerLimit 设置房间人数上限
type Option ¶ added in v0.0.22
type Option[PID comparable, P game.Player[PID], R Room] func(info *Info[PID, P, R])
func WithNotAutoJoinSeat ¶ added in v0.0.22
func WithNotAutoJoinSeat[PID comparable, P game.Player[PID], R Room]() Option[PID, P, R]
WithNotAutoJoinSeat 设置不自动加入座位
func WithPlayerLimit ¶ added in v0.0.22
WithPlayerLimit 设置房间人数上限
type PlayerJoinRoomEventHandle ¶
type PlayerJoinRoomEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, player P)
PlayerJoinRoomEventHandle 玩家加入房间事件处理函数
type PlayerKickedOutEventHandle ¶
type PlayerKickedOutEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, executor, kicked P, reason string)
PlayerKickedOutEventHandle 玩家被踢出房间事件处理函数
type PlayerLeaveRoomEventHandle ¶
type PlayerLeaveRoomEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, player P)
PlayerLeaveRoomEventHandle 玩家离开房间事件处理函数
type PlayerSeatCancelEventHandle ¶
type PlayerSeatCancelEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, player P, seat int)
PlayerSeatCancelEventHandle 玩家座位取消事件处理函数
type PlayerSeatChangeEventHandle ¶
type PlayerSeatChangeEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, player P, oldSeat, newSeat int)
PlayerSeatChangeEventHandle 玩家座位改变事件处理函数
type PlayerSeatSetEventHandle ¶
type PlayerSeatSetEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, player P, seat int)
PlayerSeatSetEventHandle 玩家座位设置事件处理函数
type PlayerUpgradeOwnerEventHandle ¶
type PlayerUpgradeOwnerEventHandle[PID comparable, P game.Player[PID], R Room] func(room R, oldOwner, newOwner P)
PlayerUpgradeOwnerEventHandle 玩家成为房主事件处理函数
type Seat ¶
type Seat[PlayerID comparable, P game.Player[PlayerID], R Room] struct { // contains filtered or unexported fields }
Seat 房间座位信息
func (*Seat[PlayerID, P, R]) AddSeat ¶ added in v0.0.22
func (slf *Seat[PlayerID, P, R]) AddSeat(id PlayerID)
AddSeat 为特定玩家添加座位
- 当座位存在空缺的时候,玩家将会优先在空缺位置坐下,否则将会在末位追加
func (*Seat[PlayerID, P, R]) GetNextSeat ¶
GetNextSeat 获取特定座位号下一个未缺席的座位号
func (*Seat[PlayerID, P, R]) GetPlayerIDWithSeat ¶
GetPlayerIDWithSeat 获取特定座位号的玩家ID
func (*Seat[PlayerID, P, R]) GetPlayerWithSeat ¶ added in v0.0.22
GetPlayerWithSeat 获取特定座位号的玩家
func (*Seat[PlayerID, P, R]) GetPrevSeat ¶
GetPrevSeat 获取特定座位号上一个未缺席的座位号
func (*Seat[PlayerID, P, R]) GetSeatInfo ¶
func (slf *Seat[PlayerID, P, R]) GetSeatInfo() []*PlayerID
GetSeatInfo 获取所有座位号
- 在非补位模式(WithRoomSeatFillIn)下由于座位号可能存在缺席的情况,所以需要根据是否为空指针进行判断
func (*Seat[PlayerID, P, R]) GetSeatInfoMapVacancy ¶
GetSeatInfoMapVacancy 获取座位号及其对应的玩家信息
- 缺席情况将不会被忽略
func (*Seat[PlayerID, P, R]) GetSeatInfoWithPlayerIDMap ¶
GetSeatInfoWithPlayerIDMap 获取玩家及其座位号信息
func (*Seat[PlayerID, P, R]) GetSeatPlayerCount ¶ added in v0.0.22
GetSeatPlayerCount 获取座位上的玩家数量
- 该数量不包括空缺的座位
func (*Seat[PlayerID, P, R]) RemoveSeat ¶ added in v0.0.22
func (slf *Seat[PlayerID, P, R]) RemoveSeat(id PlayerID)
RemoveSeat 删除玩家座位