From 31fc23c9459a1731cb9f92de1e7cf724b1c1dc74 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 30 Jun 2022 17:06:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=A3=E9=99=A4=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_resonance.go | 2 +- modules/hero/api_starUp.go | 4 +++- modules/hero/api_strengthen.go | 10 +++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index 088cb5534..5ee8af76e 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -107,7 +107,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf if v.A == "attr" { // 查询玩家身上资源是否满足 value := this.moduleHero.api.user.QueryAttributeValue(session.GetUserId(), v.T) if value >= v.N { // 直接删除财富 - code = this.user.AddAttributeValue(session.GetUserId(), v.T, -v.N) // 扣除资源 + code = this.user.AddAttributeValue(session.GetUserId(), v.T, value-v.N) // 扣除资源 break } else { code = pb.ErrorCode_ResNoEnough diff --git a/modules/hero/api_starUp.go b/modules/hero/api_starUp.go index 4a6e65f1b..94dcc3fd8 100644 --- a/modules/hero/api_starUp.go +++ b/modules/hero/api_starUp.go @@ -97,6 +97,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He result = map[string]interface{}{ "costGold": target.Gold, "heroObj": tagHero, + "curGold": curGold, } return } @@ -106,6 +107,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string costGold := agrs["costGold"].(int32) _hero := agrs["heroObj"].(*pb.DBHero) + curGold := agrs["curGold"].(int32) if _hero == nil { code = pb.ErrorCode_HeroNoExist return @@ -117,7 +119,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string }() // 消耗道具 - code = this.user.AddAttributeValue(session.GetUserId(), "gold", -costGold) // 减少金币 + code = this.user.AddAttributeValue(session.GetUserId(), "gold", curGold-costGold) // 减少金币 if code != pb.ErrorCode_Success { log.Errorf("cost gold failed ,count = %d", costGold) code = pb.ErrorCode_GoldNoEnough diff --git a/modules/hero/api_strengthen.go b/modules/hero/api_strengthen.go index 75a0bc158..49482e332 100644 --- a/modules/hero/api_strengthen.go +++ b/modules/hero/api_strengthen.go @@ -21,8 +21,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero atn = map[string]interface{}{} ) atn = make(map[string]interface{}, 0) - curGold = 0 - costRes = 0 + _hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在 if err != pb.ErrorCode_Success { @@ -155,15 +154,12 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, agrs map[string]i return } // 删除经验卡 - err := this.moduleHero.modelHero.DelListlds(session.GetUserId(), req.ExpCardID) + err := this.moduleHero.modelHero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount) if err != nil { log.Errorf("delete err failed err:%T!", err) return } - //code = this.moduleHero.modelHero.moduleHero.DelCard(req.ExpCardID, req.Amount) - if code != pb.ErrorCode_Success { - return - } + err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化 if err != nil { log.Errorf("PushHeroProperty err!")