game_sync/worldsrv/coinscenecanenter.go

48 lines
1.6 KiB
Go

package main
import (
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common"
gamehallproto "mongo.games.com/game/protocol/gamehall"
)
type FuncCoinSceneCanEnter func(csp *CoinScenePool, p *Player) gamehallproto.OpResultCode
var coinSceneCanEnterFuncPool = make(map[int]FuncCoinSceneCanEnter)
// RegisterCoinSceneCanEnterFunc 注册游戏入场检测方法
func RegisterCoinSceneCanEnterFunc(gameId int, f FuncCoinSceneCanEnter) {
coinSceneCanEnterFuncPool[gameId] = f
}
func GetCoinSceneCanEnterFunc(gameId int) FuncCoinSceneCanEnter {
if f, exist := coinSceneCanEnterFuncPool[gameId]; exist {
return f
}
return nil
}
func init() {
RegisterCoinSceneCanEnterFunc(common.GameId_ChesstitiansCambodian, chessCanEnterFunc)
RegisterCoinSceneCanEnterFunc(common.GameId_ChesstitiansCambodianRobot, chessCanEnterFunc)
}
// 象棋入场检查象棋积分
func chessCanEnterFunc(csp *CoinScenePool, p *Player) gamehallproto.OpResultCode {
chessGradeLimit := csp.dbGameFree.GetChessGradeLimit()
if len(chessGradeLimit) == 2 {
if chessGradeLimit[0] > 0 && p.ChessGrade < int64(chessGradeLimit[0]) {
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter find snid:%v %v grade limit:%v", p.SnId, p.ChessGrade, chessGradeLimit)
return gamehallproto.OpResultCode_OPRC_ChessGradeLimit
}
if chessGradeLimit[1] > 0 && p.ChessGrade >= int64(chessGradeLimit[1]) {
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter find snid:%v %v grade limit:%v", p.SnId, p.ChessGrade, chessGradeLimit)
return gamehallproto.OpResultCode_OPRC_ChessGradeLimit
}
}
return gamehallproto.OpResultCode_OPRC_Sucess
}
//todo DB_Createroom 入场检测