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) } //更新英雄数据 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 }