From 7ed2750398ec4b5ba2f3354f676f626a4617aebc Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 19:23:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B6=88=E8=80=97?= =?UTF-8?q?=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/model_hero.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index b6b4490b7..7b1e5e420 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -119,8 +119,14 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero { } //消耗一张英雄卡 -func (this *ModelHero) consumeOneHeroCard(uid, heroId string) error { - return this.moduleHero.modelHero.DelListlds(uid, heroId) +func (this *ModelHero) consumeOneHeroCard(hero *pb.DBHero, count int32) error { + if hero == nil { + return fmt.Errorf("hero no exist") + } + if hero.SameCount < count { + return fmt.Errorf("card no enough") + } + return this.moduleHero.modelHero.DelListlds(hero.Uid, hero.Id) } //更新英雄数据 From de0befd8bbdf8706fee55f6144b932336288336a Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 19:25:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B6=88=E8=80=97?= =?UTF-8?q?=E5=8D=A12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hero/module.go b/modules/hero/module.go index b407d0c53..f64cb9880 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -58,7 +58,7 @@ func (this *Hero) ChangeCard(uId string, heroCfgId int32, count int32) (code pb. } for _, v := range curList { - err := this.modelHero.consumeOneHeroCard(uId, v.Id) + err := this.modelHero.consumeOneHeroCard(v, count) if err != nil { return pb.ErrorCode_DBError }