惊喜货物只针对与对应出售货物的商人出现
This commit is contained in:
parent
8f035baaad
commit
a9a117b56c
@ -80,9 +80,10 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
|
||||
if trolltrain.Circle != circleCount {
|
||||
trolltrain.SurpriseID = make(map[int32]int32, 0)
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(trainNum)))
|
||||
goods := this.configure.GetTrollAllGoods()
|
||||
n2, _ := rand.Int(rand.Reader, big.NewInt(int64(len(goods)-1))) //算的是下标所以-1
|
||||
trolltrain.SurpriseID[int32(n.Int64())+1] = int32(n2.Int64()) + 1
|
||||
// 只算当前商人所属的货物
|
||||
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
|
||||
@ -91,7 +92,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
|
||||
index = circleCount * trainNum // 计算火车的位置信息
|
||||
for _, v := range szTrain {
|
||||
if leftTime <= v {
|
||||
trolltrain.RefreshTime = trolltrain.Ctime + int64(circleCount*circletime+leftTime)
|
||||
trolltrain.RefreshTime = configure.Now().Unix() - int64(leftTime) //trolltrain.Ctime + int64(circleCount*circletime+leftTime)
|
||||
trolltrain.RangeId = (index % maxCoefficient) + 1
|
||||
trolltrain.TarinPos = (index % trainNum) + 1
|
||||
break
|
||||
|
@ -166,3 +166,20 @@ func (this *configureComp) GetTrollAllGoods() (data []*cfg.GameTrollGoodsData) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 返回商人货物信息
|
||||
func (this *configureComp) GetTrollGoodsFor(trainID int32) (data []int32) {
|
||||
if v, err := this.GetConfigure(game_trollgoods); err == nil {
|
||||
if configure, ok := v.(*cfg.GameTrollGoods); ok {
|
||||
for _, v := range configure.GetDataList() {
|
||||
if v.Goodsfor == trainID {
|
||||
data = append(data, v.Id)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Errorf("get GameTrollGoodsData conf err:%v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user