机器人比赛场数量参数
This commit is contained in:
parent
95701368a6
commit
cad0f24bd8
|
@ -2,15 +2,17 @@ package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/goserver/core"
|
"mongo.games.com/goserver/core"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Config = Configuration{}
|
var Config = &Configuration{}
|
||||||
|
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
Count int // 机器人总数
|
Count int // 机器人总数
|
||||||
AppId string // appID
|
MatchCount int // 比赛机器人总数
|
||||||
Connects netlib.SessionConfig // 网络连接配置
|
AppId string // appID
|
||||||
|
Connects netlib.SessionConfig // 网络连接配置
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Configuration) Name() string {
|
func (this *Configuration) Name() string {
|
||||||
|
@ -18,7 +20,10 @@ func (this *Configuration) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Configuration) Init() error {
|
func (this *Configuration) Init() error {
|
||||||
//logger.Logger.Tracef("%+v", *this)
|
logger.Logger.Tracef("%+v", *this)
|
||||||
|
if this.Count == 0 {
|
||||||
|
this.Count = 20
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,5 +32,5 @@ func (this *Configuration) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
core.RegistePackage(&Config)
|
core.RegistePackage(Config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SendEmote 随机表情
|
// SendEmote 随机表情
|
||||||
func SendEmote(s *netlib.Session, p IPlayer, arr []int) {
|
func SendEmote(s *netlib.Session, arr []int) {
|
||||||
e := arr[rand.Intn(len(arr))] // 随机一个表情
|
e := arr[rand.Intn(len(arr))] // 随机一个表情
|
||||||
if e == -1 {
|
if e == -1 {
|
||||||
return
|
return
|
||||||
|
|
|
@ -21,20 +21,16 @@ type PlayerMgr struct {
|
||||||
playersMapSnId map[int32]*player_proto.SCPlayerData // 玩家id:玩家信息
|
playersMapSnId map[int32]*player_proto.SCPlayerData // 玩家id:玩家信息
|
||||||
playersSession map[int32]*netlib.Session // 非比赛场; 玩家id:session
|
playersSession map[int32]*netlib.Session // 非比赛场; 玩家id:session
|
||||||
playersMatchSession 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) {
|
func (pm *PlayerMgr) AddPlayer(data *player_proto.SCPlayerData, s *netlib.Session) {
|
||||||
snid := data.GetData().GetSnId()
|
snid := data.GetData().GetSnId()
|
||||||
pm.playersMapSnId[snid] = data
|
pm.playersMapSnId[snid] = data
|
||||||
|
|
||||||
// 给比赛场预留50%的机器人
|
if Config.Count-Config.MatchCount > len(pm.playersSession) {
|
||||||
if pm.playerEnterType {
|
|
||||||
pm.playerEnterType = false
|
|
||||||
pm.playersMatchSession[snid] = s
|
|
||||||
} else {
|
|
||||||
pm.playerEnterType = true
|
|
||||||
pm.playersSession[snid] = s
|
pm.playersSession[snid] = s
|
||||||
|
} else {
|
||||||
|
pm.playersMatchSession[snid] = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
func SendEmote(s *netlib.Session, scene *TienLenScene, p *TienLenPlayer, arr []int, tp int) {
|
func SendEmote(s *netlib.Session, scene *TienLenScene, p *TienLenPlayer, arr []int, tp int) {
|
||||||
if !base.SceneMgrSingleton.IsFreeMode(scene.GetRoomId()) && !scene.IsMatchScene() {
|
if !base.SceneMgrSingleton.IsFreeMode(scene.GetRoomId()) && !scene.IsMatchScene() {
|
||||||
if p.EmoteTimes[tp] == 0 {
|
if p.EmoteTimes[tp] == 0 {
|
||||||
base.SendEmote(s, p, arr)
|
base.SendEmote(s, arr)
|
||||||
}
|
}
|
||||||
p.EmoteTimes[tp]++
|
p.EmoteTimes[tp]++
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue