This commit is contained in:
liwei1dao 2023-05-17 18:59:09 +08:00
commit ba20d5fd20
2 changed files with 18 additions and 4 deletions

View File

@ -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]

View File

@ -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 {
if conf := this.configure.GetCaravanLv(curLv + 1); conf != nil {
if conf.Newmoneyexp <= int32(data.Profit) {
curLv++
if conf := this.configure.GetCaravanLv(curLv); conf != nil {
if conf.Newmoneyexp > int32(data.Profit) {
curLv -= 1
} else {
break
}
} else {