feat: room.Helper 支持通过 BroadcastExcept 向被排除表达式命中外的玩家广播消息

This commit is contained in:
kercylan98 2023-08-02 16:17:05 +08:00
parent 553c4362e3
commit 08045088e6
1 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,17 @@ func (slf *Helper[PID, P, R]) BroadcastSeat(handle func(player P), except ...PID
}
}
// BroadcastExcept 向房间中的所有玩家广播消息,根据特定表达式排除指定玩家
// - 当 except 返回 true 时,排除该玩家
func (slf *Helper[PID, P, R]) BroadcastExcept(handle func(player P) bool, except func(player P) bool) {
for _, player := range slf.GetPlayers() {
if except(player) {
continue
}
handle(player)
}
}
// SetPlayerLimit 设置房间中的玩家数量上限
func (slf *Helper[PID, P, R]) SetPlayerLimit(limit int) {
slf.m.SetPlayerLimit(slf.room.GetGuid(), limit)