From 4335663fbc0c15d9ab4c33bcc12979d2e70007cf Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sat, 23 Jul 2022 01:40:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/module.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/modules/hero/module.go b/modules/hero/module.go index d6dbcf3f0..597d4256a 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -166,10 +166,22 @@ func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (newhero *pb. data["def"] = int32(nowConfig.Def - preConfig.Def) this.modelHero.mergeMainProperty(uid, heroId, data) } - _hero.SameCount -= 1 - curCount := _hero.SameCount - if _hero.SameCount == 0 { + + curCount := _hero.SameCount - 1 + if curCount == 0 { this.modelHero.consumeHeroCard(uid, _hero.Id, 1) + } else { + newhero, err1 = this.modelHero.createOneHero(uid, _hero.HeroID) + if err1 != nil { + code = pb.ErrorCode_DBError + } + update := map[string]interface{}{ + "sameCount": curCount, + } + newhero.SameCount = curCount + if err := this.modelHero.modifyHeroData(uid, newhero.Id, update); err != nil { + code = pb.ErrorCode_DBError + } } update1 := map[string]interface{}{ "lv": curLv, @@ -177,24 +189,16 @@ func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (newhero *pb. "isOverlying": false, "sameCount": 1, } - newhero, err1 = this.modelHero.createOneHero(uid, _hero.HeroID) - if err1 != nil { - code = pb.ErrorCode_DBError - } + _hero.Lv = curLv _hero.Exp = curExp _hero.IsOverlying = false _hero.SameCount = 1 - newhero.SameCount = curCount - update := map[string]interface{}{ - "sameCount": curCount, - } + if err := this.modelHero.modifyHeroData(uid, _hero.Id, update1); err != nil { code = pb.ErrorCode_DBError } - if err := this.modelHero.modifyHeroData(uid, newhero.Id, update); err != nil { - code = pb.ErrorCode_DBError - } + oldhero = _hero } else { code = pb.ErrorCode_HeroNoExist