From a9a117b56c83bb3235db74ce8ba7af848592e31d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 10 Nov 2022 15:21:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=83=8A=E5=96=9C=E8=B4=A7=E7=89=A9=E5=8F=AA?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E4=B8=8E=E5=AF=B9=E5=BA=94=E5=87=BA=E5=94=AE?= =?UTF-8?q?=E8=B4=A7=E7=89=A9=E7=9A=84=E5=95=86=E4=BA=BA=E5=87=BA=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/troll/api_getlist.go | 9 +++++---- modules/troll/comp_configure.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/troll/api_getlist.go b/modules/troll/api_getlist.go index d94037722..dbeb880f5 100644 --- a/modules/troll/api_getlist.go +++ b/modules/troll/api_getlist.go @@ -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 diff --git a/modules/troll/comp_configure.go b/modules/troll/comp_configure.go index bff1b384d..b10ca9df8 100644 --- a/modules/troll/comp_configure.go +++ b/modules/troll/comp_configure.go @@ -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 +}