堆叠数量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 { if code != pb.ErrorCode_Success {
// 升级失败资源回退 // 升级失败资源回退
code = this.module.DispenseRes(session, res, true) 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) _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 { if err1 != nil {
this.module.Errorf("PushHeroProperty err!") this.module.Errorf("PushHeroProperty err!")
} }
_hero.Lv = curLv
_hero.Exp = curExp oldhero.Property = m
_hero.Property = m _costHero = append(_costHero, oldhero)
_costHero = append(_costHero, _hero) _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: _costHero})
//session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}}) session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: newhero})
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
if iLvUp > 0 { // 升级了 统计任务 if iLvUp > 0 { // 升级了 统计任务
this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroLevel, &pb.TaskParam{Second: iLvUp}) 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 { if len(hero.EquipID) == 0 {
return return
} }
var (
curSameCount int32
)
update := make(map[string]interface{}) update := make(map[string]interface{})
if hero.IsOverlying && hero.SameCount > 1 { if hero.IsOverlying && hero.SameCount > 1 {
hero.SameCount -= 1 curSameCount = hero.SameCount - 1
update["sameCount"] = hero.SameCount hero.SameCount = 1
update["isOverlying"] = false 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 { if err = this.modifyHeroData(hero.Uid, hero.Id, update); err != nil {
this.moduleHero.Errorf("%v", err) this.moduleHero.Errorf("%v", err)
return return
@ -299,12 +307,13 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
this.moduleHero.Errorf("%v", err) this.moduleHero.Errorf("%v", err)
return return
} }
newHero.EquipID = hero.EquipID update1 := make(map[string]interface{})
update["suiteId"] = hero.SuiteId
update["suiteExtId"] = hero.SuiteExtId update1["sameCount"] = curSameCount
update["equipID"] = hero.EquipID update1["isoverlying"] = true
update["isoverlying"] = false newHero.IsOverlying = true
this.modifyHeroData(newHero.Uid, newHero.Id, update) newHero.SameCount = curSameCount
this.modifyHeroData(newHero.Uid, newHero.Id, update1)
} else { } else {
update["equipID"] = hero.EquipID update["equipID"] = hero.EquipID
update["isoverlying"] = false 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 ( var (
curExp int32 curExp int32
curLv int32 curLv int32
err1 error
) )
_hero, err := this.GetHero(uid, heroId) // 获取英雄信息 _hero, err := this.GetHero(uid, heroId) // 获取英雄信息
if err != 0 { 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) data["def"] = int32(nowConfig.Def - preConfig.Def)
this.modelHero.mergeMainProperty(uid, heroId, data) this.modelHero.mergeMainProperty(uid, heroId, data)
} }
_hero.SameCount -= 1
update := map[string]interface{}{ 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, "lv": curLv,
"exp": curExp, "exp": curExp,
"isOverlying": false, "isOverlying": false,
"sameCount": 1,
} }
newhero, err1 = this.modelHero.createOneHero(uid, _hero.HeroID)
if err := this.modelHero.modifyHeroData(uid, heroId, update); err != nil { if err1 != nil {
code = pb.ErrorCode_DBError 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 { } else {
code = pb.ErrorCode_HeroNoExist code = pb.ErrorCode_HeroNoExist
return return