diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 7b1e5e420..b78464f11 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -119,14 +119,14 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero { } //消耗一张英雄卡 -func (this *ModelHero) consumeOneHeroCard(hero *pb.DBHero, count int32) error { - if hero == nil { - return fmt.Errorf("hero no exist") +func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err error) { + for i := 0; i < int(count); i++ { + if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil { + log.Errorf("%v", err) + break + } } - if hero.SameCount < count { - return fmt.Errorf("card no enough") - } - return this.moduleHero.modelHero.DelListlds(hero.Uid, hero.Id) + return } //更新英雄数据 diff --git a/modules/hero/module.go b/modules/hero/module.go index 9e033c60b..b0650a012 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(v, count) + err := this.modelHero.consumeOneHeroCard(v.Uid, v.Id, count) if err != nil { return pb.ErrorCode_DBError }