From 1267123e1af070d6c81cfb7482ed68819313a09f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 17 May 2023 18:56:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E9=98=9F=E7=AD=89=E7=BA=A7=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=8F=91=E5=A5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/api_buyorsell.go | 14 ++++++++++++++ modules/caravan/module.go | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/caravan/api_buyorsell.go b/modules/caravan/api_buyorsell.go index 4efedbc6c..af98a37e6 100644 --- a/modules/caravan/api_buyorsell.go +++ b/modules/caravan/api_buyorsell.go @@ -78,8 +78,22 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe return } // 统计 收益 + var lvReward []*cfg.Gameatn caravan.Profit += int64(addScore) update["profit"] = caravan.Profit + curLv := this.module.CheckCaravavLvUp(caravan) + if curLv > caravan.Lv { + for i := caravan.Lv; i <= curLv-caravan.Lv; i++ { + if c := this.module.configure.GetCaravanLv(int32(i)); c != nil { + lvReward = append(lvReward, c.Reward...) + } + } + } + if len(lvReward) > 0 { + if reward := this.module.DispenseRes(session, lvReward, true); reward != pb.ErrorCode_Success { + this.module.Errorf("lv reward dispenseRes err:%v", lvReward) + } + } } else { // 买入 for k, v := range req.Items { items, ok := caravan.Items[k] diff --git a/modules/caravan/module.go b/modules/caravan/module.go index 4e8290c81..a351e1451 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -328,10 +328,10 @@ func (this *Caravan) ArrayBag(data *pb.DBCaravan, limit int32) (bFull bool) { func (this *Caravan) CheckCaravavLvUp(data *pb.DBCaravan) (curLv int32) { curLv = data.Lv for { - curLv++ - if conf := this.configure.GetCaravanLv(curLv); conf != nil { - if conf.Newmoneyexp > int32(data.Profit) { - curLv -= 1 + if conf := this.configure.GetCaravanLv(curLv + 1); conf != nil { + if conf.Newmoneyexp <= int32(data.Profit) { + curLv++ + } else { break } } else {