堆叠数量bug

This commit is contained in:
meixiongfeng 2022-07-23 00:18:46 +08:00
parent 02b2294af3
commit 1bd6d9dfaf
3 changed files with 62 additions and 25 deletions

View File

@ -154,7 +154,7 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
}
// 执行升级逻辑
code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
newhero, oldhero, code := this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
if code != pb.ErrorCode_Success {
// 升级失败资源回退
code = this.module.DispenseRes(session, res, true)
@ -172,17 +172,16 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
_costHero = append(_costHero, costHero)
}
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, oldhero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Lv = curLv
_hero.Exp = curExp
_hero.Property = m
_costHero = append(_costHero, _hero)
oldhero.Property = m
_costHero = append(_costHero, oldhero)
_costHero = append(_costHero, newhero)
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: _costHero})
//session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: newhero})
if iLvUp > 0 { // 升级了 统计任务
this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroLevel, &pb.TaskParam{Second: iLvUp})
}

View File

@ -283,12 +283,20 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
if len(hero.EquipID) == 0 {
return
}
var (
curSameCount int32
)
update := make(map[string]interface{})
if hero.IsOverlying && hero.SameCount > 1 {
hero.SameCount -= 1
update["sameCount"] = hero.SameCount
update["isOverlying"] = false
curSameCount = hero.SameCount - 1
hero.SameCount = 1
hero.IsOverlying = false
update["suiteId"] = hero.SuiteId
update["suiteExtId"] = hero.SuiteExtId
update["equipID"] = hero.EquipID
update["isoverlying"] = false
update["sameCount"] = 1
if err = this.modifyHeroData(hero.Uid, hero.Id, update); err != nil {
this.moduleHero.Errorf("%v", err)
return
@ -299,12 +307,13 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
this.moduleHero.Errorf("%v", err)
return
}
newHero.EquipID = hero.EquipID
update["suiteId"] = hero.SuiteId
update["suiteExtId"] = hero.SuiteExtId
update["equipID"] = hero.EquipID
update["isoverlying"] = false
this.modifyHeroData(newHero.Uid, newHero.Id, update)
update1 := make(map[string]interface{})
update1["sameCount"] = curSameCount
update1["isoverlying"] = true
newHero.IsOverlying = true
newHero.SameCount = curSameCount
this.modifyHeroData(newHero.Uid, newHero.Id, update1)
} else {
update["equipID"] = hero.EquipID
update["isoverlying"] = false

View File

@ -112,10 +112,11 @@ func (this *Hero) QueryHeroAmount(uId string, heroCfgId int32) (amount uint32) {
}
// 给指定英雄加经验
func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (code pb.ErrorCode) {
func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (newhero *pb.DBHero, oldhero *pb.DBHero, code pb.ErrorCode) {
var (
curExp int32
curLv int32
err1 error
)
_hero, err := this.GetHero(uid, heroId) // 获取英雄信息
if err != 0 {
@ -165,17 +166,45 @@ func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (code pb.Erro
data["def"] = int32(nowConfig.Def - preConfig.Def)
this.modelHero.mergeMainProperty(uid, heroId, data)
}
update := map[string]interface{}{
_hero.SameCount -= 1
curCount := _hero.SameCount
if _hero.SameCount == 0 {
this.modelHero.consumeHeroCard(uid, _hero.Id, 1)
}
// else {
// update := map[string]interface{}{
// "sameCount": _hero.SameCount,
// }
// if err := this.modelHero.modifyHeroData(uid, heroId, update); err != nil {
// code = pb.ErrorCode_DBError
// } // 修改英雄数据
// }
// 新增英雄
update1 := map[string]interface{}{
"lv": curLv,
"exp": curExp,
"isOverlying": false,
"sameCount": 1,
}
if err := this.modelHero.modifyHeroData(uid, heroId, update); err != nil {
newhero, err1 = this.modelHero.createOneHero(uid, _hero.HeroID)
if err1 != nil {
code = pb.ErrorCode_DBError
} // 修改英雄数据
}
_hero.Lv = curLv
_hero.Exp = curExp
_hero.IsOverlying = false
_hero.SameCount = 1
newhero.SameCount = curCount
update := map[string]interface{}{
"sameCount": curCount,
}
if err := this.modelHero.modifyHeroData(uid, _hero.Id, update); err != nil {
code = pb.ErrorCode_DBError
}
if err := this.modelHero.modifyHeroData(uid, newhero.Id, update1); err != nil {
code = pb.ErrorCode_DBError
}
oldhero = _hero
} else {
code = pb.ErrorCode_HeroNoExist
return