机器人比赛场数量参数

This commit is contained in:
sk 2024-04-28 18:02:16 +08:00
parent 95701368a6
commit cad0f24bd8
4 changed files with 16 additions and 15 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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
}
}

View File

@ -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]++
}