This commit is contained in:
meixiongfeng 2022-06-29 19:32:16 +08:00
commit bd1b5b2735
2 changed files with 9 additions and 3 deletions

View File

@ -119,8 +119,14 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero {
} }
//消耗一张英雄卡 //消耗一张英雄卡
func (this *ModelHero) consumeOneHeroCard(uid, heroId string) error { func (this *ModelHero) consumeOneHeroCard(hero *pb.DBHero, count int32) error {
return this.moduleHero.modelHero.DelListlds(uid, heroId) 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)
} }
//更新英雄数据 //更新英雄数据

View File

@ -58,7 +58,7 @@ func (this *Hero) ChangeCard(uId string, heroCfgId int32, count int32) (code pb.
} }
for _, v := range curList { for _, v := range curList {
err := this.modelHero.consumeOneHeroCard(uId, v.Id) err := this.modelHero.consumeOneHeroCard(v, count)
if err != nil { if err != nil {
return pb.ErrorCode_DBError return pb.ErrorCode_DBError
} }