修改卡消耗
This commit is contained in:
parent
93570f645f
commit
541ffb0d42
@ -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
|
||||
}
|
||||
|
||||
//更新英雄数据
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user