新增获取玩家数量接口
This commit is contained in:
parent
f1488fe7d3
commit
da77329799
|
@ -43,6 +43,10 @@ func (slf *Room[PlayerID, Player]) GetPlayers() synchronization.MapReadonly[Play
|
||||||
return slf.players
|
return slf.players
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *Room[PlayerID, Player]) GetPlayerCount() int {
|
||||||
|
return slf.players.Size()
|
||||||
|
}
|
||||||
|
|
||||||
func (slf *Room[PlayerID, Player]) IsExistPlayer(id PlayerID) bool {
|
func (slf *Room[PlayerID, Player]) IsExistPlayer(id PlayerID) bool {
|
||||||
return slf.players.Exist(id)
|
return slf.players.Exist(id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ type Room[PlayerID comparable, P Player[PlayerID]] interface {
|
||||||
GetPlayer(id PlayerID) P
|
GetPlayer(id PlayerID) P
|
||||||
// GetPlayers 获取房间中的所有玩家
|
// GetPlayers 获取房间中的所有玩家
|
||||||
GetPlayers() synchronization.MapReadonly[PlayerID, P]
|
GetPlayers() synchronization.MapReadonly[PlayerID, P]
|
||||||
|
// GetPlayerCount 获取玩家数量
|
||||||
|
GetPlayerCount() int
|
||||||
// IsExistPlayer 检查房间中是否存在特定玩家
|
// IsExistPlayer 检查房间中是否存在特定玩家
|
||||||
IsExistPlayer(id PlayerID) bool
|
IsExistPlayer(id PlayerID) bool
|
||||||
// IsOwner 检查玩家是否是房主
|
// IsOwner 检查玩家是否是房主
|
||||||
|
|
Loading…
Reference in New Issue