|
|
@ -29,6 +29,7 @@ type RobotManager struct { |
|
|
|
GronTimer *gron.Cron |
|
|
|
Lock sync.RWMutex |
|
|
|
GameRoom *Room |
|
|
|
FirstEnterTimer int64 //首个机器人进入时间
|
|
|
|
NextEnterTimer int64 //下个机器人进入时间
|
|
|
|
FlushCountTimer int64 //下次刷新机器人数量的时间
|
|
|
|
MaxCount int //机器人数量
|
|
|
@ -81,12 +82,44 @@ func (r *RobotManager) OnInit(conf string, GameRoom *Room) { |
|
|
|
nowUnixNano := time.Now().UnixNano() |
|
|
|
nowMilliSeconds := nowUnixNano / 1e6 |
|
|
|
|
|
|
|
// 这里现在修改立马进入一个机器人
|
|
|
|
r.NextEnterTimer = nowMilliSeconds + 100 |
|
|
|
//MinInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000
|
|
|
|
//MaxInterTime := GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000
|
|
|
|
//rTime := int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime)
|
|
|
|
//r.NextEnterTimer = nowMilliSeconds + rTime
|
|
|
|
// 第一个进入的机器人 只判断一次
|
|
|
|
r.FirstEnterTimer = 0 |
|
|
|
if r.GameRoom.CreatorId != 0 { |
|
|
|
FirstMinTime := r.GameRoom.TableConfig.FirstRobotCheckMinFrequency |
|
|
|
FirstMaxTime := r.GameRoom.TableConfig.FirstRobotCheckMaxFrequency |
|
|
|
if FirstMaxTime <= FirstMinTime { |
|
|
|
r.FirstEnterTimer = nowMilliSeconds + FirstMaxTime |
|
|
|
} else { |
|
|
|
r.FirstEnterTimer = nowMilliSeconds + rand.Int63n(FirstMaxTime-FirstMinTime) + FirstMinTime |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 间隔多少时间正常进个机器人
|
|
|
|
MinInterTime := 0 |
|
|
|
MaxInterTime := 0 |
|
|
|
if r.GameRoom.TableConfig != nil { |
|
|
|
MinInterTime = int(r.GameRoom.TableConfig.RobotCheckMinFrequency) * 1000 |
|
|
|
MaxInterTime = int(r.GameRoom.TableConfig.RobotCheckMaxFrequency) * 1000 |
|
|
|
log.Debug(" 后台配置 机器人进入频率 最小 ", MinInterTime, " 最大 ", MaxInterTime) |
|
|
|
} else { |
|
|
|
MinInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[0] * 1000 |
|
|
|
MaxInterTime = r.GameRoom.BloodCtrl.AndroidOprateConfig.JoinHZ[1] * 1000 |
|
|
|
} |
|
|
|
|
|
|
|
rTime := int64(0) |
|
|
|
if MaxInterTime <= MinInterTime { |
|
|
|
rTime = int64(MinInterTime) |
|
|
|
} else { |
|
|
|
rTime = int64(rand.Intn(MaxInterTime-MinInterTime) + MinInterTime) |
|
|
|
} |
|
|
|
|
|
|
|
//处理个意外
|
|
|
|
if rTime == 0 { |
|
|
|
rTime = 2000 |
|
|
|
log.Error(" 出现0了 是不行的 ", r.GameRoom.RoomID) |
|
|
|
} |
|
|
|
|
|
|
|
r.NextEnterTimer = nowMilliSeconds + rTime |
|
|
|
|
|
|
|
if GameRoom.TableConfig != nil { |
|
|
|
r.MaxCount = 0 |
|
|
|