添加获取第一个可用座位号函数
This commit is contained in:
parent
915163d37d
commit
b61a76ee6c
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
// - 当没有下一个座位号时将始终返回本身
|
||||
|
|
Loading…
Reference in New Issue