diff --git a/game/builtin/room_seat.go b/game/builtin/room_seat.go index 283c070..0683feb 100644 --- a/game/builtin/room_seat.go +++ b/game/builtin/room_seat.go @@ -172,6 +172,15 @@ func (slf *RoomSeat[PlayerID, Player]) GetSeatInfoWithPlayerIDMap() map[PlayerID return slf.seatPS.Map() } +func (slf *RoomSeat[PlayerID, Player]) GetFirstSeat() int { + for seat, playerId := range slf.seatSP { + if playerId != nil { + return seat + } + } + return -1 +} + func (slf *RoomSeat[PlayerID, Player]) GetNextSeat(seat int) int { l := len(slf.seatSP) if l == 0 || seat >= l || seat < 0 { diff --git a/game/room_seat.go b/game/room_seat.go index 8b81cb0..05cb24c 100644 --- a/game/room_seat.go +++ b/game/room_seat.go @@ -26,6 +26,8 @@ type RoomSeat[PlayerID comparable, P Player[PlayerID]] interface { GetSeatInfoMapVacancy() map[int]*PlayerID // GetSeatInfoWithPlayerIDMap 获取座位信息,将以玩家ID作为key GetSeatInfoWithPlayerIDMap() map[PlayerID]int + // GetFirstSeat 获取第一个非空缺座位号,不存在时将返回-1 + GetFirstSeat() int // GetNextSeat 获取下一个座位号,空缺的位置将会被跳过 // - 超出范围将返回-1 // - 当没有下一个座位号时将始终返回本身