From 7ed2750398ec4b5ba2f3354f676f626a4617aebc Mon Sep 17 00:00:00 2001 From: zhaocy Date: Wed, 29 Jun 2022 19:23:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B6=88=E8=80=97=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) } //更新英雄数据