diff --git a/robot/base/config.go b/robot/base/config.go index a8d0433..2966ca5 100644 --- a/robot/base/config.go +++ b/robot/base/config.go @@ -2,15 +2,17 @@ package base import ( "mongo.games.com/goserver/core" + "mongo.games.com/goserver/core/logger" "mongo.games.com/goserver/core/netlib" ) -var Config = Configuration{} +var Config = &Configuration{} type Configuration struct { - Count int // 机器人总数 - AppId string // appID - Connects netlib.SessionConfig // 网络连接配置 + Count int // 机器人总数 + MatchCount int // 比赛机器人总数 + AppId string // appID + Connects netlib.SessionConfig // 网络连接配置 } func (this *Configuration) Name() string { @@ -18,7 +20,10 @@ func (this *Configuration) Name() string { } func (this *Configuration) Init() error { - //logger.Logger.Tracef("%+v", *this) + logger.Logger.Tracef("%+v", *this) + if this.Count == 0 { + this.Count = 20 + } return nil } @@ -27,5 +32,5 @@ func (this *Configuration) Close() error { } func init() { - core.RegistePackage(&Config) + core.RegistePackage(Config) } diff --git a/robot/base/interaction.go b/robot/base/interaction.go index ac516e8..e4c1f64 100644 --- a/robot/base/interaction.go +++ b/robot/base/interaction.go @@ -42,7 +42,7 @@ var ( ) // SendEmote 随机表情 -func SendEmote(s *netlib.Session, p IPlayer, arr []int) { +func SendEmote(s *netlib.Session, arr []int) { e := arr[rand.Intn(len(arr))] // 随机一个表情 if e == -1 { return diff --git a/robot/base/playermgr.go b/robot/base/playermgr.go index 3f2b596..a5f8cfa 100644 --- a/robot/base/playermgr.go +++ b/robot/base/playermgr.go @@ -21,20 +21,16 @@ type PlayerMgr struct { playersMapSnId map[int32]*player_proto.SCPlayerData // 玩家id:玩家信息 playersSession map[int32]*netlib.Session // 非比赛场; 玩家id:session playersMatchSession map[int32]*netlib.Session // 比赛场;玩家id:session - playerEnterType bool } func (pm *PlayerMgr) AddPlayer(data *player_proto.SCPlayerData, s *netlib.Session) { snid := data.GetData().GetSnId() pm.playersMapSnId[snid] = data - // 给比赛场预留50%的机器人 - if pm.playerEnterType { - pm.playerEnterType = false - pm.playersMatchSession[snid] = s - } else { - pm.playerEnterType = true + if Config.Count-Config.MatchCount > len(pm.playersSession) { pm.playersSession[snid] = s + } else { + pm.playersMatchSession[snid] = s } } diff --git a/robot/tienlen/sctienlen.go b/robot/tienlen/sctienlen.go index 57bab5e..d600e3d 100644 --- a/robot/tienlen/sctienlen.go +++ b/robot/tienlen/sctienlen.go @@ -23,7 +23,7 @@ import ( func SendEmote(s *netlib.Session, scene *TienLenScene, p *TienLenPlayer, arr []int, tp int) { if !base.SceneMgrSingleton.IsFreeMode(scene.GetRoomId()) && !scene.IsMatchScene() { if p.EmoteTimes[tp] == 0 { - base.SendEmote(s, p, arr) + base.SendEmote(s, arr) } p.EmoteTimes[tp]++ }