You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
623 B
Go
29 lines
623 B
Go
3 years ago
|
package game
|
||
|
|
||
|
import (
|
||
|
pbRoom "dcg/game/pb/room"
|
||
|
"errors"
|
||
|
)
|
||
|
|
||
|
// LivePair 直播间ID 与 游戏类型 映射关系
|
||
|
var (
|
||
|
LivePair map[int64]pbRoom.GameType
|
||
|
defaultGameType = pbRoom.GameType_ZHG
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
LivePair = make(map[int64]pbRoom.GameType)
|
||
|
}
|
||
|
|
||
|
func CacheGameType(roomId int64, gameType pbRoom.GameType) {
|
||
|
LivePair[roomId] = gameType
|
||
|
}
|
||
|
|
||
|
//goland:noinspection GoNameStartsWithPackageName
|
||
|
func GameTypeByLiveRoomId(roomId int64) (pbRoom.GameType, error) {
|
||
|
if gameType, ok := LivePair[roomId]; ok {
|
||
|
return gameType, nil
|
||
|
}
|
||
|
return defaultGameType, errors.New("该直播间未加入游戏房间")
|
||
|
}
|