消息分发读取
This commit is contained in:
parent
94e7197673
commit
d7b0d07b06
@ -28,24 +28,20 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
// GetMsgDistribute 获取消息分发规则读取配置表
|
||||
func (this *configureComp) GetMsgDistribute(msgmid, msguid string) (rule string, ok bool) {
|
||||
var (
|
||||
err error
|
||||
v interface{}
|
||||
item *cfg.GameMsgdistribData
|
||||
)
|
||||
if v, err = this.GetConfigure(game_msgdistrib); err != nil {
|
||||
ok = false
|
||||
return
|
||||
} else {
|
||||
if v, err := this.GetConfigure(game_msgdistrib); err == nil {
|
||||
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgmid]; ok && item.Open {
|
||||
rule = item.Routrules
|
||||
return
|
||||
} else {
|
||||
msgid := strings.ToLower(fmt.Sprintf("%s.%s", msgmid, msguid))
|
||||
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgid]; ok && item.Open {
|
||||
rule = item.Routrules
|
||||
return
|
||||
}
|
||||
ok = false
|
||||
}
|
||||
}
|
||||
ok = false
|
||||
return
|
||||
}
|
||||
|
@ -18,33 +18,20 @@ func (this *apiComp) SurpriseIdCheck(session comm.IUserSession, req *pb.TrollSur
|
||||
|
||||
func (this *apiComp) SurpriseId(session comm.IUserSession, req *pb.TrollSurpriseIdReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
update map[string]interface{}
|
||||
maxCoefficient int32
|
||||
circletime int32 // 循环一个周期的时间
|
||||
circleCount int32 // 循环的次数
|
||||
update map[string]interface{}
|
||||
)
|
||||
|
||||
update = make(map[string]interface{})
|
||||
if code = this.SurpriseIdCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
trolltrain, err := this.module.modelTroll.getTrollList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
maxCoefficient = this.configure.GetTrollMaxCoefficientNux() // 增长幅度的最大值
|
||||
if maxCoefficient == 0 {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
|
||||
/// 计算经过了多少个周期
|
||||
szTrain := this.configure.GetTrollAllTrain()
|
||||
var (
|
||||
circletime int32 // 循环一个周期的时间
|
||||
circleCount int32 // 循环的次数
|
||||
|
||||
)
|
||||
for _, v := range szTrain {
|
||||
circletime += v
|
||||
}
|
||||
@ -53,25 +40,24 @@ func (this *apiComp) SurpriseId(session comm.IUserSession, req *pb.TrollSurprise
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if int32(configure.Now().Unix()-trolltrain.RefreshTime) < szTrain[trolltrain.TarinPos-1] {
|
||||
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})
|
||||
return
|
||||
}
|
||||
trainNum := this.configure.GetTrollMaxTraintNum()
|
||||
if int32(configure.Now().Unix()-trolltrain.RefreshTime) >= szTrain[trolltrain.TarinPos-1] {
|
||||
trainNum := this.configure.GetTrollMaxTraintNum()
|
||||
|
||||
t := int32(configure.Now().Unix() - trolltrain.Ctime)
|
||||
circleCount = t / circletime // 经过的周期数
|
||||
if trolltrain.Circle != circleCount {
|
||||
trolltrain.SurpriseID = make(map[int32]int32, 0)
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(trainNum)))
|
||||
// 只算当前商人所属的货物
|
||||
g := this.configure.GetTrollGoodsFor(int32(n.Int64()) + 1)
|
||||
n2, _ := rand.Int(rand.Reader, big.NewInt(int64(len(g))))
|
||||
trolltrain.SurpriseID[int32(n.Int64())+1] = g[int32(n2.Int64())]
|
||||
update["surpriseID"] = trolltrain.SurpriseID
|
||||
trolltrain.Circle = circleCount
|
||||
update["circle"] = trolltrain.Circle
|
||||
this.module.ModifyTrollData(session.GetUserId(), update)
|
||||
t := int32(configure.Now().Unix() - trolltrain.Ctime)
|
||||
circleCount = t / circletime // 经过的周期数
|
||||
if trolltrain.Circle != circleCount {
|
||||
trolltrain.SurpriseID = make(map[int32]int32, 0)
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(trainNum)))
|
||||
// 只算当前商人所属的货物
|
||||
g := this.configure.GetTrollGoodsFor(int32(n.Int64()) + 1)
|
||||
n2, _ := rand.Int(rand.Reader, big.NewInt(int64(len(g))))
|
||||
trolltrain.SurpriseID[int32(n.Int64())+1] = g[int32(n2.Int64())]
|
||||
update["surpriseID"] = trolltrain.SurpriseID
|
||||
trolltrain.Circle = circleCount
|
||||
update["circle"] = trolltrain.Circle
|
||||
this.module.ModifyTrollData(session.GetUserId(), update)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), TrollSurpriseIdResp, &pb.TrollSurpriseIdResp{
|
||||
|
Loading…
Reference in New Issue
Block a user