room

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoSeat = -1 // 无座位
)

Variables

View Source
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]) Broadcast added in v0.0.24

func (slf *Helper[PID, P, R]) Broadcast(handle func(player P), except ...PID)

Broadcast 向房间中的所有玩家广播消息

func (*Helper[PID, P, R]) BroadcastExcept added in v0.0.25

func (slf *Helper[PID, P, R]) BroadcastExcept(handle func(player P), except func(player P) bool)

BroadcastExcept 向房间中的所有玩家广播消息,根据特定表达式排除指定玩家

  • 当 except 返回 true 时,排除该玩家

func (*Helper[PID, P, R]) BroadcastSeat added in v0.0.24

func (slf *Helper[PID, P, R]) BroadcastSeat(handle func(player P), except ...PID)

BroadcastSeat 向房间中所有座位上的玩家广播消息

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

func (slf *Helper[PID, P, R]) GetPlayerCount() int

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

func (slf *Helper[PID, P, R]) GetPlayerLimit() int

GetPlayerLimit 获取房间中的玩家数量上限

func (*Helper[PID, P, R]) GetPlayerRoomHelpers added in v0.0.22

func (slf *Helper[PID, P, R]) GetPlayerRoomHelpers(playerId PID) map[int64]*Helper[PID, P, R]

GetPlayerRoomHelpers 获取玩家所在的所有房间助手

func (*Helper[PID, P, R]) GetPlayerRooms added in v0.0.22

func (slf *Helper[PID, P, R]) GetPlayerRooms(playerId PID) map[int64]R

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]) GetPlayersSlice added in v0.0.24

func (slf *Helper[PID, P, R]) GetPlayersSlice() []P

GetPlayersSlice 获取房间中的所有玩家

func (*Helper[PID, P, R]) GetRemainder added in v0.0.22

func (slf *Helper[PID, P, R]) GetRemainder() int

GetRemainder 获取房间还可以容纳多少玩家

func (*Helper[PID, P, R]) HasOwner added in v0.0.22

func (slf *Helper[PID, P, R]) HasOwner() bool

HasOwner 是否有房主

func (*Helper[PID, P, R]) HasPlayer added in v0.0.22

func (slf *Helper[PID, P, R]) HasPlayer(playerId PID) bool

HasPlayer 是否有玩家

func (*Helper[PID, P, R]) IsEmpty added in v0.0.22

func (slf *Helper[PID, P, R]) IsEmpty() bool

IsEmpty 房间是否为空

func (*Helper[PID, P, R]) IsFull added in v0.0.22

func (slf *Helper[PID, P, R]) IsFull() bool

IsFull 房间是否已满

func (*Helper[PID, P, R]) IsOwner added in v0.0.22

func (slf *Helper[PID, P, R]) IsOwner(playerId PID) bool

IsOwner 是否是房主

func (*Helper[PID, P, R]) Join added in v0.0.22

func (slf *Helper[PID, P, R]) Join(player P) error

Join 加入房间

func (*Helper[PID, P, R]) KickOut added in v0.0.22

func (slf *Helper[PID, P, R]) KickOut(executor, kicked PID, reason string) error

KickOut 踢出房间

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]) Room added in v0.0.22

func (slf *Helper[PID, P, R]) Room() R

Room 获取房间

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

func (slf *Helper[PID, P, R]) SetPlayerLimit(limit int)

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

func (slf *Manager[PID, P, R]) CancelOwner(roomId int64)

CancelOwner 取消房主

func (*Manager[PID, P, R]) CreateRoom

func (slf *Manager[PID, P, R]) CreateRoom(room R, options ...Option[PID, P, R])

CreateRoom 创建房间

func (*Manager[PID, P, R]) Exist

func (slf *Manager[PID, P, R]) Exist(guid int64) bool

Exist 检查房间是否存在

func (*Manager[PID, P, R]) ExistPlayer

func (slf *Manager[PID, P, R]) ExistPlayer(id PID) bool

ExistPlayer 检查玩家是否在任一房间内

func (*Manager[PID, P, R]) GetHelper added in v0.0.22

func (slf *Manager[PID, P, R]) GetHelper(room R) *Helper[PID, P, R]

GetHelper 获取房间助手

func (*Manager[PID, P, R]) GetOwner added in v0.0.22

func (slf *Manager[PID, P, R]) GetOwner(roomId int64) (player P)

GetOwner 获取房主

func (*Manager[PID, P, R]) GetPlayer

func (slf *Manager[PID, P, R]) GetPlayer(id PID) P

GetPlayer 获取玩家

func (*Manager[PID, P, R]) GetPlayerCount

func (slf *Manager[PID, P, R]) GetPlayerCount() int

GetPlayerCount 获取玩家数量

func (*Manager[PID, P, R]) GetPlayerRoom

func (slf *Manager[PID, P, R]) GetPlayerRoom(id PID) []R

GetPlayerRoom 获取玩家所在房间

func (*Manager[PID, P, R]) GetPlayerRoomCount

func (slf *Manager[PID, P, R]) GetPlayerRoomCount(id PID) int

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

func (slf *Manager[PID, P, R]) GetPlayerRooms(playerId PID) (rooms map[int64]R)

GetPlayerRooms 获取玩家所在的房间

func (*Manager[PID, P, R]) GetPlayers

func (slf *Manager[PID, P, R]) GetPlayers() *concurrent.BalanceMap[PID, P]

GetPlayers 获取所有玩家

func (*Manager[PID, P, R]) GetRoom

func (slf *Manager[PID, P, R]) GetRoom(guid int64) (r R)

GetRoom 获取房间

func (*Manager[PID, P, R]) GetRoomCount

func (slf *Manager[PID, P, R]) GetRoomCount() int

GetRoomCount 获取房间数量

func (*Manager[PID, P, R]) GetRoomPlayer

func (slf *Manager[PID, P, R]) GetRoomPlayer(roomId int64, playerId PID) P

GetRoomPlayer 获取房间中的玩家

func (*Manager[PID, P, R]) GetRoomPlayerCount

func (slf *Manager[PID, P, R]) GetRoomPlayerCount(guid int64) int

GetRoomPlayerCount 获取房间中玩家数量

func (*Manager[PID, P, R]) GetRoomPlayerLimit

func (slf *Manager[PID, P, R]) GetRoomPlayerLimit(guid int64) int

GetRoomPlayerLimit 获取房间中的玩家数量上限

func (*Manager[PID, P, R]) GetRoomPlayers

func (slf *Manager[PID, P, R]) GetRoomPlayers(guid int64) map[PID]P

GetRoomPlayers 获取房间中的玩家

func (*Manager[PID, P, R]) GetRooms

func (slf *Manager[PID, P, R]) GetRooms() map[int64]R

GetRooms 获取所有房间

func (*Manager[PID, P, R]) GetSeatInfo

func (slf *Manager[PID, P, R]) GetSeatInfo(roomId int64) *Seat[PID, P, R]

GetSeatInfo 获取座位信息

func (*Manager[PID, P, R]) HasOwner added in v0.0.22

func (slf *Manager[PID, P, R]) HasOwner(roomId int64) bool

HasOwner 检查房间是否有房主

func (*Manager[PID, P, R]) InRoom

func (slf *Manager[PID, P, R]) InRoom(guid int64, id PID) bool

InRoom 检查玩家是否在指定房间内

func (*Manager[PID, P, R]) IsOwner added in v0.0.22

func (slf *Manager[PID, P, R]) IsOwner(roomId int64, playerId PID) bool

IsOwner 检查玩家是否是房主

func (*Manager[PID, P, R]) Join

func (slf *Manager[PID, P, R]) Join(roomId int64, player P) error

Join 使玩家加入房间

func (*Manager[PID, P, R]) KickOut

func (slf *Manager[PID, P, R]) KickOut(roomId int64, executor, kicked PID, reason string) error

KickOut 以某种原因踢出特定玩家

  • 该函数不会校验任何权限相关的内容,调用后将直接踢出玩家

func (*Manager[PID, P, R]) Leave

func (slf *Manager[PID, P, R]) Leave(roomId int64, player P)

Leave 使玩家离开房间

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

func (slf *Manager[PID, P, R]) ReleaseRoom(guid int64)

ReleaseRoom 释放房间

func (*Manager[PID, P, R]) SetOwner

func (slf *Manager[PID, P, R]) SetOwner(roomId int64, owner PID)

SetOwner 设置房主

func (*Manager[PID, P, R]) SetPlayerLimit

func (slf *Manager[PID, P, R]) SetPlayerLimit(roomId int64, limit int)

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

func WithPlayerLimit[PID comparable, P game.Player[PID], R Room](limit int) Option[PID, P, R]

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 Room

type Room interface {
	// GetGuid 获取房间的唯一标识符
	GetGuid() int64
}

Room 游戏房间接口

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]) GetFirstSeat

func (slf *Seat[PlayerID, P, R]) GetFirstSeat() int

GetFirstSeat 获取第一个未缺席的座位号

  • 如果没有,将会返回 NoSeat

func (*Seat[PlayerID, P, R]) GetNextSeat

func (slf *Seat[PlayerID, P, R]) GetNextSeat(seat int) int

GetNextSeat 获取特定座位号下一个未缺席的座位号

func (*Seat[PlayerID, P, R]) GetNextSeatVacancy

func (slf *Seat[PlayerID, P, R]) GetNextSeatVacancy(seat int) int

GetNextSeatVacancy 获取特定座位号下一个座位号

  • 缺席将不会被忽略

func (*Seat[PlayerID, P, R]) GetPlayerIDWithSeat

func (slf *Seat[PlayerID, P, R]) GetPlayerIDWithSeat(seat int) (id PlayerID)

GetPlayerIDWithSeat 获取特定座位号的玩家ID

func (*Seat[PlayerID, P, R]) GetPlayerWithSeat added in v0.0.22

func (slf *Seat[PlayerID, P, R]) GetPlayerWithSeat(seat int) (player P)

GetPlayerWithSeat 获取特定座位号的玩家

func (*Seat[PlayerID, P, R]) GetPrevSeat

func (slf *Seat[PlayerID, P, R]) GetPrevSeat(seat int) int

GetPrevSeat 获取特定座位号上一个未缺席的座位号

func (*Seat[PlayerID, P, R]) GetPrevSeatVacancy

func (slf *Seat[PlayerID, P, R]) GetPrevSeatVacancy(seat int) int

GetPrevSeatVacancy 获取特定座位号上一个座位号

  • 缺席将不会被忽略

func (*Seat[PlayerID, P, R]) GetSeat

func (slf *Seat[PlayerID, P, R]) GetSeat(id PlayerID) int

GetSeat 获取玩家座位号

  • 如果玩家没有座位,将会返回 NoSeat

func (*Seat[PlayerID, P, R]) GetSeatInfo

func (slf *Seat[PlayerID, P, R]) GetSeatInfo() []*PlayerID

GetSeatInfo 获取所有座位号

  • 在非补位模式(WithRoomSeatFillIn)下由于座位号可能存在缺席的情况,所以需要根据是否为空指针进行判断

func (*Seat[PlayerID, P, R]) GetSeatInfoMap

func (slf *Seat[PlayerID, P, R]) GetSeatInfoMap() map[int]PlayerID

GetSeatInfoMap 获取座位号及其对应的玩家信息

  • 缺席情况将被忽略

func (*Seat[PlayerID, P, R]) GetSeatInfoMapVacancy

func (slf *Seat[PlayerID, P, R]) GetSeatInfoMapVacancy() map[int]*PlayerID

GetSeatInfoMapVacancy 获取座位号及其对应的玩家信息

  • 缺席情况将不会被忽略

func (*Seat[PlayerID, P, R]) GetSeatInfoWithPlayerIDMap

func (slf *Seat[PlayerID, P, R]) GetSeatInfoWithPlayerIDMap() map[PlayerID]int

GetSeatInfoWithPlayerIDMap 获取玩家及其座位号信息

func (*Seat[PlayerID, P, R]) GetSeatPlayerCount added in v0.0.22

func (slf *Seat[PlayerID, P, R]) GetSeatPlayerCount() int

GetSeatPlayerCount 获取座位上的玩家数量

  • 该数量不包括空缺的座位

func (*Seat[PlayerID, P, R]) HasSeat added in v0.0.22

func (slf *Seat[PlayerID, P, R]) HasSeat(id PlayerID) bool

HasSeat 判断玩家是否有座位

func (*Seat[PlayerID, P, R]) IsNoSeat added in v0.0.22

func (slf *Seat[PlayerID, P, R]) IsNoSeat(id PlayerID) bool

IsNoSeat 判断玩家是否没有座位

func (*Seat[PlayerID, P, R]) RemoveSeat added in v0.0.22

func (slf *Seat[PlayerID, P, R]) RemoveSeat(id PlayerID)

RemoveSeat 删除玩家座位

func (*Seat[PlayerID, P, R]) SetSeat

func (slf *Seat[PlayerID, P, R]) SetSeat(id PlayerID, seat int) int

SetSeat 设置玩家的座位号

  • 如果位置已经有玩家,将会与其进行更换

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL